Watch the pref reach the screen, not just the function
Review pointed out that `dailyGroups` was well covered and the wiring to it was not: passing the wrong pref from App, binding the checkbox to a neighbour, or hardcoding `true` in Dailies each shipped with the suite green. Three of those are now caught by rendering the strip and the settings panel rather than the function behind them — verified by performing the mutations, not by reading the code. The fourth, App handing Dailies the wrong pref, is still uncovered: no test renders App, and closing it needs a feed and a click library this project does not have. Also pins the default. Flipping that one line silently empties Today's dailies for every existing reader, which is the whole argument of the comment above it, and nothing was watching — `defaults` is exported so the value and the upgrade path can both be asserted. And DATA-MODEL's enumeration of the prefs blob had gone stale; AGENTS.md names it as the doc to update when a stored key moves. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
4277c28e50
commit
dd8d7577b3
+52
-1
@@ -8,7 +8,7 @@ import {
|
||||
startMarkers,
|
||||
Timeline,
|
||||
} from "../src/client/components/Timeline.tsx";
|
||||
import { CatchUpPanel, dailyGroups } from "../src/client/components/Dailies.tsx";
|
||||
import { CatchUpPanel, Dailies, dailyGroups } from "../src/client/components/Dailies.tsx";
|
||||
import { Welcome } from "../src/client/components/Welcome.tsx";
|
||||
import { timelineLanes } from "../src/client/state/lanes.ts";
|
||||
import { GameMetaProvider } from "../src/client/state/gameMeta.tsx";
|
||||
@@ -1088,3 +1088,54 @@ describe("dailyGroups with the chores switched off", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("the chores toggle reaches the screen", () => {
|
||||
// `dailyGroups` is pure and well covered, but nothing tied `prefs.showChores`
|
||||
// to what renders. Review proved four plausible breaks shipped green —
|
||||
// including App passing the wrong pref, and Dailies hardcoding `true` — so
|
||||
// these assert the rendered strip rather than the function behind it.
|
||||
const NOW = Date.parse("2026-08-17T12:00:00.000Z");
|
||||
const repeating = {
|
||||
id: "e1",
|
||||
game: "genshin",
|
||||
title: "Lantern Rite login",
|
||||
type: "login",
|
||||
summary: null,
|
||||
startsAt: "2026-08-10T00:00:00.000Z",
|
||||
startPrecision: "day",
|
||||
endsAt: null,
|
||||
endPrecision: "unknown",
|
||||
regionScoped: false,
|
||||
regionEnds: null,
|
||||
sourceUrl: "https://example.test",
|
||||
} as never;
|
||||
|
||||
const strip = (showChores: boolean) =>
|
||||
render(
|
||||
<Dailies
|
||||
games={["genshin"]}
|
||||
events={[repeating]}
|
||||
region="europe"
|
||||
now={NOW}
|
||||
showChores={showChores}
|
||||
daysFor={() => []}
|
||||
onToggleDay={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
test("on, the invented chore is on screen", () => {
|
||||
const html = strip(true);
|
||||
expect(html).toContain("Commissions, resin");
|
||||
expect(html).toContain("Lantern Rite login");
|
||||
});
|
||||
|
||||
test("off, the chore is gone and the event and its count are not", () => {
|
||||
// The count is asserted too: it derives from the items, so a chore hidden
|
||||
// from view but still counted would leave the reader chasing a tick that
|
||||
// is not there.
|
||||
const html = strip(false);
|
||||
expect(html).not.toContain("Commissions, resin");
|
||||
expect(html).toContain("Lantern Rite login");
|
||||
expect(html).toContain("0/1");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user