feat(operations): add create_project operation across agent, mcp, and cli (#529)

* feat(operations): add create_project operation across agent, mcp, and cli

* fix(api): remove legacy team creation endpoint

* fix(api): preserve ProjectInfo response on POST /teams/:teamId/projects
This commit is contained in:
Yiling-J
2026-11-13 11:43:08 +08:00
committed by GitHub
parent 97c2939b5e
commit c55804a548
20 changed files with 369 additions and 66 deletions
+10 -12
View File
@@ -77,7 +77,6 @@ vi.mock('@shumai/core/src/workflowTask/workflowTask', () => ({
describe('team api', () => {
const app = new Hono().use('*', authMiddleware).route('/', teamRoute)
let mockCreateTeam: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockGetUserTeams: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockGetMe: any // eslint-disable-line @typescript-eslint/no-explicit-any
let mockGetTeamMembers: any // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -90,7 +89,6 @@ describe('team api', () => {
let mockUpdateMe: any // eslint-disable-line @typescript-eslint/no-explicit-any
beforeEach(() => {
mockCreateTeam = vi.spyOn(teamService, 'createTeam')
mockGetUserTeams = vi.spyOn(teamService, 'getUserTeams')
mockGetMe = vi.spyOn(teamService, 'getMe')
mockGetTeamMembers = vi.spyOn(teamService, 'getTeamMembers')
@@ -108,9 +106,13 @@ describe('team api', () => {
vi.restoreAllMocks()
})
it('POST /teams creates a new team', async () => {
const mockTeam = { id: 't1', name: 'New Team', updatedAt: new Date() }
mockCreateTeam.mockResolvedValue(mockTeam)
it('POST /teams returns 404 without creating a team or writing an audit entry', async () => {
const createTeam = vi.spyOn(teamService, 'createTeam').mockResolvedValue({
id: 't1',
name: 'New Team',
updatedAt: new Date(),
})
const { auditLogService } = await import('@shumai/core/src/auditLog/auditLog')
const res = await app.request('/teams', {
method: 'POST',
@@ -120,13 +122,9 @@ describe('team api', () => {
}),
})
expect(res.status).toBe(200)
const data = await res.json()
expect(data.id).toBe('t1')
expect(mockCreateTeam).toHaveBeenCalledWith(
expect.objectContaining({ id: 'user1' }),
expect.objectContaining({ name: 'New Team' }),
)
expect(res.status).toBe(404)
expect(createTeam).not.toHaveBeenCalled()
expect(auditLogService.logAction).not.toHaveBeenCalled()
})
it('GET /teams returns user teams', async () => {