diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-07 22:31:23 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-07 22:31:23 +0200 |
| commit | 992e40835af1600a0961ec2454fb78ff43aec3c6 (patch) | |
| tree | 3c0602ae64a186ce5ac51be6b0795037488f552a /src/lib/server/services/routines.test.ts | |
| parent | e4a158965f3fcfe6fac65a1eba7b456d615e7dca (diff) | |
Add routine archives: archive date, searchable archived list, frozen page
- Stamp archived_at on the archived snapshot; copy it on edit
- loadArchived(projectId) + collapsible fuzzy-searched "Archivées" section on the project page
- Archived routine pages open read-only with the health chart ending at the archive date; edit/complete actions reject archived routines
Diffstat (limited to 'src/lib/server/services/routines.test.ts')
| -rw-r--r-- | src/lib/server/services/routines.test.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib/server/services/routines.test.ts b/src/lib/server/services/routines.test.ts index 05abcaf..e8c4f35 100644 --- a/src/lib/server/services/routines.test.ts +++ b/src/lib/server/services/routines.test.ts @@ -7,6 +7,7 @@ import { archive, complete, loadAllVersions, + loadArchived, loadProjectDashboard, loadOverview, } from './routines'; @@ -88,6 +89,38 @@ describe('routines service', () => { expect(dashboard.healthScore).toBe(100); }); + it('loadArchived lists archived routines; edits keep the archive date', async () => { + const a = await add(projectId, 'clean kitchen', 7, db); + await add(projectId, 'water plants', 3, db); + await archive(a.id, db); + const stamped = (await loadAllVersions(a.id, db))[1].archivedAt; + expect(stamped).toBeTruthy(); + + const edited = await edit(a.id, { name: 'clean kitchen deeply' }, db); + expect(edited.archived).toBe(true); + expect(edited.archivedAt).toBe(stamped); + + const archived = await loadArchived(projectId, db); + expect(archived.map((r) => r.id)).toEqual([a.id]); + expect(archived[0].name).toBe('clean kitchen deeply'); + expect(archived[0].frequencyDays).toBe(7); + expect(archived[0].archivedAt).toBe(stamped); + }); + + it('loadArchived sorts most recently archived first', async () => { + const a = await add(projectId, 'first', 1, db); + const b = await add(projectId, 'second', 1, db); + await archive(a.id, db); + await archive(b.id, db); + + const archived = await loadArchived(projectId, db); + expect(archived).toHaveLength(2); + // Descending archive date; equal timestamps keep insertion order. + expect(new Date(archived[0].archivedAt).getTime()).toBeGreaterThanOrEqual( + new Date(archived[1].archivedAt).getTime(), + ); + }); + it('complete records the snapshot version it was made against', async () => { const r = await add(projectId, 'clean kitchen', 7, db); await edit(r.id, { frequencyDays: 5 }, db); |
