aboutsummaryrefslogtreecommitdiff
path: root/src/lib/server/services/routines.test.ts
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-09-07 19:17:45 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-09-07 19:17:45 +0200
commit37573109a05a07ac50827759ea63793209baa73a (patch)
tree62c5004bb006eb6ec03830f069b0d26a112e72ab /src/lib/server/services/routines.test.ts
parent1b96084da4ea317b06d92f4d493d102059599009 (diff)
Add routine detail page with editable description and health history
Diffstat (limited to 'src/lib/server/services/routines.test.ts')
-rw-r--r--src/lib/server/services/routines.test.ts36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/lib/server/services/routines.test.ts b/src/lib/server/services/routines.test.ts
index 9e1f429..05abcaf 100644
--- a/src/lib/server/services/routines.test.ts
+++ b/src/lib/server/services/routines.test.ts
@@ -33,7 +33,11 @@ describe('routines service', () => {
it('edit inserts a new snapshot version and keeps history', async () => {
const r = await add(projectId, 'clean kitchen', 7, db);
- const updated = await edit(r.id, 'clean kitchen deeply', 3, db);
+ const updated = await edit(
+ r.id,
+ { name: 'clean kitchen deeply', frequencyDays: 3 },
+ db,
+ );
expect(updated.version).toBe(2);
expect(updated.frequencyDays).toBe(3);
@@ -43,6 +47,34 @@ describe('routines service', () => {
expect(versions[1].frequencyDays).toBe(3);
});
+ it('new routines start with an empty description', async () => {
+ const r = await add(projectId, 'clean kitchen', 7, db);
+ expect(r.description).toBe('');
+ });
+
+ it('edit is partial: name/frequency edits keep the description and vice-versa', async () => {
+ const r = await add(projectId, 'clean kitchen', 7, db);
+ const described = await edit(r.id, { description: 'wax on, wax off' }, db);
+ expect(described.name).toBe('clean kitchen');
+ expect(described.frequencyDays).toBe(7);
+ expect(described.description).toBe('wax on, wax off');
+
+ const renamed = await edit(r.id, { name: 'clean the whole kitchen' }, db);
+ expect(renamed.version).toBe(3);
+ expect(renamed.description).toBe('wax on, wax off');
+ expect(renamed.frequencyDays).toBe(7);
+
+ const refreq = await edit(r.id, { frequencyDays: 14 }, db);
+ expect(refreq.version).toBe(4);
+ expect(refreq.name).toBe('clean the whole kitchen');
+ expect(refreq.description).toBe('wax on, wax off');
+
+ const cleared = await edit(r.id, { description: '' }, db);
+ expect(cleared.version).toBe(5);
+ expect(cleared.description).toBe('');
+ expect(cleared.name).toBe('clean the whole kitchen');
+ });
+
it('archive inserts an archived snapshot without removing history', async () => {
const r = await add(projectId, 'clean kitchen', 7, db);
await archive(r.id, db);
@@ -58,7 +90,7 @@ describe('routines service', () => {
it('complete records the snapshot version it was made against', async () => {
const r = await add(projectId, 'clean kitchen', 7, db);
- await edit(r.id, 'clean kitchen', 5, db);
+ await edit(r.id, { frequencyDays: 5 }, db);
const doneAt = new Date().toISOString();
const completion = await complete(r.id, 'with vinegar', doneAt, db);
expect(completion.routineVersion).toBe(2);