mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 09:56:17 -05:00
test: act on review — and correct an overstated claim about the toast bug
I said all four toast kinds were "the same pixel" in night. They were not.
Planting a reversion to hue names left the new distinctness test GREEN, because
in night `--blue`, `--green`, `--yellow` and `--red` are four different values
(2.29, 3.14, 4.52, 5.64 against a panel). What they are is cramped and badly
ranked, with info at 2.29:1 -- below the 3:1 floor, present and invisible.
The byte-identical pairs are real but elsewhere: `--orange` is `--text` and
`--yellow` is `--amber`, which bites a call site that reaches for those names,
not the toast mapping. The PR body has been corrected too.
So the distinctness assertion is not the one with teeth; the legibility floor
is. The monochrome toast test now measures every kind against the toast's own
surface, and the hue reversion fails it naming the number: 2.29:1.
Also from review:
`.wrolpi-message-error` still forced `border: 1.5px dashed var(--red)` while its
accent and icon had moved to roles -- nearly the same pixel in night, so no
colour test could see it. It follows `--message-color` now. Six more library
rules were naming a hue for a thing that means danger: the night danger button,
invalid form fields, invalid paths, path error text, danger panels and failed
table rows. All roles now, with a source guard that fails any rule whose
SELECTOR means severity and whose body names a hue. Focus rings and active-tab
accents deliberately keep `--blue`: those are the primary accent, not severity.
The tokens.css note claimed the brightness ramp held "in every theme" when the
tests deliberately limit it to monochrome. Narrowed, with the reason spelled
out, because the next person to read it would otherwise have "fixed" light to
match the prose -- which would mean reordering light's hues to satisfy a test.
Added the end-of-chain cases the review asked for: four toasts and four Messages
in night and amber, measured rather than inferred from variable names.
Colour reads now go through a strict `toRgb` that refuses anything not already
resolved. The reviewer's concern that `getPropertyValue('--info')` returns an
unresolved `var(--blue)` does not hold -- custom properties are substituted at
computed-value time and it returns `#20629c` -- but feeding an unresolved value
to a luminance calculation yields NaN, and `expect(NaN).to.not.equal(x)` passes.
Worth refusing loudly.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
08c5c233c8
commit
c7fddc55af
4 changed files with 155 additions and 27 deletions
|
|
@ -663,6 +663,37 @@ describe('Label as a tag', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('the library names severity by role, never by hue', () => {
|
||||
/*
|
||||
* A source guard, because a hue here is invisible in review and invisible in most tests.
|
||||
* In night `--red` and `--danger` are nearly the same pixel, so a rule that reverts to
|
||||
* `var(--red)` looks right in every screenshot and every distinctness check -- and is
|
||||
* still wrong, because the whole point is that a theme gets to decide what danger looks
|
||||
* like. This is how `.wrolpi-message-error` kept a hardcoded `var(--red)` frame through
|
||||
* the change that moved its accent and icon onto roles.
|
||||
*
|
||||
* Focus rings and active-tab accents deliberately stay `--blue`: those are the primary
|
||||
* accent, not a severity, and `--primary` is a separate token for exactly that reason.
|
||||
*/
|
||||
const severity = /(danger|error|failed|invalid|warning|success|complete)/i;
|
||||
|
||||
it('uses no severity hue in a rule whose name means severity', () => {
|
||||
const css = fs.readFileSync(path.join(__dirname, 'ui.css'), 'utf8');
|
||||
const hues = /var\(--(red|green|amber|yellow|orange)\)/;
|
||||
|
||||
// Split into rules, keeping each selector with its body.
|
||||
const offenders = [];
|
||||
for (const match of css.matchAll(/([^{}]+)\{([^}]*)\}/g)) {
|
||||
const [, selector, body] = match;
|
||||
if (severity.test(selector) && hues.test(body)) {
|
||||
offenders.push(`${selector.trim().split('\n').pop().trim()} -> ${body.match(hues)[0]}`);
|
||||
}
|
||||
}
|
||||
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('nothing paints a label\'s text with an inline colour', () => {
|
||||
/*
|
||||
* A source guard, because this defect appeared at three separate call sites and fixing the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue