mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 05:39:57 -05:00
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:
parent
675bd5d620
commit
acd27fe28e
5 changed files with 110 additions and 65 deletions
|
|
@ -1224,15 +1224,24 @@ export function FileIcon({file, disabled = true, size = 48, ...props}) {
|
|||
/>
|
||||
}
|
||||
|
||||
export function LoadStatistic({label, value, cores, ...props}) {
|
||||
// Load is a warning above half the cores, and a problem above three quarters.
|
||||
/**
|
||||
* The severity of a load average: a warning above half the cores, a problem above three
|
||||
* quarters, and nothing to say below that or when the core count is unknown.
|
||||
*
|
||||
* Exported and pure so the branches can be tested as branches. Reading the colour back off
|
||||
* a rendered Statistic cannot do it -- jsdom rejects `color: var(--danger)` as an invalid
|
||||
* declaration and drops it, so every value comes back as the empty string.
|
||||
*/
|
||||
export const loadRole = (value, cores) => {
|
||||
if (!cores) return undefined;
|
||||
const quarter = cores / 4;
|
||||
let color;
|
||||
if (cores && value >= (quarter * 3)) {
|
||||
color = 'danger';
|
||||
} else if (cores && value >= (quarter * 2)) {
|
||||
color = 'warning';
|
||||
}
|
||||
if (value >= quarter * 3) return 'danger';
|
||||
if (value >= quarter * 2) return 'warning';
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export function LoadStatistic({label, value, cores, ...props}) {
|
||||
const color = loadRole(value, cores);
|
||||
return <Statistic
|
||||
label={label}
|
||||
value={value ? parseFloat(value).toFixed(1) : '?'}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue