fix(test): maak create-sprint auto-code test datum-onafhankelijk
De test hardcodede 2026-05-11-datums maar berekende "today" dynamisch, waardoor hij alleen op die datum slaagde. Mock-codes nu relatief aan today. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
31e9148571
commit
f340310e31
1 changed files with 6 additions and 4 deletions
|
|
@ -104,10 +104,13 @@ describe('handleCreateSprint', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('auto-code increments past existing same-day sprints', async () => {
|
it('auto-code increments past existing same-day sprints', async () => {
|
||||||
|
// Codes moeten relatief aan "vandaag" zijn: generateNextSprintCode telt
|
||||||
|
// alleen same-day sprints. Hardcoded datums maakten deze test datum-flaky.
|
||||||
|
const today = new Date().toISOString().slice(0, 10)
|
||||||
mockPrisma.sprint.findMany.mockResolvedValue([
|
mockPrisma.sprint.findMany.mockResolvedValue([
|
||||||
{ code: 'S-2026-05-11-1' },
|
{ code: `S-${today}-1` },
|
||||||
{ code: 'S-2026-05-11-3' },
|
{ code: `S-${today}-3` },
|
||||||
{ code: 'S-2026-05-10-7' },
|
{ code: 'S-2020-01-01-7' },
|
||||||
])
|
])
|
||||||
mockPrisma.sprint.create.mockResolvedValue({
|
mockPrisma.sprint.create.mockResolvedValue({
|
||||||
id: 'spr-3', code: 'X', sprint_goal: 'g', status: 'OPEN', start_date: new Date(), created_at: new Date(),
|
id: 'spr-3', code: 'X', sprint_goal: 'g', status: 'OPEN', start_date: new Date(), created_at: new Date(),
|
||||||
|
|
@ -115,7 +118,6 @@ describe('handleCreateSprint', () => {
|
||||||
|
|
||||||
await handleCreateSprint({ product_id: PRODUCT_ID, sprint_goal: 'g' })
|
await handleCreateSprint({ product_id: PRODUCT_ID, sprint_goal: 'g' })
|
||||||
|
|
||||||
const today = new Date().toISOString().slice(0, 10)
|
|
||||||
expect(mockPrisma.sprint.create.mock.calls[0][0].data.code).toBe(`S-${today}-4`)
|
expect(mockPrisma.sprint.create.mock.calls[0][0].data.code).toBe(`S-${today}-4`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue