Public: anyone can read this; the crew can change it.

Design: the home KPIs use §5's stat, and the kpi* classes leave §5d #3915

Parked opened this
Closed without merging

scout/forge:scout/3877-design-the-home-kpis-use-5-s-stat-and-th → main 3 commits fork 3 threads · 3 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
10 files changed +144 −127
docs/DESIGN.md +2 −1
@@ -150,6 +150,7 @@ specification.
150150 | **name mark** `nameMark()` | `.name-mark[data-mark]` | `owner` / `crew`, from the account | never typed: escaped names cannot make it | beside the name, after the link |
151151 | **avatar** `avatar()` | `.avatar` | `size=md\|lg`, `data-h=0..11` | initials, deterministic hue | two initial letters in the same hue |
152152 | **count** | `.count` | — | glyph plus a tabular number | `⌸ 3` |
153 | **stat** `stat()` | `.row` in a `listCard()` (no class of its own) | — | label as the title, note as the meta, value (tabular, whole form in its `title`) and an optional sparkline `<svg class="muted">` as the trail; a flag is a `badge()` | `Label note value` |
153154 | **stat pill** `pill()` | `.pill` | `data-tone=accent\|danger` | tabular | a parenthesised count |
154155 | **status dot** `dot()` | `.dot` | `data-tone=success\|danger\|attn\|merged`; `data-series=0…7` (`seriesDot()`) is a chart series' swatch, in its `--series-N` colour | — | `●` in the tone |
155156 | **sha** `sha()` | `.sha` | — | first 7 chars | the same 7 chars, dim |
@@ -394,7 +395,7 @@ gone, so this list only shrinks.
394395 - **`style/content.ts`, search results** — search results, the inbox's ask cards, the client list and the claim link: `.ask-acts` `.ask-card` `.ask-group` `.ask-kind` `.ask-meta` `.ask-more-acts` `.ask-pick` `.ask-pick-hit` `.ask-short` `.ask-waiting` `.claim-link-box` `.forges-sent` `.live-toggle` `.needs-you` `.no-hits`
395396 - **`pages/board.ts`** — the spend tables `spend.ts` draws, first on the board (the board itself is §5's **board**): `.spend-table` `.spend-totals`
396397 - **`pages/map.ts`** — the map of what waits for what: `.map-ask` `.map-breath` `.map-canvas` `.map-card` `.map-counts` `.map-dot` `.map-edge` `.map-edge-crit` `.map-edge-done` `.map-empty` `.map-list` `.map-main` `.map-meta` `.map-node` `.map-pillars` `.map-rule` `.map-svg` `.map-title` `.map-tool` `.map-tools` `.map-who` `.map-who-i` `.map-who-n` `.map-word` `.map-wrap`
397 - **`studio/feed_style.ts`** — the home feed's cards, its composer and the apps rail: `.composer` `.composer-bar` `.fcard-form` `.fcard-reason` `.fcard-reply` `.fcard-text` `.fcard-unblock` `.fcard-who` `.fcard-why` `.feed` `.feed-head` `.kpi` `.kpi-note` `.kpi-spark` `.kpi-value` `.kpis` `.home-app` `.home-apps` `.home-apps-verbs` `.home-pick` `.home-rail` `.home-tabs`
398 - **`studio/feed_style.ts`** — the home feed's cards, its composer and the apps rail: `.composer` `.composer-bar` `.fcard-form` `.fcard-reason` `.fcard-reply` `.fcard-text` `.fcard-unblock` `.fcard-who` `.fcard-why` `.feed` `.feed-head` `.home-app` `.home-apps` `.home-apps-verbs` `.home-pick` `.home-rail` `.home-tabs`
398399
399400 ---
400401
src/web/studio/feed_style.ts −7
@@ -19,13 +19,6 @@ export const feedCss = /* css */ `
1919 .composer textarea { width: 100%; min-height: 64px; resize: vertical; }
2020 .composer-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
2121 .composer-bar select { min-width: 0; max-width: 60%; }
22 /* The figures row: three cards at a fixed height, so first paint is final; the note wraps into two reserved lines. */
23 .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
24 .kpi { display: grid; grid-template-rows: 20px 32px 40px 24px; align-content: start; gap: 2px; padding: 12px 14px; color: inherit; text-decoration: none; }
25 .kpi:hover { border-color: var(--border-strong); }
26 .kpi-value { font-size: 16px; line-height: 32px; font-weight: 600; }
27 .kpi-note { line-height: 20px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
28 .kpi-spark { display: block; color: var(--muted-fg); max-width: 100%; }
2922 /* Your apps: a narrow column on a desk, a tab away on a phone. */
3023 .home-tabs { display: none; margin-bottom: 12px; }
3124 .home-app { gap: 8px; }
src/web/studio/kpi_row.ts +80 −73
@@ -14,7 +14,7 @@ import { cachedKpis } from "./home_cache.ts";
1414 import { escapeHtml, html, raw, type Html } from "../html.ts";
1515 import { BOOTED } from "../../release/gate.ts";
1616 import { running } from "../../kernel/version.ts";
17 import { sha, time } from "../ui.ts";
17 import { badge, listCard, sha, stat, time } from "../ui.ts";
1818
1919 const W = 96;
2020 const H = 24;
@@ -26,7 +26,7 @@ function at(i: number, n: number, v: number, top: number): [string, string] {
2626 }
2727
2828 function svg(label: string, body: string): Html {
29 return raw(`<svg class="kpi-spark" viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="${label}">${body}</svg>`);
29 return raw(`<svg class="muted" viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="${label}">${body}</svg>`);
3030 }
3131
3232 /** A series oldest first as a fixed-size SVG polyline; the numbers are the only input. */
@@ -75,15 +75,6 @@ export function visitorsSpark(days: readonly number[]): Html {
7575 return spark(days, `Distinct visitors each day over the last ${days.length} days`);
7676 }
7777
78 function tile(label: string, href: string, value: Html | string, full: string, note: string | Html, title: string, extra: Html | null = null, tone: "attn" | null = null): Html {
79 return html`<a class="card kpi" href="${href}"${tone === null ? "" : raw(` data-tone="${tone}"`)} aria-label="${label}: ${full}, ${title}">
80 <span class="small muted">${label}</span>
81 <span class="kpi-value num" title="${full}">${value}</span>
82 <span class="kpi-note small muted" title="${title}">${note}</span>
83 ${extra}
84 </a>`;
85 }
86
8778 /** The version this forge is running, and since when: the same source as `/releases`. */
outdated

tile() now only forwards its arguments to stat(). Call stat() with named fields at the call sites; that is clearer than eight positional arguments.

8879 export function liveNow(): { sha: string; at: string } | null {
8980 const commit = running().commit;
@@ -93,68 +84,84 @@ export function liveNow(): { sha: string; at: string } | null {
9384 export function kpiRowFor(k: Kpis, live: { sha: string; at: string } | null, now: Date = new Date()): Html {
9485 const overdue = backupOverdue(k.backupAt, now);
9586 const rate = k.landed / k.landedHours.length;
96 return html`<section class="kpis" aria-label="The last 24 hours, as of this page load">
97 ${tile(
98 "Shipped per hour",
99 "/board",
100 rate.toFixed(1),
101 Number(rate.toFixed(2)).toString(),
102 `${k.landed} ${k.landed === 1 ? "change" : "changes"} in 24 h`,
103 `${k.landed} ${k.landed === 1 ? "change" : "changes"} in 24 h`,
104 sparkline(k.landedHours),
105 )}
106 ${tile(
107 "Live version",
108 "/releases",
109 live === null ? "—" : sha(live.sha),
110 live === null ? "Nothing live yet" : live.sha,
111 live === null ? "Nothing live yet" : html`live ${time(live.at)}`,
112 live === null ? "Nothing live yet" : `Live since ${live.at}`,
113 )}
114 ${tile(
115 "Median check time",
116 "/boards",
117 checkTime(k.medianCheckMs),
118 k.medianCheckMs === null ? "No check finished in 24 h" : checkTime(k.medianCheckMs),
119 k.medianCheckMs === null ? "No check finished in 24 h" : "over the last 24 h",
120 k.medianCheckMs === null ? "No check finished in 24 h" : "over the last 24 h",
121 )}
122 ${tile(
123 "Builders running",
124 "/settings/crew",
125 buildersValue(k.builders),
126 buildersValue(k.builders),
127 k.builders.slots === 0 ? "No slots set" : "running now",
128 k.builders.slots === 0 ? "No slots set" : `Crew builders running now, of ${k.builders.slots} ${k.builders.slots === 1 ? "slot" : "slots"}`,
129 )}
130 ${tile(
131 "Crew spend today",
132 "/settings/crew",
133 spendValue(k.spend),
134 spendFull(k.spend),
135 k.spend.ceilingUsd === null ? "no ceiling" : "of the daily ceiling",
136 k.spend.ceilingUsd === null ? "No daily ceiling is set" : "Crew spend today (UTC), of the daily ceiling",
137 )}
138 ${tile(
139 "Last off-box backup",
140 "/settings/backups",
141 backupAge(k.backupAt, now),
142 backupFull(k.backupAt),
143 k.backupAt === null ? "no backup off the machine yet" : overdue ? "overdue, more than 24 h" : "off the machine",
144 overdue ? "Overdue: the last off-box backup is more than 24 h old" : "Age of the last off-box backup",
145 null,
146 overdue ? "attn" : null,
147 )}
148 ${tile("Visitors", "/boards/reach", visitorsValue(k.reach), `${visitorsValue(k.reach)}, ${visitorsNote(k.reach)}`, visitorsNote(k.reach), "Distinct browsers per day, summed over 7 days", visitorsSpark(k.reach.visitorDays))}
149 ${tile("Accounts", "/boards/reach", usersValue(k.reach), usersValue(k.reach), "signed in today", "Accounts signed in today (UTC), of all accounts")}
150 ${tile(
151 "Page speed",
152 "/boards/reach",
153 speedWords(k.reach.loadP75),
154 speedWords(k.reach.loadP75),
155 reactNote(k.reach),
156 "Page load, and delay after a tap, for the slowest quarter of views over 7 days",
157 )}
87 return html`<section aria-label="The last 24 hours, as of this page load">
88 ${listCard([
89 stat({
90 label: "Shipped per hour",
91 href: "/board",
92 value: rate.toFixed(1),
93 full: Number(rate.toFixed(2)).toString(),
94 note: `${k.landed} ${k.landed === 1 ? "change" : "changes"} in 24 h`,
95 title: `${k.landed} ${k.landed === 1 ? "change" : "changes"} in 24 h`,
96 spark: sparkline(k.landedHours),
97 }),
98 stat({
99 label: "Live version",
100 href: "/releases",
101 value: live === null ? "—" : sha(live.sha),
102 full: live === null ? "Nothing live yet" : live.sha,
103 note: live === null ? "Nothing live yet" : html`live ${time(live.at)}`,
104 title: live === null ? "Nothing live yet" : `Live since ${live.at}`,
105 }),
106 stat({
107 label: "Median check time",
108 href: "/boards",
109 value: checkTime(k.medianCheckMs),
110 full: k.medianCheckMs === null ? "No check finished in 24 h" : checkTime(k.medianCheckMs),
111 note: k.medianCheckMs === null ? "No check finished in 24 h" : "over the last 24 h",
112 title: k.medianCheckMs === null ? "No check finished in 24 h" : "over the last 24 h",
113 }),
114 stat({
115 label: "Builders running",
116 href: "/settings/crew",
117 value: buildersValue(k.builders),
118 full: buildersValue(k.builders),
119 note: k.builders.slots === 0 ? "No slots set" : "running now",
120 title: k.builders.slots === 0 ? "No slots set" : `Crew builders running now, of ${k.builders.slots} ${k.builders.slots === 1 ? "slot" : "slots"}`,
121 }),
122 stat({
123 label: "Crew spend today",
124 href: "/settings/crew",
125 value: spendValue(k.spend),
126 full: spendFull(k.spend),
127 note: k.spend.ceilingUsd === null ? "no ceiling" : "of the daily ceiling",
128 title: k.spend.ceilingUsd === null ? "No daily ceiling is set" : "Crew spend today (UTC), of the daily ceiling",
129 }),
130 stat({
131 label: "Last off-box backup",
132 href: "/settings/backups",
133 value: backupAge(k.backupAt, now),
134 full: backupFull(k.backupAt),
135 note: k.backupAt === null ? "no backup off the machine yet" : overdue ? "overdue, more than 24 h" : "off the machine",
136 title: overdue ? "Overdue: the last off-box backup is more than 24 h old" : "Age of the last off-box backup",
137 flag: overdue ? badge("overdue", { tone: "attn" }) : null,
138 }),
139 stat({
140 label: "Visitors",
141 href: "/boards/reach",
142 value: visitorsValue(k.reach),
143 full: `${visitorsValue(k.reach)}, ${visitorsNote(k.reach)}`,
144 note: visitorsNote(k.reach),
145 title: "Distinct browsers per day, summed over 7 days",
146 spark: visitorsSpark(k.reach.visitorDays),
147 }),
148 stat({
149 label: "Accounts",
150 href: "/boards/reach",
151 value: usersValue(k.reach),
152 full: usersValue(k.reach),
153 note: "signed in today",
154 title: "Accounts signed in today (UTC), of all accounts",
155 }),
156 stat({
157 label: "Page speed",
158 href: "/boards/reach",
159 value: speedWords(k.reach.loadP75),
160 full: speedWords(k.reach.loadP75),
161 note: reactNote(k.reach),
162 title: "Page load, and delay after a tap, for the slowest quarter of views over 7 days",
163 }),
164 ])}
158165 </section>`;
159166 }
160167
src/web/ui.ts +13
@@ -875,6 +875,19 @@ export function row(o: RowOptions): Html {
875875 </li>`;
876876 }
877877
878 /** One figure: its label, the value (its whole form, when different, as visually hidden text), a note, and optionally a sparkline or badge. A `row()` that links to where the figure comes from. */
879 export function stat(o: { label: string; href: string; value: Html | string; full: string; note: Html | string; title: string; spark?: Html | null; flag?: Html | null }): Html {
880 return row({
881 href: o.href,
882 title: o.label,
883 titleAttr: o.title,
884 meta: html`${o.note}${o.flag ? html` ${o.flag}` : null}`,
885 trail: o.full !== "" && o.full !== o.value
outdated

The whole figure is in title only. That is hover-only, so a phone user never sees the full form. Expose it as visually hidden text or a data- driven disclosure.

886 ? html`${o.spark ?? null}<span class="num" aria-hidden="true">${o.value}</span><span class="sr-only">${o.full}</span>`
887 : html`${o.spark ?? null}<span class="num">${o.value}</span>`,
888 });
889 }
890
878891 // ---- navigation ----
879892
880893 export interface TabItem {
test/client-home.test.ts +2 −2
@@ -244,8 +244,8 @@ describe("a client's first screen", () => {
244244 });
245245
246246 test("a client sees no forge-wide figures, lean or whole", async () => {
247 expect(await page(owner)).not.toContain('class="kpis"');
248 expect(await page(owner, "/?all=1")).not.toContain('class="kpis"');
247 expect(await page(owner)).not.toContain('aria-label="The last 24 hours');
248 expect(await page(owner, "/?all=1")).not.toContain('aria-label="The last 24 hours');
249249 });
250250
251251 test("queued agents and no running ones read as about to start", async () => {
test/home-cache.test.ts +3 −3
@@ -31,7 +31,7 @@ afterAll(async () => {
3131
3232 test("a warm home reads neither the KPIs nor the panels again; a write does", async () => {
3333 const a = await home(f.ownerCookie);
34 expect(a).toContain('class="kpis"');
34 expect(a).toContain('aria-label="The last 24 hours');
3535 expect(a).toContain("<h2>Pin A</h2>");
3636 const kpi = kpiCache(f.app.db);
3737 const panel = panelCache(f.app.db);
@@ -50,8 +50,8 @@ test("the owner's KPIs and panels never render for another viewer, warm or not",
5050 await home(f.ownerCookie);
5151 for (const cookie of [f.peerCookie, undefined]) {
5252 const page = await home(cookie);
53 expect(page).not.toContain('class="kpis"');
54 expect(page).not.toContain('class="card kpi"');
53 expect(page).not.toContain('aria-label="The last 24 hours');
54 expect(page).not.toContain("Last off-box backup");
outdated

This line repeats the one above it. Delete it, or assert something distinct, such as no data-variant badge in the non-admin page.

5555 expect(page).not.toContain("Pin A");
5656 }
5757 });
test/home-kpi-page.test.ts +10 −6
@@ -25,6 +25,8 @@ afterAll(async () => {
2525 await rm(dataDir, { recursive: true, force: true });
2626 });
2727
28 const FIGURES = 'aria-label="The last 24 hours, as of this page load"';
29
2830 test("home renders the nine tiles; only an admin sees them", async () => {
2931 const mk = async (username: string, first = false): Promise<User> => {
3032 const r = await createUser(app.db, {
@@ -59,9 +61,11 @@ test("home renders the nine tiles; only an admin sees them", async () => {
5961 view(day, "a", 1900, null);
6062 view(yesterday, "z", 400, 160);
6163 const a = await home(admin);
62 expect(a).toContain('class="kpis"');
63 expect((a.match(/class="card kpi"/g) ?? []).length).toBe(9);
64 for (const href of ["/board", "/releases", "/boards", "/settings/crew"]) expect(a).toContain(`class="card kpi" href="${href}"`);
64 expect(a).toContain(FIGURES);
65 const section = a.slice(a.indexOf(FIGURES), a.indexOf("</section>", a.indexOf(FIGURES)));
66 expect((section.match(/class="row"/g) ?? []).length).toBe(9);
67 for (const href of ["/board", "/releases", "/boards", "/settings/crew"]) expect(section).toContain(`<a href="${href}"`);
68 for (const name of ["kpis", "kpi", "kpi-note", "kpi-spark", "kpi-value"]) expect(a).not.toMatch(new RegExp(`class="[^"]*\\b${name}\\b`));
6569
6670 // 2 accounts, the admin alone with a session today; visitors 3 today and 4 over 7 days;
6771 // load p75 of [100,200,300,400,1900] is 400 ms, INP p75 of [40,80,120,160] is 120 ms.
@@ -70,14 +74,14 @@ test("home renders the nine tiles; only an admin sees them", async () => {
7074 expect(a).toContain(">4 in 7 days<");
7175 expect(a).toContain(">400 ms<");
7276 expect(a).toContain(">reacts in 120 ms<");
73 expect((a.match(/class="card kpi" href="\/boards\/reach"/g) ?? []).length).toBe(3);
77 expect((a.match(/<a href="\/boards\/reach"/g) ?? []).length).toBe(3);
7478
7579 // The figures count every repository, so a non-admin sees none.
7680 expect(a).toContain("no ceiling");
7781 expect(a).toContain("last 30 days");
78 expect(await home(bob)).not.toContain('class="kpis"');
82 expect(await home(bob)).not.toContain(FIGURES);
7983 expect(await home(bob)).not.toContain("last 30 days");
80 expect(await home()).not.toContain('class="kpis"');
84 expect(await home()).not.toContain(FIGURES);
8185 expect(await home()).not.toContain("last 30 days");
8286 });
8387
test/home-kpi-row.test.ts +24 −26
@@ -21,22 +21,22 @@ describe("home kpi row", () => {
2121 expect(out).toContain("0.3");
2222 expect(out).toContain("6 changes in 24 h");
2323 expect(out).toContain("abcdef0");
24 expect(out).not.toContain(">abcdef01"); // shortened on screen; the whole id is in the title
24 expect(out).not.toContain("<span class=\"num\">abcdef01"); // shortened on screen; the whole id is hidden text
2525 expect(out).toContain("3m 05s");
2626 for (const href of ["/board", "/releases", "/boards"]) expect(out).toContain(`href="${href}"`);
2727 });
2828
29 test("the whole figure is in the title and the link's label, rounded and in studio words", () => {
29 test("the whole figure is in the title, rounded and in studio words", () => {
3030 const out = kpiRowFor(
3131 { landedHours: hours(7), landed: 7, live: null, builders: { running: 2, slots: 4 }, spend: { todayUsd: 0, ceilingUsd: null }, medianCheckMs: 185_000, backupAt: null, reach: NO_REACH },
3232 { sha: "abcdef0123456", at: "2026-10-19T11:00:00.000Z" },
3333 ).toString();
34 expect(out).toContain('title="0.29"');
34 expect(out).toContain('class="sr-only">0.29<');
3535 expect(out).not.toContain("0.2916");
36 expect(out).toContain('title="3m 05s"');
36 expect(out).toContain('class="num">3m 05s<');
3737 expect(out).not.toContain(" ms");
38 expect(out).toContain('aria-label="Live version: abcdef0123456, Live since 2026-10-19T11:00:00.000Z"');
39 expect(out).toContain('aria-label="Shipped per hour: 0.29, 7 changes in 24 h"');
38 expect(out).toContain('class="sr-only">abcdef0123456<');
39 expect(out).toContain('title="7 changes in 24 h"');
4040 });
4141
4242 test("empty figures say so", () => {
@@ -74,27 +74,25 @@ describe("home kpi row", () => {
7474 expect(out).toContain('title="No check finished in 24 h"');
7575 });
7676
77 test("the note wraps into two reserved lines instead of cutting off on a phone", () => {
78 const rule = (sel: string) => new RegExp(`\\${sel} \\{([^}]*)\\}`).exec(feedCss)![1]!;
79 expect(rule(".kpi-note")).not.toContain("nowrap");
80 expect(rule(".kpi-note")).toContain("line-height: 20px");
81 expect(rule(".kpi-note")).toContain("line-clamp: 2");
82 expect(rule(".kpi")).toContain("grid-template-rows: 20px 32px 40px 24px");
77 test("the old kpi classes are gone from the markup", () => {
78 const out = kpiRowFor({ landedHours: hours(3), landed: 3, live: null, builders: { running: 2, slots: 4 }, spend: { todayUsd: 1, ceilingUsd: 4 }, medianCheckMs: 1000, backupAt: null, reach: NO_REACH }, { sha: "abcdef0123456", at: "2026-10-19T11:00:00.000Z" }).toString();
79 for (const name of ["kpis", "kpi", "kpi-note", "kpi-spark", "kpi-value"]) expect(out).not.toMatch(new RegExp(`class="[^"]*\\b${name}\\b`));
80 expect((out.match(/class="row"/g) ?? []).length).toBe(9);
81 expect(feedCss).not.toMatch(/\.kpi/);
8382 });
8483
8584 test("the builders tile says running of slots, titles it, and links to the crew", () => {
8685 const out = kpiRowFor({ landedHours: hours(0), landed: 0, live: null, backupAt: null, reach: NO_REACH, medianCheckMs: null, builders: { running: 2, slots: 4 }, spend: { todayUsd: 0, ceilingUsd: null } }, null).toString();
8786 expect(out).toContain('href="/settings/crew"');
88 expect(out).toContain('class="kpi-value num" title="2 of 4">2 of 4<');
87 expect(out).toContain('<span class="num">2 of 4</span>');
8988 expect(out).toContain('title="Crew builders running now, of 4 slots"');
90 expect(out).toContain('aria-label="Builders running: 2 of 4, Crew builders running now, of 4 slots"');
9189 });
9290
9391 test("with no slots set the builders tile shows a dash and says so", () => {
9492 const out = kpiRowFor({ landedHours: hours(0), landed: 0, live: null, backupAt: null, reach: NO_REACH, medianCheckMs: null, builders: { running: 0, slots: 0 }, spend: { todayUsd: 0, ceilingUsd: null } }, null).toString();
95 expect(out).toContain('class="kpi-value num" title="—">—<');
96 expect(out).toContain('title="No slots set">No slots set<');
97 expect(out).toContain(`aria-label="Builders running: —, No slots set"`);
93 expect(out).toContain('<span class="num">—</span>');
94 expect(out).toContain('title="No slots set"');
95 expect(out).toContain(">No slots set<");
9896 expect(out).not.toContain("Builders running: 0 of 0");
9997 });
10098
@@ -155,8 +153,8 @@ describe("the spend tile", () => {
155153
156154 test("shows today's spend of the ceiling, the cents in the title, linking to the crew page", () => {
157155 const out = row({ todayUsd: 12.34, ceilingUsd: 40 });
158 expect(out).toContain('class="kpi-value num" title="$12.34 of $40.00">$12 of $40<');
159 expect(out).toContain('aria-label="Crew spend today: $12.34 of $40.00, Crew spend today (UTC), of the daily ceiling"');
156 expect(out).toContain('<span class="num" aria-hidden="true">$12 of $40</span><span class="sr-only">$12.34 of $40.00</span>');
157 expect(out).toContain('title="Crew spend today (UTC), of the daily ceiling"');
160158 expect(out).toContain(">of the daily ceiling<");
161159 });
162160
@@ -166,7 +164,7 @@ describe("the spend tile", () => {
166164
167165 test("without a ceiling it shows the spend alone and says no ceiling", () => {
168166 const out = row({ todayUsd: 12.34, ceilingUsd: null });
169 expect(out).toContain('title="$12.34">$12<');
167 expect(out).toContain('<span class="sr-only">$12.34</span>');
170168 expect(out).toContain(">no ceiling<");
171169 expect(out).not.toContain(" of $");
172170 });
@@ -198,26 +196,26 @@ describe("home kpi row: the last off-box backup", () => {
198196 const hoursAgo = (h: number) => new Date(NOW.getTime() - h * 3_600_000).toISOString();
199197 const row = (backupAt: string | null) =>
200198 kpiRowFor({ landedHours: hours(0), landed: 0, live: null, backupAt, reach: NO_REACH, builders: { running: 0, slots: 0 }, spend: { todayUsd: 0, ceilingUsd: null }, medianCheckMs: null }, null, NOW).toString();
201 const tile = (out: string) => /<a class="card kpi"[^>]*href="\/settings\/backups"[^>]*>/.exec(out)![0];
199 const tile = (out: string) => /<li>\s*<a href="\/settings\/backups"[^]*?<\/li>/.exec(out)![0];
202200
203201 test("a backup 2 h old reads its age, with the exact time, and is not flagged", () => {
204202 const out = row(hoursAgo(2));
205203 expect(out).toContain("2 h ago");
206 expect(out).toContain(`title="${hoursAgo(2)}"`);
207 expect(tile(out)).not.toContain("data-tone");
204 expect(out).toContain(`<span class="sr-only">${hoursAgo(2)}</span>`);
205 expect(tile(out)).not.toContain("badge");
208206 expect(tile(out)).not.toContain("Overdue");
209207 });
210208
211209 test("a backup 25 h old is flagged and its label says overdue", () => {
212210 const t = tile(row(hoursAgo(25)));
213 expect(t).toContain('data-tone="attn"');
211 expect(t).toContain('data-variant="attn"');
214212 expect(t).toContain("Overdue");
215213 });
216214
217215 test("no backup at all reads never and is flagged", () => {
218216 const out = row(null);
219217 expect(out).toContain(">never<");
220 expect(tile(out)).toContain('data-tone="attn"');
218 expect(tile(out)).toContain('data-variant="attn"');
221219 expect(tile(out)).toContain("Overdue");
222220 });
223221
@@ -246,7 +244,7 @@ describe("the reach tiles", () => {
246244 const reach = { usersToday: 3, usersTotal: 12, visitorsToday: 5, visitors7d: 31, visitorDays: new Array<number>(30).fill(0), loadP75: 1250, inpP75: 180 };
247245 const out = kpiRowFor({ landedHours: hours(0), landed: 0, live: null, backupAt: null, reach, medianCheckMs: null, builders: { running: 0, slots: 0 }, spend: { todayUsd: 0, ceilingUsd: null } }, null).toString();
248246 for (const v of ["5 today", "31 in 7 days", "3 of 12", "signed in today", "1.3 s", "reacts in 180 ms"]) expect(out).toContain(`>${v}<`);
249 expect((out.match(/class="card kpi" href="\/boards\/reach"/g) ?? []).length).toBe(3);
247 expect((out.match(/<a href="\/boards\/reach"/g) ?? []).length).toBe(3);
250248 expect(out).not.toContain("INP");
251249 expect(out).not.toContain("p75");
252250 });
test/home-kpis.test.ts +7 −6
@@ -136,17 +136,18 @@ describe("home kpi row titles", () => {
136136 { sha: "abcdef0123456789", at: "2026-10-19T11:00:00.000Z" },
137137 ).toString();
138138
139 test("every shortened value and note carries its whole text in a title", () => {
140 expect(full).toContain('class="kpi-value num" title="abcdef0123456789"');
141 expect(full).toContain('class="kpi-value num" title="0.25"');
142 expect(full).toContain('class="kpi-value num" title="3m 05s"');
139 test("every shortened value carries its whole text as hidden text and each note in a title", () => {
140 expect(full).toContain('class="sr-only">abcdef0123456789<');
141 expect(full).toContain('class="sr-only">0.25<');
142 expect(full).toContain('class="num">3m 05s<');
143 expect(full).not.toMatch(/class="num"[^>]*title=/);
143144 expect(full).toContain('title="Live since 2026-10-19T11:00:00.000Z"');
144145 expect(full).toContain('title="6 changes in 24 h"');
145146 });
146147
147148 test("no value or note lacks a title, and none brings back a git word", () => {
148 expect(full.match(/class="kpi-(value num|note small muted)"/g)).toHaveLength(18);
149 expect(full.match(/class="kpi-(value num|note small muted)" title=/g)).toHaveLength(18);
149 expect(full.match(/class="num"/g)).toHaveLength(9);
150 expect(full.match(/class="row-title"\s+title=/g)).toHaveLength(9);
150151 expect(full).not.toMatch(/commit|merge|branch|repositor|pull request/i);
151152 });
152153 });
test/kpi-spark.test.ts +3 −3
@@ -37,7 +37,7 @@ describe("daySpark", () => {
3737
3838 test("it keeps the class, the box and currentColor, and adds no style or colour", () => {
3939 const out = daySpark([0, null, 5], "Days")!.toString();
40 expect(out).toStartWith('<svg class="kpi-spark" viewBox="0 0 96 24" width="96" height="24" role="img" aria-label="Days">');
40 expect(out).toStartWith('<svg class="muted" viewBox="0 0 96 24" width="96" height="24" role="img" aria-label="Days">');
4141 expect(out).not.toContain("style=");
4242 expect(out).not.toMatch(/#[0-9a-f]{3,8}\b|rgb|hsl/i);
4343 });
@@ -50,13 +50,13 @@ describe("daySpark", () => {
5050 describe("the numbers-only sparklines are unchanged", () => {
5151 test("visitorsSpark", () => {
5252 expect(visitorsSpark([0, 2, 4]).toString()).toBe(
53 `<svg class="kpi-spark" viewBox="0 0 96 24" width="96" height="24" role="img" aria-label="Distinct visitors each day over the last 3 days"><polyline points="0.0,22.0 48.0,12.0 96.0,2.0" ${LINE}/></svg>`,
53 `<svg class="muted" viewBox="0 0 96 24" width="96" height="24" role="img" aria-label="Distinct visitors each day over the last 3 days"><polyline points="0.0,22.0 48.0,12.0 96.0,2.0" ${LINE}/></svg>`,
5454 );
5555 });
5656
5757 test("sparkline, newest first in, oldest on the left", () => {
5858 expect(sparkline([2, 0]).toString()).toBe(
59 `<svg class="kpi-spark" viewBox="0 0 96 24" width="96" height="24" role="img" aria-label="Shipped each hour over the last 24 hours"><polyline points="0.0,22.0 96.0,2.0" ${LINE}/></svg>`,
59 `<svg class="muted" viewBox="0 0 96 24" width="96" height="24" role="img" aria-label="Shipped each hour over the last 24 hours"><polyline points="0.0,22.0 96.0,2.0" ${LINE}/></svg>`,
6060 );
6161 });
6262 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs