mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 06:48:19 +00:00
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:
@@ -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()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user