test(core): add missing tests for methods introduced in 97069042

Add comprehensive test coverage for 5 core service methods that were
added in the layered architecture refactor but lacked tests:

- AgentService.getAgent: found/not-found cases
- ProjectService.getUserProjects: team scope, project scope,
  multi-team aggregation, limit, and empty result cases
- SkillService.getSkill: full field mapping and not-found cases
- TeamService.hasWritableRoleInAnyTeam: owner, editor, reviewer,
  and no-membership cases
- UserService (new file): getUserById and createGuestUser
This commit is contained in:
yiling
2026-08-01 20:44:34 +08:00
parent 1600949e4a
commit 3b86d9b6d8
5 changed files with 269 additions and 0 deletions
+22
View File
@@ -399,4 +399,26 @@ describe('AgentService', () => {
expect(found?.creator?.name).toBe('Regular User')
})
})
describe('getAgent', () => {
test('returns agent when it exists', async () => {
const db = prisma
const svc = new AgentService()
const { agent } = await setupTestData(db)
const result = await svc.getAgent({ agentId: agent.id })
expect(result).not.toBeNull()
expect(result?.id).toBe(agent.id)
expect(result?.type).toBe('chat')
})
test('returns null for non-existent ID', async () => {
const svc = new AgentService()
const result = await svc.getAgent({ agentId: 'nonexistent-id' })
expect(result).toBeNull()
})
})
})