From aa1202fea8cbf6024075cd77779e9c78aa49d448 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 3 Apr 2026 20:56:07 +0200 Subject: [PATCH] chore: remove redundant truncate calls now that all tables are wiped before each test --- .../e2e/filters/filter-autocomplete.spec.ts | 6 ----- .../e2e/project/parent-project-clear.spec.ts | 4 +-- frontend/tests/e2e/project/prepareProjects.ts | 10 ++----- .../tests/e2e/project/project-history.spec.ts | 1 - .../e2e/project/project-view-kanban.spec.ts | 1 - .../e2e/project/project-view-list.spec.ts | 2 -- frontend/tests/e2e/sharing/team.spec.ts | 1 - .../tests/e2e/task/comment-pagination.spec.ts | 1 - .../tests/e2e/task/comment-sort-order.spec.ts | 2 -- frontend/tests/e2e/task/date-display.spec.ts | 2 -- .../tests/e2e/task/drag-to-project.spec.ts | 8 ------ .../tests/e2e/task/mention-in-comment.spec.ts | 1 - frontend/tests/e2e/task/overview.spec.ts | 2 -- .../tests/e2e/task/subtask-duplicates.spec.ts | 7 ----- frontend/tests/e2e/task/task.spec.ts | 26 ------------------- .../tests/e2e/task/tiptap-editor-save.spec.ts | 1 - .../tests/e2e/user/email-confirmation.spec.ts | 3 --- frontend/tests/e2e/user/logout.spec.ts | 1 - .../tests/e2e/user/password-reset.spec.ts | 2 -- frontend/tests/support/filterTestHelpers.ts | 6 ----- 20 files changed, 4 insertions(+), 83 deletions(-) diff --git a/frontend/tests/e2e/filters/filter-autocomplete.spec.ts b/frontend/tests/e2e/filters/filter-autocomplete.spec.ts index 6370a3a13..94af4955c 100644 --- a/frontend/tests/e2e/filters/filter-autocomplete.spec.ts +++ b/frontend/tests/e2e/filters/filter-autocomplete.spec.ts @@ -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) diff --git a/frontend/tests/e2e/project/parent-project-clear.spec.ts b/frontend/tests/e2e/project/parent-project-clear.spec.ts index 4d2539ee5..267369f63 100644 --- a/frontend/tests/e2e/project/parent-project-clear.spec.ts +++ b/frontend/tests/e2e/project/parent-project-clear.spec.ts @@ -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}`) diff --git a/frontend/tests/e2e/project/prepareProjects.ts b/frontend/tests/e2e/project/prepareProjects.ts index e6e874ea6..6341bda5c 100644 --- a/frontend/tests/e2e/project/prepareProjects.ts +++ b/frontend/tests/e2e/project/prepareProjects.ts @@ -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 } diff --git a/frontend/tests/e2e/project/project-history.spec.ts b/frontend/tests/e2e/project/project-history.spec.ts index d051879b8..6d2980d60 100644 --- a/frontend/tests/e2e/project/project-history.spec.ts +++ b/frontend/tests/e2e/project/project-history.spec.ts @@ -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, diff --git a/frontend/tests/e2e/project/project-view-kanban.spec.ts b/frontend/tests/e2e/project/project-view-kanban.spec.ts index 0d1f37941..e8d42214e 100644 --- a/frontend/tests/e2e/project/project-view-kanban.spec.ts +++ b/frontend/tests/e2e/project/project-view-kanban.spec.ts @@ -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, diff --git a/frontend/tests/e2e/project/project-view-list.spec.ts b/frontend/tests/e2e/project/project-view-list.spec.ts index 5767d0a2c..589afb0e5 100644 --- a/frontend/tests/e2e/project/project-view-list.spec.ts +++ b/frontend/tests/e2e/project/project-view-list.spec.ts @@ -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, diff --git a/frontend/tests/e2e/sharing/team.spec.ts b/frontend/tests/e2e/sharing/team.spec.ts index 022e6a977..432f78af2 100644 --- a/frontend/tests/e2e/sharing/team.spec.ts +++ b/frontend/tests/e2e/sharing/team.spec.ts @@ -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' diff --git a/frontend/tests/e2e/task/comment-pagination.spec.ts b/frontend/tests/e2e/task/comment-pagination.spec.ts index 2cf21f1cc..1839aabf9 100644 --- a/frontend/tests/e2e/task/comment-pagination.spec.ts +++ b/frontend/tests/e2e/task/comment-pagination.spec.ts @@ -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}) => { diff --git a/frontend/tests/e2e/task/comment-sort-order.spec.ts b/frontend/tests/e2e/task/comment-sort-order.spec.ts index 29b49abc8..6fb5c30ec 100644 --- a/frontend/tests/e2e/task/comment-sort-order.spec.ts +++ b/frontend/tests/e2e/task/comment-sort-order.spec.ts @@ -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) diff --git a/frontend/tests/e2e/task/date-display.spec.ts b/frontend/tests/e2e/task/date-display.spec.ts index b8f6f5c68..6f79535ef 100644 --- a/frontend/tests/e2e/task/date-display.spec.ts +++ b/frontend/tests/e2e/task/date-display.spec.ts @@ -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, diff --git a/frontend/tests/e2e/task/drag-to-project.spec.ts b/frontend/tests/e2e/task/drag-to-project.spec.ts index 6b52e19ba..53841931d 100644 --- a/frontend/tests/e2e/task/drag-to-project.spec.ts +++ b/frontend/tests/e2e/task/drag-to-project.spec.ts @@ -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', diff --git a/frontend/tests/e2e/task/mention-in-comment.spec.ts b/frontend/tests/e2e/task/mention-in-comment.spec.ts index 21c558e08..3d9cc37ff 100644 --- a/frontend/tests/e2e/task/mention-in-comment.spec.ts +++ b/frontend/tests/e2e/task/mention-in-comment.spec.ts @@ -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}) => { diff --git a/frontend/tests/e2e/task/overview.spec.ts b/frontend/tests/e2e/task/overview.spec.ts index b8a458bd3..a27177f43 100644 --- a/frontend/tests/e2e/task/overview.spec.ts +++ b/frontend/tests/e2e/task/overview.spec.ts @@ -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:') diff --git a/frontend/tests/e2e/task/subtask-duplicates.spec.ts b/frontend/tests/e2e/task/subtask-duplicates.spec.ts index 3166d4d26..536db824b 100644 --- a/frontend/tests/e2e/task/subtask-duplicates.spec.ts +++ b/frontend/tests/e2e/task/subtask-duplicates.spec.ts @@ -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] diff --git a/frontend/tests/e2e/task/task.spec.ts b/frontend/tests/e2e/task/task.spec.ts index b4344722f..80a5ed7c5 100644 --- a/frontend/tests/e2e/task/task.spec.ts +++ b/frontend/tests/e2e/task/task.spec.ts @@ -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: '', diff --git a/frontend/tests/e2e/task/tiptap-editor-save.spec.ts b/frontend/tests/e2e/task/tiptap-editor-save.spec.ts index 919eda8c5..51004dd62 100644 --- a/frontend/tests/e2e/task/tiptap-editor-save.spec.ts +++ b/frontend/tests/e2e/task/tiptap-editor-save.spec.ts @@ -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() }) /** diff --git a/frontend/tests/e2e/user/email-confirmation.spec.ts b/frontend/tests/e2e/user/email-confirmation.spec.ts index 62752c8f9..a19ff4b7f 100644 --- a/frontend/tests/e2e/user/email-confirmation.spec.ts +++ b/frontend/tests/e2e/user/email-confirmation.spec.ts @@ -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', diff --git a/frontend/tests/e2e/user/logout.spec.ts b/frontend/tests/e2e/user/logout.spec.ts index c20c60bb5..1228a3bc1 100644 --- a/frontend/tests/e2e/user/logout.spec.ts +++ b/frontend/tests/e2e/user/logout.spec.ts @@ -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, diff --git a/frontend/tests/e2e/user/password-reset.spec.ts b/frontend/tests/e2e/user/password-reset.spec.ts index 22b835806..60f8a4b73 100644 --- a/frontend/tests/e2e/user/password-reset.spec.ts +++ b/frontend/tests/e2e/user/password-reset.spec.ts @@ -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 }) diff --git a/frontend/tests/support/filterTestHelpers.ts b/frontend/tests/support/filterTestHelpers.ts index 35200a1cf..1ad6d7ce1 100644 --- a/frontend/tests/support/filterTestHelpers.ts +++ b/frontend/tests/support/filterTestHelpers.ts @@ -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,