From 7c30916d28f29e911ca7c3cf4f7bdff77fc1cdf6 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Wed, 4 Mar 2026 13:16:01 +0100 Subject: [PATCH] test: fix 4 failing unit tests after recent sync and dueDay changes - Add TODAY_TAG to FAKE_ROOT_STATE in TaskArchiveService so handleUpdateTask can find it when marking tasks as done - Update dueDay assertion to expect defined value (set to today by updateDoneOnForTask) - Add mock tasks to LWW integration tests so orphan filter doesn't remove taskIds from PROJECT/TAG entities --- .../features/archive/task-archive.service.spec.ts | 2 +- src/app/features/archive/task-archive.service.ts | 5 +++-- .../lww-update-store-application.integration.spec.ts | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/features/archive/task-archive.service.spec.ts b/src/app/features/archive/task-archive.service.spec.ts index 52d2c90cbe..8cb67ac5a8 100644 --- a/src/app/features/archive/task-archive.service.spec.ts +++ b/src/app/features/archive/task-archive.service.spec.ts @@ -272,7 +272,7 @@ describe('TaskArchiveService', () => { expect(updatedTask.isDone).toBe(true); expect(updatedTask.doneOn).toBeGreaterThan(0); - expect(updatedTask.dueDay).toBeUndefined(); + expect(updatedTask.dueDay).toBeDefined(); // Mark as undone archiveDbAdapterMock.loadArchiveYoung.and.returnValue( diff --git a/src/app/features/archive/task-archive.service.ts b/src/app/features/archive/task-archive.service.ts index 25aabc1851..19f69d7349 100644 --- a/src/app/features/archive/task-archive.service.ts +++ b/src/app/features/archive/task-archive.service.ts @@ -13,9 +13,10 @@ import { ArchiveModel } from './archive.model'; import { initialTimeTrackingState } from '../time-tracking/store/time-tracking.reducer'; import { RootState } from '../../root-store/root-state'; import { PROJECT_FEATURE_NAME } from '../project/store/project.reducer'; -import { TAG_FEATURE_NAME } from '../tag/store/tag.reducer'; +import { TAG_FEATURE_NAME, tagAdapter } from '../tag/store/tag.reducer'; import { WORK_CONTEXT_FEATURE_NAME } from '../work-context/store/work-context.selectors'; import { plannerFeatureKey } from '../planner/store/planner.reducer'; +import { TODAY_TAG } from '../tag/tag.const'; // Default empty archive const DEFAULT_ARCHIVE: ArchiveModel = { @@ -28,7 +29,7 @@ const DEFAULT_ARCHIVE: ArchiveModel = { // Other feature states are empty as they're not needed for task updates const FAKE_ROOT_STATE: RootState = { [PROJECT_FEATURE_NAME]: { ids: [], entities: {} }, - [TAG_FEATURE_NAME]: { ids: [], entities: {} }, + [TAG_FEATURE_NAME]: tagAdapter.addOne(TODAY_TAG, tagAdapter.getInitialState()), [WORK_CONTEXT_FEATURE_NAME]: { activeId: 'xyz', activeType: 'TAG', diff --git a/src/app/op-log/testing/integration/lww-update-store-application.integration.spec.ts b/src/app/op-log/testing/integration/lww-update-store-application.integration.spec.ts index 3ab9dbcf89..0fd49c59b8 100644 --- a/src/app/op-log/testing/integration/lww-update-store-application.integration.spec.ts +++ b/src/app/op-log/testing/integration/lww-update-store-application.integration.spec.ts @@ -168,8 +168,13 @@ describe('LWW Update Store Application Integration', () => { Action >; + // Include mock tasks so filterOrphanedTaskIdsFromEntityData doesn't remove them const initialState = createMockRootState( - {}, + { + task1: { id: 'task1', title: 'T1', notes: '', done: false, modified: 1000 }, + task2: { id: 'task2', title: 'T2', notes: '', done: false, modified: 1000 }, + task3: { id: 'task3', title: 'T3', notes: '', done: false, modified: 1000 }, + }, { project1: { id: 'project1', @@ -201,8 +206,11 @@ describe('LWW Update Store Application Integration', () => { Action >; + // Include mock task so filterOrphanedTaskIdsFromEntityData doesn't remove it const initialState = createMockRootState( - {}, + { + task1: { id: 'task1', title: 'T1', notes: '', done: false, modified: 1000 }, + }, {}, { tag1: {