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 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f7ba86e6e5
commit
1c7df637a4
@@ -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: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1507,6 +1507,9 @@ describe("built-in weekly tasks in the strip", () => {
|
||||
expect(html).toContain("Track Zenless Zone Zero");
|
||||
expect(html).toContain("weekly tasks?");
|
||||
expect(html).toContain("No thanks");
|
||||
// Heard out of context, "Yes" has to say what it agrees to.
|
||||
expect(html).toContain(`aria-label="Yes, track Zenless Zone Zero's built-in weekly tasks"`.replace("'", "'"));
|
||||
expect(html).toContain(`aria-label="No thanks to Zenless Zone Zero's built-in weekly tasks"`.replace("'", "'"));
|
||||
});
|
||||
|
||||
test("with nothing to show and nothing to ask, the strip is absent", () => {
|
||||
|
||||
Reference in New Issue
Block a user