refactor(api): enforce layered architecture by moving db queries to core services

This commit is contained in:
yiling
2026-08-01 16:25:01 +08:00
parent fb66166b49
commit 97069042b2
26 changed files with 256 additions and 363 deletions
+4 -11
View File
@@ -11,22 +11,15 @@ vi.mock('@shumai/core/src/auditLog/auditLog', () => ({
logAction: vi.fn().mockResolvedValue({}),
},
}))
vi.mock('@shumai/db', async (importOriginal) => {
const actual = await importOriginal<typeof import('@shumai/db')>()
return {
...actual,
prisma: {
agent: {
findUnique: vi.fn().mockResolvedValue({ teamId: 'team1' }),
},
},
}
})
describe('Agent API', () => {
beforeEach(() => {
vi.clearAllMocks()
vi.mocked(authzService.hasPermission).mockResolvedValue(undefined)
vi.mocked(agentService.getAgent).mockResolvedValue({
id: 'agent1',
teamId: 'team1',
} as unknown as Awaited<ReturnType<typeof agentService.getAgent>>)
})
describe('GET /teams/:teamId/agents', () => {