fix(test): prune leftover task duplicates

This commit is contained in:
kolaente 2025-09-30 16:49:32 +02:00
parent e63b349b5f
commit 46b4f65da0
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
2 changed files with 24 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import {createFakeUserAndLogin} from '../../support/authenticateUser'
import {ProjectFactory} from '../../factories/project'
import {TaskFactory} from '../../factories/task'
import {ProjectViewFactory} from '../../factories/project_view'
import {TaskRelationFactory} from '../../factories/task_relation'
function createViews(projectId: number, projectViewId: number) {
return ProjectViewFactory.create(1, {
@ -20,10 +21,11 @@ describe('Subtask duplicate handling', () => {
let parentB
let subtask
beforeEach(() => {
ProjectFactory.truncate()
ProjectViewFactory.truncate()
TaskFactory.truncate()
beforeEach(() => {
ProjectFactory.truncate()
ProjectViewFactory.truncate()
TaskFactory.truncate()
TaskRelationFactory.truncate()
projectA = ProjectFactory.create(1, {id: 1, title: 'Project A'})[0]
createViews(projectA.id, 1)

View File

@ -0,0 +1,18 @@
import {Factory} from '../support/factory'
export class TaskRelationFactory extends Factory {
static table = 'task_relations'
static factory() {
const now = new Date()
return {
id: '{increment}',
task_id: '{increment}',
other_task_id: '{increment}',
relation_kind: 'related',
created_by_id: 1,
created: now.toISOString(),
}
}
}