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

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

Parked opened this
Closed without merging

scout/forge:scout/3877-design-the-home-kpis-use-5-s-stat-and-th → main 1 commit fork 1 thread · 1 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
10 files changed +80 −76
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 +24 −27
@@ -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,13 +75,8 @@ 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>`;
78 function tile(label: string, href: string, value: Html | string, full: string, note: string | Html, title: string, spark: Html | null = null, flag: Html | null = null): Html {
79 return stat({ label, href, value, full, note, title, spark, flag });
8580 }
8681
8782 /** The version this forge is running, and since when: the same source as `/releases`. */
@@ -93,8 +88,9 @@ export function liveNow(): { sha: string; at: string } | null {
9388 export function kpiRowFor(k: Kpis, live: { sha: string; at: string } | null, now: Date = new Date()): Html {
9489 const overdue = backupOverdue(k.backupAt, now);
9590 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(
91 return html`<section aria-label="The last 24 hours, as of this page load">
92 ${listCard([
93 tile(
9894 "Shipped per hour",
9995 "/board",
10096 rate.toFixed(1),
@@ -102,40 +98,40 @@ export function kpiRowFor(k: Kpis, live: { sha: string; at: string } | null, now
10298 `${k.landed} ${k.landed === 1 ? "change" : "changes"} in 24 h`,
10399 `${k.landed} ${k.landed === 1 ? "change" : "changes"} in 24 h`,
104100 sparkline(k.landedHours),
105 )}
106 ${tile(
101 ),
102 tile(
107103 "Live version",
108104 "/releases",
109105 live === null ? "—" : sha(live.sha),
110106 live === null ? "Nothing live yet" : live.sha,
111107 live === null ? "Nothing live yet" : html`live ${time(live.at)}`,
112108 live === null ? "Nothing live yet" : `Live since ${live.at}`,
113 )}
114 ${tile(
109 ),
110 tile(
115111 "Median check time",
116112 "/boards",
117113 checkTime(k.medianCheckMs),
118114 k.medianCheckMs === null ? "No check finished in 24 h" : checkTime(k.medianCheckMs),
119115 k.medianCheckMs === null ? "No check finished in 24 h" : "over the last 24 h",
120116 k.medianCheckMs === null ? "No check finished in 24 h" : "over the last 24 h",
121 )}
122 ${tile(
117 ),
118 tile(
123119 "Builders running",
124120 "/settings/crew",
125121 buildersValue(k.builders),
126122 buildersValue(k.builders),
127123 k.builders.slots === 0 ? "No slots set" : "running now",
128124 k.builders.slots === 0 ? "No slots set" : `Crew builders running now, of ${k.builders.slots} ${k.builders.slots === 1 ? "slot" : "slots"}`,
129 )}
130 ${tile(
125 ),
126 tile(
131127 "Crew spend today",
132128 "/settings/crew",
133129 spendValue(k.spend),
134130 spendFull(k.spend),
135131 k.spend.ceilingUsd === null ? "no ceiling" : "of the daily ceiling",
136132 k.spend.ceilingUsd === null ? "No daily ceiling is set" : "Crew spend today (UTC), of the daily ceiling",
137 )}
138 ${tile(
133 ),
134 tile(
139135 "Last off-box backup",
140136 "/settings/backups",
141137 backupAge(k.backupAt, now),
@@ -143,18 +139,19 @@ export function kpiRowFor(k: Kpis, live: { sha: string; at: string } | null, now
143139 k.backupAt === null ? "no backup off the machine yet" : overdue ? "overdue, more than 24 h" : "off the machine",
144140 overdue ? "Overdue: the last off-box backup is more than 24 h old" : "Age of the last off-box backup",
145141 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(
142 overdue ? badge("overdue", { tone: "attn" }) : null,
143 ),
144 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)),
145 tile("Accounts", "/boards/reach", usersValue(k.reach), usersValue(k.reach), "signed in today", "Accounts signed in today (UTC), of all accounts"),
146 tile(
151147 "Page speed",
152148 "/boards/reach",
153149 speedWords(k.reach.loadP75),
154150 speedWords(k.reach.loadP75),
155151 reactNote(k.reach),
156152 "Page load, and delay after a tap, for the slowest quarter of views over 7 days",
157 )}
153 ),
154 ])}
158155 </section>`;
159156 }
160157
src/web/ui.ts +11
@@ -875,6 +875,17 @@ export function row(o: RowOptions): Html {
875875 </li>`;
876876 }
877877
878 /** One figure: its label, the value (with its whole form as a title), 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: html`${o.spark ?? null}<span class="num" title="${o.full}">${o.value}</span>`,
886 });
887 }
888
878889 // ---- navigation ----
879890
880891 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('aria-label="The last 24 hours');

Duplicate of the line above; drop it, or assert something different such as the 9-row count.

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 +20 −22
@@ -26,7 +26,7 @@ describe("home kpi row", () => {
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" },
@@ -35,8 +35,8 @@ describe("home kpi row", () => {
3535 expect(out).not.toContain("0.2916");
3636 expect(out).toContain('title="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('title="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" title="2 of 4">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" title="—">—</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" title="$12.34 of $40.00">$12 of $40</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('title="$12.34">$12</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");
206204 expect(out).toContain(`title="${hoursAgo(2)}"`);
207 expect(tile(out)).not.toContain("data-tone");
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 +5 −5
@@ -137,16 +137,16 @@ describe("home kpi row titles", () => {
137137 ).toString();
138138
139139 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"');
140 expect(full).toContain('class="num" title="abcdef0123456789"');
141 expect(full).toContain('class="num" title="0.25"');
142 expect(full).toContain('class="num" title="3m 05s"');
143143 expect(full).toContain('title="Live since 2026-10-19T11:00:00.000Z"');
144144 expect(full).toContain('title="6 changes in 24 h"');
145145 });
146146
147147 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);
148 expect(full.match(/class="num" title=/g)).toHaveLength(9);
149 expect(full.match(/class="row-title"\s+title=/g)).toHaveLength(9);
150150 expect(full).not.toMatch(/commit|merge|branch|repositor|pull request/i);
151151 });
152152 });
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