From 616ac8b95fdebd1884b73dc7c0af41a1af1afe9f Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 2 Apr 2026 18:55:52 +0200 Subject: [PATCH] test: add failing tests for subtask visibility in filtered views Add test cases to verify that subtasks are shown in saved filter views regardless of whether their parent task is also in the results. Ref: #2494 --- .../composables/useTaskListFiltering.test.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/frontend/src/composables/useTaskListFiltering.test.ts b/frontend/src/composables/useTaskListFiltering.test.ts index 2a1a9e215..e557a25c4 100644 --- a/frontend/src/composables/useTaskListFiltering.test.ts +++ b/frontend/src/composables/useTaskListFiltering.test.ts @@ -177,4 +177,52 @@ describe('shouldShowTaskInListView', () => { expect(shouldShowTaskInListView(subtask as ITask, allTasks)).toBe(false) }) + + it('should show subtasks in filtered views even when parent is in the same view', () => { + const parentTask: Partial = { + id: 1, + title: 'Parent Task', + projectId: 100, + relatedTasks: {}, + } + + const subtask: Partial = { + id: 2, + title: 'Subtask', + projectId: 100, + relatedTasks: { + parenttask: [{ + id: 1, + title: 'Parent Task', + projectId: 100, + } as ITask], + }, + } + + const allTasks = [parentTask, subtask] as ITask[] + + // In a filtered view, both parent and subtask should be visible + expect(shouldShowTaskInListView(parentTask as ITask, allTasks, true)).toBe(true) + expect(shouldShowTaskInListView(subtask as ITask, allTasks, true)).toBe(true) + }) + + it('should show subtasks in filtered views even when only subtask matches filter', () => { + const subtask: Partial = { + id: 2, + title: 'Subtask matching filter', + projectId: 100, + relatedTasks: { + parenttask: [{ + id: 1, + title: 'Parent Task', + projectId: 100, + } as ITask], + }, + } + + // Only the subtask is in the results (parent didn't match filter) + const allTasks = [subtask] as ITask[] + + expect(shouldShowTaskInListView(subtask as ITask, allTasks, true)).toBe(true) + }) })