mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 07:28: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:
@@ -223,4 +223,36 @@ describe('SkillService', () => {
|
||||
})
|
||||
expect(dbSkill?.config).toEqual(newConfig)
|
||||
})
|
||||
|
||||
describe('getSkill', () => {
|
||||
it('returns skill info with teamId when it exists', async () => {
|
||||
const team = await prisma.team.create({ data: { name: 'Test Team' } })
|
||||
const skill = await prisma.skill.create({
|
||||
data: {
|
||||
name: 'My Skill',
|
||||
description: 'A description',
|
||||
assetId: 'asset-1',
|
||||
hash: 'hash-1',
|
||||
teamId: team.id,
|
||||
},
|
||||
})
|
||||
|
||||
const result = await skillService.getSkill(skill.id)
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.id).toBe(skill.id)
|
||||
expect(result?.name).toBe('My Skill')
|
||||
expect(result?.description).toBe('A description')
|
||||
expect(result?.teamId).toBe(team.id)
|
||||
expect(result?.assetId).toBe('asset-1')
|
||||
expect(result?.hash).toBe('hash-1')
|
||||
expect(result?.permission).toBe('reviewer')
|
||||
expect(typeof result?.createdAt).toBe('string')
|
||||
expect(typeof result?.updatedAt).toBe('string')
|
||||
})
|
||||
|
||||
it('returns null for non-existent ID', async () => {
|
||||
const result = await skillService.getSkill('nonexistent-id')
|
||||
expect(result).toBeNull()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user