Judge the day readout by the day's kinds, not the window's

A day whose food was all unlabelled read "Fri, Sep 18 — No kind 300 g · 300 g
in total": the number twice, under a label with nothing to distinguish it from.

The guard was on the wrong quantity. It asked whether the *chart* was split,
when what decides this is how many kinds *that day* holds — and a chart split
across other days can still land on a day of one kind. Keying off the day's own
parts fixes the reported case and a second one nobody had hit yet, where a day
of a single named kind read "Dry 300 g · 300 g in total".

So: several kinds keep the total beside them, being what the bar's height shows
and what you would otherwise add up. One kind does not, because it already is
the total. And "No kind" alone drops its label, which was only ever there to
tell it apart from something else.

The new assertions were checked against the old guard, where five of them fail.
The original ones passed throughout, which is the point — they only ever
exercised a chart with one series, and this bug lives on the other axis.
This commit is contained in:
Alexander Heldt
2026-09-22 15:05:02 +00:00
parent 8c9ea45410
commit cd13efdbed
2 changed files with 43 additions and 10 deletions
+27
View File
@@ -315,6 +315,33 @@ suite("what the sentence is allowed to say");
"a day marked not counted says that instead of reading as empty");
}
suite("a day holding only one kind");
{
// The chart is split — other days have several kinds — but this day's food
// is all one. The total is that one figure, so saying it twice is noise.
kinds = [{ id: "d", name: "Dry", colorIndex: 0 }, { id: "f", name: "Fresh", colorIndex: 1 }];
const days = [day(18, { "": 300 }), day(19, { d: 210, f: 90 }), day(20, { d: 300 })];
selected = "2026-09-18";
const unlabelled = read(days).textContent;
eq(unlabelled, "Fri, Sep 18 — 300 g.",
"a day of unlabelled food gives the bare total, on a split chart too");
ok(!/No kind/.test(unlabelled),
"…without the 'No kind' label, which has nothing to distinguish it from");
ok(!/in total/.test(unlabelled), "…and without saying the number twice");
selected = "2026-09-20";
const oneKind = read(days).textContent;
eq(oneKind, "Sun, Sep 20 — Dry 300 g.",
"a day of one named kind keeps the name, which does say something");
ok(!/in total/.test(oneKind), "…but still does not repeat the figure");
selected = "2026-09-19";
ok(/in total/.test(read(days).textContent),
"two kinds on a day still get the total beside them");
}
suite("an unsplit chart gets the day total too");
{
// No kinds defined: there is still no hover on a phone, so the figure was