fix(routines): test the copy, name what Yes agrees to, and true up the docs

Make it mine's copying was inline in App and untested; it is now a pure
function with a test, so a change to either store can't make the copy
silently arrive empty. The question's buttons now say what they answer
when heard out of context. The prefs block and the spec now match what
shipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-13 14:19:16 +02:00
1 parent f7ba86e6e5
commit 1c7df637a4
7 files changed
+65 -10

No files matched your search

+19
View File
@@ -6,6 +6,7 @@ import {
routinesFor,
routineToAsk,
mineFrom,
copyRoutineState,
} from "../src/shared/routines.ts";
import { restorePrefsValue } from "../src/client/state/usePrefs.ts";
import { taskStatus } from "../src/shared/task.ts";
@@ -94,3 +95,21 @@ describe("making a built-in your own", () => {
});
});
});
describe("copying a built-in's record to the reader's copy", () => {
const logs = { "routine:zzz:ridu-weekly": { days: ["2026-10-12"], at: "2026-10-12T10:00:00.000Z" } };
const amounts = { "routine:zzz:ridu-weekly": { "2026-10-12": { value: 900, at: "2026-10-13T10:00:00.000Z" } } };
test("ticks and numbers land under the new id; the original's are not touched", () => {
const copy = copyRoutineState(logs, amounts, "routine:zzz:ridu-weekly", "mytask:abcdef1234");
expect(copy.daily).toEqual({ "mytask:abcdef1234": logs["routine:zzz:ridu-weekly"] });
expect(copy.amounts).toEqual({ "mytask:abcdef1234": amounts["routine:zzz:ridu-weekly"] });
expect(Object.keys(copy.daily)).not.toContain("routine:zzz:ridu-weekly");
});
test("nothing recorded, nothing copied", () => {
expect(copyRoutineState({}, {}, "routine:zzz:ridu-weekly", "mytask:abcdef1234")).toEqual({
daily: {}, amounts: {},
});
});
});