chore: remove redundant truncate calls now that all tables are wiped before each test

This commit is contained in:
kolaente 2026-04-03 20:56:07 +02:00 committed by kolaente
parent 2ee8ad4109
commit aa1202fea8
20 changed files with 4 additions and 83 deletions

View File

@ -2,7 +2,6 @@ import {test, expect} from '../../support/fixtures'
import {ProjectFactory} from '../../factories/project'
import {TaskFactory} from '../../factories/task'
import {ProjectViewFactory} from '../../factories/project_view'
import {SavedFilterFactory} from '../../factories/saved_filter'
/**
* Tests for filter autocomplete functionality, specifically for:
@ -31,11 +30,6 @@ function getFilterInput(page) {
test.describe('Filter Autocomplete', () => {
test.beforeEach(async ({authenticatedPage, currentUser}) => {
// authenticatedPage fixture triggers apiContext which sets up Factory.request
await ProjectFactory.truncate()
await TaskFactory.truncate()
await ProjectViewFactory.truncate()
await SavedFilterFactory.truncate()
const userId = currentUser.id
// Create projects - one with spaces in name (the bug case)

View File

@ -17,7 +17,7 @@ test.describe('Parent Project Clear', () => {
title: 'Child Project',
parent_project_id: parentProjects[0].id,
}, false)
const childViews = await createDefaultViews(childProjects[0].id, 104, false)
const childViews = await createDefaultViews(childProjects[0].id, 104)
// Navigate to the child project first
await page.goto(`/projects/${childProjects[0].id}/${childViews[0].id}`)
@ -75,7 +75,7 @@ test.describe('Parent Project Clear', () => {
title: 'Test Child',
parent_project_id: parentProjects[0].id,
}, false)
const childViews = await createDefaultViews(childProjects[0].id, 204, false)
const childViews = await createDefaultViews(childProjects[0].id, 204)
// Navigate to the child project first
await page.goto(`/projects/${childProjects[0].id}/${childViews[0].id}`)

View File

@ -2,10 +2,7 @@ import {ProjectFactory} from '../../factories/project'
import {TaskFactory} from '../../factories/task'
import {ProjectViewFactory} from '../../factories/project_view'
export async function createDefaultViews(projectId: number, startViewId = 1, truncate: boolean = true) {
if (truncate) {
await ProjectViewFactory.truncate()
}
export async function createDefaultViews(projectId: number, startViewId = 1) {
const list = await ProjectViewFactory.create(1, {
id: startViewId,
project_id: projectId,
@ -41,11 +38,8 @@ export async function createProjects(count: number = 1) {
title: i => count === 1 ? 'First Project' : `Project ${i + 1}`,
})
await TaskFactory.truncate()
await ProjectViewFactory.truncate()
for (let i = 0; i < projects.length; i++) {
const views = await createDefaultViews(projects[i].id, i * 4 + 1, false)
const views = await createDefaultViews(projects[i].id, i * 4 + 1)
projects[i].views = views
}

View File

@ -6,7 +6,6 @@ test.describe('Project History', () => {
test('should show a project history on the home page', async ({authenticatedPage: page}) => {
test.setTimeout(60000)
const projects = await ProjectFactory.create(7)
await ProjectViewFactory.truncate()
for (const p of projects) {
await ProjectViewFactory.create(1, {
id: p.id,

View File

@ -38,7 +38,6 @@ async function createTaskWithBuckets(buckets, count = 1) {
const data = await TaskFactory.create(count, {
project_id: 1,
})
await TaskBucketFactory.truncate()
for (const t of data) {
await TaskBucketFactory.create(1, {
task_id: t.id,

View File

@ -109,7 +109,6 @@ test.describe('Project View List', () => {
}, false)
// Make task 2 a subtask of task 1
await TaskRelationFactory.truncate()
await TaskRelationFactory.create(1, {
id: 1,
task_id: 2,
@ -143,7 +142,6 @@ test.describe('Project View List', () => {
}, false)
// Make task 2 a subtask of task 1
await TaskRelationFactory.truncate()
await TaskRelationFactory.create(1, {
id: 1,
task_id: 2,

View File

@ -5,7 +5,6 @@ import {UserFactory} from '../../factories/user'
test.describe('Team', () => {
test('Creates a new team', async ({authenticatedPage: page}) => {
await TeamFactory.truncate()
await page.goto('/teams')
const newTeamName = 'New Team'

View File

@ -9,7 +9,6 @@ test.describe('Task comment pagination', () => {
await ProjectFactory.create(1)
await createDefaultViews(1)
await TaskFactory.create(1, {id: 1})
await TaskCommentFactory.truncate()
})
test('shows pagination when more comments than configured page size', async ({authenticatedPage: page, apiContext}) => {

View File

@ -39,7 +39,6 @@ test.describe('Comment sort order', () => {
await ProjectFactory.create(1)
await createDefaultViews(1)
await TaskFactory.create(1, {id: 1})
await TaskCommentFactory.truncate()
})
test('defaults to oldest first', async ({authenticatedPage: page}) => {
@ -199,7 +198,6 @@ test.describe('Comment sort order', () => {
frontend_settings: JSON.stringify({commentSortOrder: 'desc'}),
}))[0]
const project = (await ProjectFactory.create(1, {owner_id: user.id}))[0]
await TaskFactory.truncate()
await TaskFactory.create(1, {id: 1, project_id: project.id, created_by_id: user.id})
await createCommentsWithTimestamps(3)

View File

@ -74,7 +74,6 @@ test.describe('Date display setting', () => {
frontend_settings: JSON.stringify({dateDisplay: format, timeFormat: TIME_FORMAT.HOURS_12}),
}))[0]
const project = (await ProjectFactory.create(1, {owner_id: user.id}))[0]
await TaskFactory.truncate()
const task = (await TaskFactory.create(1, {
id: 1,
project_id: project.id,
@ -96,7 +95,6 @@ test.describe('Date display setting', () => {
frontend_settings: JSON.stringify({dateDisplay: format, timeFormat: TIME_FORMAT.HOURS_24}),
}))[0]
const project = (await ProjectFactory.create(1, {owner_id: user.id}))[0]
await TaskFactory.truncate()
const task = (await TaskFactory.create(1, {
id: 1,
project_id: project.id,

View File

@ -15,8 +15,6 @@ async function createProjectsWithTasks() {
})
// Create views for both projects
await ProjectViewFactory.truncate()
// List view for source project
const sourceListView = await ProjectViewFactory.create(1, {
id: 1,
@ -45,7 +43,6 @@ async function createProjectsWithTasks() {
})
// Create tasks in source project
await TaskFactory.truncate()
const tasks = await TaskFactory.create(3, {
id: '{increment}',
title: i => `Task ${i + 1}`,
@ -53,7 +50,6 @@ async function createProjectsWithTasks() {
})
// Assign tasks to bucket for kanban view
await TaskBucketFactory.truncate()
for (const task of tasks) {
await TaskBucketFactory.create(1, {
task_id: task.id,
@ -180,7 +176,6 @@ test.describe('Drag Task to Project in Sidebar', () => {
title: 'Source Project',
})
await ProjectViewFactory.truncate()
const sourceListView = await ProjectViewFactory.create(1, {
id: 1,
project_id: projects[0].id,
@ -194,7 +189,6 @@ test.describe('Drag Task to Project in Sidebar', () => {
owner_id: 1,
})
await TaskFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
title: 'Test Task',
@ -249,7 +243,6 @@ test.describe('Drag Task to Project in Sidebar', () => {
permission: 0,
})
await ProjectViewFactory.truncate()
const sourceListView = await ProjectViewFactory.create(1, {
id: 1,
project_id: sourceProject[0].id,
@ -263,7 +256,6 @@ test.describe('Drag Task to Project in Sidebar', () => {
view_kind: 0,
}, false)
await TaskFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
title: 'Test Task',

View File

@ -9,7 +9,6 @@ test.describe('Mention in task comment', () => {
await ProjectFactory.create(1)
await createDefaultViews(1)
await TaskFactory.create(1, {id: 1})
await TaskCommentFactory.truncate()
})
test('typing @ in comment editor does not throw TypeError', async ({authenticatedPage: page}) => {

View File

@ -157,8 +157,6 @@ test.describe('Home Page Task Overview', () => {
})
test('Should show the cta buttons for new project when there are no tasks', async ({authenticatedPage: page}) => {
await TaskFactory.truncate()
await page.goto('/')
await expect(page.locator('.home.app-content .content')).toContainText('Import your projects and tasks from other services into Vikunja:')

View File

@ -20,13 +20,6 @@ test.describe('Subtask duplicate handling', () => {
let subtask
test.beforeEach(async ({authenticatedPage: page, apiContext}) => {
await Promise.all([
ProjectFactory.truncate(),
ProjectViewFactory.truncate(),
TaskFactory.truncate(),
TaskRelationFactory.truncate(),
])
projectA = (await ProjectFactory.create(1, {id: 1, title: 'Project A'}))[0]
await createViews(projectA.id, 1)
projectB = (await ProjectFactory.create(1, {id: 2, title: 'Project B'}, false))[0]

View File

@ -95,8 +95,6 @@ test.describe('Task', () => {
buckets = await BucketFactory.create(1, {
project_view_id: views[3].id,
}) as Bucket[]
await TaskFactory.truncate()
await UserProjectFactory.truncate()
})
test('Should be created new', async ({authenticatedPage: page}) => {
@ -190,12 +188,6 @@ test.describe('Task', () => {
})
test.describe('Task Detail View', () => {
test.beforeEach(async ({authenticatedPage: page}) => {
await TaskCommentFactory.truncate()
await LabelTaskFactory.truncate()
await TaskAttachmentFactory.truncate()
})
test('provides back navigation to the project in the list view', async ({authenticatedPage: page}) => {
const tasks = await TaskFactory.create(1)
const loadTasksPromise = page.waitForResponse(response =>
@ -471,8 +463,6 @@ test.describe('Task', () => {
})
test('Can add an assignee to a task', async ({authenticatedPage: page}) => {
await TaskAssigneeFactory.truncate()
// Create users with IDs starting at 100 to avoid conflict with logged-in user (ID 1)
// Don't truncate to preserve the authenticated user from the fixture
const users = await UserFactory.create(5, {
@ -538,7 +528,6 @@ test.describe('Task', () => {
id: 1,
project_id: 1,
})
await LabelFactory.truncate()
const newLabelText = 'some new label'
await page.goto(`/tasks/${tasks[0].id}`)
@ -559,7 +548,6 @@ test.describe('Task', () => {
project_id: 1,
})
const labels = await LabelFactory.create(1)
await LabelTaskFactory.truncate()
await page.goto(`/tasks/${tasks[0].id}`)
@ -572,7 +560,6 @@ test.describe('Task', () => {
project_id: projects[0].id,
})
const labels = await LabelFactory.create(1)
await LabelTaskFactory.truncate()
await TaskBucketFactory.create(1, {
task_id: tasks[0].id,
bucket_id: buckets[0].id,
@ -722,7 +709,6 @@ test.describe('Task', () => {
})
test('Can paste an image into the description editor which uploads it as an attachment', async ({authenticatedPage: page}) => {
await TaskAttachmentFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
}) as Task[]
@ -745,7 +731,6 @@ test.describe('Task', () => {
})
test('Can set a reminder', async ({authenticatedPage: page}) => {
await TaskReminderFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
done: false,
@ -764,7 +749,6 @@ test.describe('Task', () => {
})
test('Allows to set a relative reminder when the task already has a due date', async ({authenticatedPage: page}) => {
await TaskReminderFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
done: false,
@ -785,7 +769,6 @@ test.describe('Task', () => {
})
test('Allows to set a relative reminder when the task already has a start date', async ({authenticatedPage: page}) => {
await TaskReminderFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
done: false,
@ -806,7 +789,6 @@ test.describe('Task', () => {
})
test('Allows to set a custom relative reminder when the task already has a due date', async ({authenticatedPage: page}) => {
await TaskReminderFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
done: false,
@ -831,7 +813,6 @@ test.describe('Task', () => {
})
test('Allows to set a fixed reminder when the task already has a due date', async ({authenticatedPage: page}) => {
await TaskReminderFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
done: false,
@ -856,7 +837,6 @@ test.describe('Task', () => {
})
test('Does not auto-save when clicking a date in the absolute reminder picker', async ({authenticatedPage: page}) => {
await TaskReminderFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
done: false,
@ -900,7 +880,6 @@ test.describe('Task', () => {
})
test('Shows Confirm button for absolute date reminder when task has no due date', async ({authenticatedPage: page}) => {
await TaskReminderFactory.truncate()
// Task with no due_date — defaultRelativeTo will be null
const tasks = await TaskFactory.create(1, {
id: 1,
@ -949,7 +928,6 @@ test.describe('Task', () => {
})
test('Can add an attachment to a task', async ({authenticatedPage: page}) => {
await TaskAttachmentFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
})
@ -959,13 +937,11 @@ test.describe('Task', () => {
})
test('Can add an attachment to a task and see it appearing on kanban', async ({authenticatedPage: page}) => {
await TaskAttachmentFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
project_id: projects[0].id,
})
const labels = await LabelFactory.create(1)
await LabelTaskFactory.truncate()
await TaskBucketFactory.create(1, {
task_id: tasks[0].id,
bucket_id: buckets[0].id,
@ -1121,8 +1097,6 @@ test.describe('Task', () => {
})
test('Should render an image from attachment', async ({authenticatedPage: page, apiContext}) => {
await TaskAttachmentFactory.truncate()
const tasks = await TaskFactory.create(1, {
id: 1,
description: '',

View File

@ -5,7 +5,6 @@ import {ProjectFactory} from '../../factories/project'
test.describe('TipTap Editor Save', () => {
test.beforeEach(async ({authenticatedPage: page}) => {
await ProjectFactory.create(1)
await TaskFactory.truncate()
})
/**

View File

@ -8,9 +8,6 @@ test.describe('Email Confirmation', () => {
let confirmationToken
test.beforeEach(async ({page, apiContext}) => {
await UserFactory.truncate()
await TokenFactory.truncate()
// Create a user with status = 1 (StatusEmailConfirmationRequired)
const users = await UserFactory.create(1, {
username: 'unconfirmeduser',

View File

@ -31,7 +31,6 @@ test.describe('Log out', () => {
test('Should clear the project history after logging the user out', async ({authenticatedPage: page}) => {
const projects = await ProjectFactory.create(1)
await ProjectViewFactory.truncate()
await ProjectViewFactory.create(1, {
id: projects[0].id,
project_id: projects[0].id,

View File

@ -6,8 +6,6 @@ test.describe('Password Reset', () => {
let user: UserAttributes
test.beforeEach(async ({page, apiContext}) => {
await UserFactory.truncate()
await TokenFactory.truncate()
const users = await UserFactory.create(1)
user = users[0] as UserAttributes
})

View File

@ -2,8 +2,6 @@ import {TaskFactory} from '../factories/task'
import {TaskBucketFactory} from '../factories/task_buckets'
export async function createTasksWithPriorities(buckets?: any[]) {
await TaskFactory.truncate()
const highPriorityTask1 = (await TaskFactory.create(1, {
id: 1,
project_id: 1,
@ -34,7 +32,6 @@ export async function createTasksWithPriorities(buckets?: any[]) {
// If buckets are provided (for Kanban), add tasks to buckets
if (buckets && buckets.length > 0) {
await TaskBucketFactory.truncate()
await TaskBucketFactory.create(1, {
task_id: highPriorityTask1.id,
bucket_id: buckets[0].id,
@ -64,8 +61,6 @@ export async function createTasksWithPriorities(buckets?: any[]) {
}
export async function createTasksWithSearch(buckets?: any[]) {
await TaskFactory.truncate()
const task1 = (await TaskFactory.create(1, {
id: 1,
project_id: 1,
@ -92,7 +87,6 @@ export async function createTasksWithSearch(buckets?: any[]) {
// If buckets are provided (for Kanban), add tasks to buckets
if (buckets && buckets.length > 0) {
await TaskBucketFactory.truncate()
await TaskBucketFactory.create(1, {
task_id: task1.id,
bucket_id: buckets[0].id,