test(e2e): mirror task id to index in TaskFactory

Multiple TaskFactory.create(1, {id: N, ...}, false) calls for the same
project were all defaulting to index=1 (from {increment} with count=1),
which collides on the newly added UNIQUE(project_id, index) constraint.
Mirror the numeric id override to index so each row stays unique and
matches the id == index convention used by raw seedTasks helpers.

Fixes the e2e playwright seed failures in subtask-duplicates, list/table
filter/search, kanban filter/search, and overview specs.
This commit is contained in:
kolaente 2026-04-11 17:20:55 +02:00 committed by kolaente
parent 8578fe3468
commit c06a33fb63
1 changed files with 14 additions and 1 deletions

View File

@ -15,7 +15,20 @@ export class TaskFactory extends Factory {
created_by_id: 1,
index: '{increment}',
created: now.toISOString(),
updated: now.toISOString()
updated: now.toISOString(),
}
}
// Mirror numeric `id` overrides onto `index` so sequential single-row
// creates don't collide on UNIQUE(project_id, index). Matches the
// id == index convention used by raw seedTasks helpers.
static async create(count = 1, override: Record<string, unknown> = {}, truncate = true) {
if (
typeof override.id === 'number' &&
!('index' in override)
) {
override = {...override, index: override.id}
}
return super.create(count, override, truncate)
}
}