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:
Lucas Winther
2026-08-28 05:43:04 +02:00
co-authored by Claude Opus 5
parent 4277c28e50
commit dd8d7577b3
5 changed files with 86 additions and 5 deletions
+18 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { adoptNewLanes, adoptRenamed } from "../src/client/state/usePrefs.ts";
import { adoptNewLanes, adoptRenamed, defaults } from "../src/client/state/usePrefs.ts";
import type { LaneId } from "../src/shared/custom.ts";
/**
@@ -106,3 +106,20 @@ describe("adoptRenamed", () => {
expect(adoptRenamed({})).toEqual({});
});
});
describe("defaults that a reader would notice losing", () => {
test("the chores are on until someone says otherwise", () => {
// Flipping this one line silently empties Today's dailies for every
// existing reader — it is the whole argument of the comment above it, and
// nothing else in the suite was watching it.
expect(defaults().showChores).toBe(true);
});
test("a stored blob without the key keeps the default", () => {
// The upgrade path. Prefs saved before this key existed must not read as
// "off" — `{...defaults(), ...stored}` is what guarantees that, and JSON
// cannot carry an `undefined` that would override it.
const stored = { region: "europe", detectDaily: false } as const;
expect({ ...defaults(), ...stored }.showChores).toBe(true);
});
});