diff --git a/app/src/components/Common.js b/app/src/components/Common.js index 8332765d..9c493765 100644 --- a/app/src/components/Common.js +++ b/app/src/components/Common.js @@ -1229,9 +1229,9 @@ export function LoadStatistic({label, value, cores, ...props}) { const quarter = cores / 4; let color; if (cores && value >= (quarter * 3)) { - color = 'red'; + color = 'danger'; } else if (cores && value >= (quarter * 2)) { - color = 'orange'; + color = 'warning'; } return { } }); }); + +describe('LoadStatistic ranks load by role, not by hue', () => { + /* + * A source guard, not a render test, and deliberately so: jsdom's CSS parser REJECTS + * `color: var(--danger)` as an invalid declaration and drops it, so every inline colour + * reads back as the empty string here. A render test would pass whatever the component + * did -- the first version of this asserted `''` for the below-threshold cases and would + * have gone on passing with the hues restored. + * + * What is painted is asserted in ui-layout.cy.js, in a browser, at the thresholds. + */ + it('names roles rather than hues at both thresholds', () => { + const source = fs.readFileSync(path.join(__dirname, 'Common.js'), 'utf8'); + const helper = source.slice( + source.indexOf('export function LoadStatistic'), + source.indexOf('export function', source.indexOf('export function LoadStatistic') + 10)); + + expect(helper).toContain("color = 'danger'"); + expect(helper).toContain("color = 'warning'"); + expect(helper.match(/'(red|green|amber|yellow|orange)'/)).toBeNull(); + }); +}); + +describe('a drive\'s SMART assessment is a severity, not a colour', () => { + /* + * A source guard: `getHealthColor` is module-private, and exporting it only so a test + * can reach it would be shaping the code around the test. What matters is that the + * helper stays on the ramp -- all four branches or none, since a helper where PASS and + * FAIL rank but WARN is an unranked hue is worse than either choice. + */ + it('maps every branch to a role', () => { + const source = fs.readFileSync( + path.join(__dirname, 'admin', 'ControllerPage.js'), 'utf8'); + const helper = source.slice( + source.indexOf('const getHealthColor'), + source.indexOf('};', source.indexOf('const getHealthColor'))); + + expect(helper).toContain("'var(--success)'"); + expect(helper).toContain("'var(--warning)'"); + expect(helper).toContain("'var(--danger)'"); + expect(helper.match(/var\(--(red|green|amber|yellow|orange)\)/)).toBeNull(); + }); +}); diff --git a/app/src/components/Files.js b/app/src/components/Files.js index 1b3644de..2b8bd23a 100644 --- a/app/src/components/Files.js +++ b/app/src/components/Files.js @@ -979,10 +979,12 @@ function RefreshStepItem({phase, isActive, isCompleted, isDisabled, description} return
+ {/* The same three roles Status maps complete/active/pending onto. Not the Status + component itself: these rows carry a per-phase glyph, which is the point of them. */} + style={{color: isCompleted ? 'var(--success)' : isActive ? 'var(--info)' : 'var(--neutral)'}}/>
{phase.title}
{isActive || isCompleted ? description : ''}
@@ -1033,7 +1035,7 @@ function RefreshProgressBar({status, operation_total, operation_processed, opera // Show error state if (status === 'error' && error) { - return ; + return ; } let label = `${phaseLabel}`; diff --git a/app/src/components/Flasher.js b/app/src/components/Flasher.js index ac1652d3..295c2fcc 100644 --- a/app/src/components/Flasher.js +++ b/app/src/components/Flasher.js @@ -909,7 +909,7 @@ export function FlasherPage() { {chipMismatch && -