test: act on review — the browser test named LoadStatistic but never mounted it

The suite was titled "a load reading ranks itself", commented as covering the
thresholds, and cross-referenced from Common.test.js as the place the painted
result is checked.  It mounted a hand-built `<Statistic color='warning'/>`.

So it proved that role tokens resolve distinctly -- which the roles suite two
blocks up already covers -- and would have stayed green with LoadStatistic
reverted to `orange`/`red`.  The same shape as the column-border test in #609:
a claim that outran its measurement.  It mounts the real helper at the real
thresholds now, and the reversion fails it.

The source guards are gone.  They scraped function bodies out of files with
indexOf slices, covered two helpers, and never executed a branch.  `loadRole`
and `healthRole` are pure exported functions instead, tested as mappings:
either side of both load thresholds, every SMART assessment, lower case (the
value comes from smartctl), and the case that matters most -- an unreadable
drive must report as unknown, never as healthy.

That is also the better answer to the jsdom problem that produced the guards.
jsdom rejects `color: var(--danger)` and drops it, so the mapping cannot be read
back off a rendered component; extracting it is the honest fix rather than
asserting on source text.

And the gallery was itself half-migrated: 15 Min. Load became `danger` while
5 Min. Load stayed `orange` -- in the one sample whose caption tells the reader
to go and check night and amber, where orange is byte-identical to --text.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-08-01 18:17:18 -06:00
parent 7a6b09aee6
commit 2ce7601ebb
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
5 changed files with 110 additions and 65 deletions

View file

@ -605,19 +605,33 @@ function ServicesSection() {
// Helper to get health status color from SMART assessment
const getHealthColor = (assessment) => {
// Roles, not hues: a drive's assessment is a severity and has to rank as one. All
// four branches together -- a helper where PASS and FAIL rank but WARN is an
// unranked hue is worse than either choice, and in night `--amber` is byte-identical
// to `--yellow` so WARN would stop sitting between them.
if (!assessment) return 'var(--neutral)';
const upper = assessment.toUpperCase();
if (upper === 'PASS') return 'var(--success)';
if (upper === 'WARN') return 'var(--warning)';
if (upper === 'FAIL') return 'var(--danger)';
return 'var(--neutral)';
/**
* The severity of a SMART assessment.
*
* Roles, not hues: a drive's health is a severity and has to rank as one. All four
* branches together -- a helper where PASS and FAIL rank but WARN is an unranked hue is
* worse than either choice, and in night `--amber` is byte-identical to `--yellow`, so WARN
* would stop sitting between them.
*
* Exported and pure so the mapping can be tested as a mapping rather than scraped out of
* the source, which is what this needed before it was separated from the CSS wrapper.
*/
export const healthRole = (assessment) => {
if (!assessment) return 'neutral';
switch (assessment.toUpperCase()) {
case 'PASS':
return 'success';
case 'WARN':
return 'warning';
case 'FAIL':
return 'danger';
default:
return 'neutral';
}
};
const getHealthColor = (assessment) => `var(--${healthRole(assessment)})`;
// Helper to format power-on hours
const formatPowerOnHours = (hours) => {
if (hours === null || hours === undefined) return '-';