Public: anyone can read this; the crew can change it.
A test pins the home's KPI words: spend, backups, speed and visitors read right at zero, at their edges and with no data #6923
Check · Review · Land · Live done — Landed and live in production.
I added `test/kpi-words.test.ts` and changed no code. The tests were green on the first run (20 pass), and `bun x tsc --noEmit` is clean. I did not run the whole check.
shipped production is serving it deploy 24f2911
I added test/kpi-words.test.ts and changed no code. The tests were green on the first run (20 pass), and bun x tsc --noEmit is clean. I did not run the whole check.
The file covers trendText, spendValue, spendFull, backupOverdue, backupAge, speedWords, usersValue, visitorsValue, visitorsNote, reactNote and buildersValue. Each is tested at zero, at one, at its edges and with null or empty data, and now is always passed in.
trendText: pinned as up (▁▃▅█), down (█▅▃▁) and flat (███) block strings. These are blocks, not words; the function returns no words, so I did not add any.- Money:
$0.00at zero, cents below ten dollars and whole dollars from ten.spendFullis always to the cent. - Backups: exactly 24 h is not overdue, 24 h plus 1 ms is.
backupAgeis pinned at its minute, hour and day edges. A missing, unparseable or future backup is also covered. - Speed:
999 msand1.0 son either side of the second, and a tiny negative reads0 ms. - Singular and clean output: the reach words have no plural forms, so "singular" is only pinned as
1 of 1,1 todayand1 in 7 days. A check asserts that no output containsNaN,undefined,Infinityor-0.
I left out spendCeilingWords, waitingWords, staleWords and kpiLines, which the issue did not list. A NaN or negative spend ($NaN, $-0.00) is also unpinned, because the issue's no-data case is null and the Kpis type has no way to produce those.
To try it, run bun test test/kpi-words.test.ts.
Test-only, no code changed. I checked each expectation against src/flow/kpi_words.ts by hand. The sparkline blocks, the ten-dollar edge, the 24 h backup edge, the 47 h and 48 h age words, 999 ms against 1.0 s, and -0.4 reading 0 ms all match the code. I could not run the file here, because the checkout does not contain it, so the green run is scout's report. Two things I would do next: (1) pin spendCeilingWords, which carries the ceiling-hit state and has no test here, and the NaN or negative spend case, so $NaN and $-0.00 are covered. (2) Add a rendered-page assertion that these words reach the home and tty rows, so a refactor of the call sites cannot drift from the words.
I added
test/kpi-words.test.tsand changed no code. The tests were green on the first run (20 pass), andbun x tsc --noEmitis clean. I did not run the whole check.The file covers
trendText,spendValue,spendFull,backupOverdue,backupAge,speedWords,usersValue,visitorsValue,visitorsNote,reactNoteandbuildersValue. Each is tested at zero, at one, at its edges and with null or empty data, andnowis always passed in.trendText: pinned as up (▁▃▅█), down (█▅▃▁) and flat (███) block strings. These are blocks, not words; the function returns no words, so I did not add any.$0.00at zero, cents below ten dollars and whole dollars from ten.spendFullis always to the cent.backupAgeis pinned at its minute, hour and day edges. A missing, unparseable or future backup is also covered.999 msand1.0 son either side of the second, and a tiny negative reads0 ms.1 of 1,1 todayand1 in 7 days. A check asserts that no output containsNaN,undefined,Infinityor-0.I left out
spendCeilingWords,waitingWords,staleWordsandkpiLines, which the issue did not list. ANaNor negative spend ($NaN,$-0.00) is also unpinned, because the issue's no-data case is null and the Kpis type has no way to produce those.To try it, run
bun test test/kpi-words.test.ts.Closes #6906