From 08269b5d5ccc681f1abe9fc109805fcd9c8490d8 Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Tue, 13 Oct 2026 14:13:18 +0200 Subject: [PATCH] fix(settings): count tasks in the Your own summary A reader whose only own items were tasks was told they had none yet. Co-Authored-By: Claude Opus 5.5 --- src/client/components/Controls.tsx | 12 ++++++++---- test/controls.test.tsx | 11 ++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/client/components/Controls.tsx b/src/client/components/Controls.tsx index 4d8a530..a4ea92d 100644 --- a/src/client/components/Controls.tsx +++ b/src/client/components/Controls.tsx @@ -290,7 +290,7 @@ export function Controls({ - + @@ -387,11 +387,15 @@ function visibilityState( return also.length === 0 ? "live deadlines only" : `plus ${also.join(", ")}`; } -function ownState(games: number, events: number): string { - if (games === 0 && events === 0) return "none yet"; +/** The Your own group's summary line. Exported so its counting is tested directly. */ +export function ownState(games: number, events: number, tasks = 0): string { + if (games === 0 && events === 0 && tasks === 0) return "none yet"; const plural = (n: number, word: string) => `${n} ${word}${n === 1 ? "" : "s"}`; - return `${plural(games, "game")} · ${plural(events, "event")}`; + const parts = + games === 0 && events === 0 ? [] : [plural(games, "game"), plural(events, "event")]; + if (tasks > 0) parts.push(plural(tasks, "task")); + return parts.join(" · "); } /** diff --git a/test/controls.test.tsx b/test/controls.test.tsx index 38d4070..a7e5b61 100644 --- a/test/controls.test.tsx +++ b/test/controls.test.tsx @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; import { renderToStaticMarkup } from "react-dom/server"; -import { Controls } from "../src/client/components/Controls.tsx"; +import { Controls, ownState } from "../src/client/components/Controls.tsx"; import { GameMetaProvider } from "../src/client/state/gameMeta.tsx"; import { metaFor } from "../src/shared/games.ts"; import type { Prefs } from "../src/client/state/usePrefs.ts"; @@ -316,3 +316,12 @@ describe("Controls: built-in weekly tasks", () => { expect(render(PREFS)).not.toContain("Built-in weekly tasks"); }); }); + +describe("Controls: the Your own summary counts tasks", () => { + test("a reader with only tasks is not told they have none", () => { + expect(ownState(0, 0, 1)).toBe("1 task"); + expect(ownState(1, 2, 0)).toBe("1 game · 2 events"); + expect(ownState(1, 0, 2)).toBe("1 game · 0 events · 2 tasks"); + expect(ownState(0, 0, 0)).toBe("none yet"); + }); +});