wrolpi/app/src/components/ui/ui-layout.cy.js

4166 lines
200 KiB
JavaScript
Raw Normal View History

ui: a browser layer for the library, and the .media reset that never applied The PathInput overlap could not have been caught by jest -- jsdom computes no layout -- so the only guard was a grep for one spelling of one mistake. This adds the layer that can actually see it, and it found a real bug immediately. ui-layout.cy.js mounts library components in a real browser through a new cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and nothing else. That spartan setup is the point: these components read no ambient state, so a spec can assert what jsdom cannot compute -- real geometry, resolved custom properties, applied filters -- across all four themes. It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it still overlaps, because a geometry check that has never gone red is indistinguishable from one that cannot fail. The bug it found: the rule resetting `filter` on leaf media inside a `.media` wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost every time and never applied to anything. Every image inside a filtered wrapper has been through the luminance matrix twice since that rule landed -- markedly darker than its surroundings, which is exactly what it was written to prevent. tokens.test.js asserted only that the rule's text was present, and so stayed green throughout; it now compares the two selectors' specificity, which is computable without a browser and goes red on the old selector. Three guards in ui.test.js keep the library mock-free by construction rather than by habit: no jest.mock in its own tests, no fetch in any library file, and no useContext outside the theme controls, whose job is to read the theme. All three were verified red against planted violations. 959 jest tests, 14 new browser tests, clean cache-busted build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
import React from 'react';
import {
ActionInput, Button, Card, Header, Icon, IconButton, IconStack, Loading, MultiSelect, Panel, PathInput,
ui: the map pin buttons were three sizes for three reasons Reported as "all different sizes", and the pin row's three actions measured 46x30, 30x30 and 54x36. Three causes. APIButton dropped `size`. `useAPIButton` declared `size = 'medium'` as a parameter and then never put it into the props it hands to Button, so every APIButton in the app rendered at Mantine's default regardless of what its call site asked for -- seventeen call sites pass one, from `xs` on the map pins to `big` and `huge` on Settings. The delete pin was 36px tall beside two 30px siblings because of it. Passing the parameter default through would have fixed the bug by breaking everything else -- every APIButton naming no size would have grown from `sm` to `md` -- so the default is undefined now and Button's own default stands. Eight buttons on three other pages do grow as a result, which is their call sites finally being honoured: VideoPlayer's `large`, one of Channels' `big`, and Settings' two `big` and two `huge`. An icon-only Button was not square. A Button is as wide as its content plus its horizontal padding; an ActionIcon is square by construction; and the pin row mixes the two, because AddToPlaylistButton renders an IconButton when it has no label. Their heights already agreed -- ActionIcon's scale was remapped onto Button's some commits ago -- and this is the other axis of the same alignment, keyed off Mantine's own `--button-height` so the two stay in step through every size. They were also misaligned and touching, which is a third thing: bare inline-block siblings align on text BASELINES, and a Button's baseline is not an ActionIcon's, so the middle control sat 4.3px above the other two. A Group, as every other row of buttons in the app uses. Written test-first at Roland's request. Seven cypress cases went red on the sizes -- widths 46 against 30, 54 against 36, 62 against 42, 70 against 50, and "xs is shorter than lg: expected 36 to be below 32" for the dropped size -- with both inverses green throughout: a labelled button stays as wide as its label, and an APIButton naming no size keeps the height it had. The alignment claim is measured in ui-layout.cy.js, including the premise that bare siblings really are misaligned, since three controls of identical height not lining up is not believable otherwise. The call sites are held by a source guard, because MapPins fetches from the API and builds its rows through SortableTable. That guard earned itself twice over. Written for the pin rows, it found the map-files subscribe cell putting a preview button beside a subscribe button with the same defect. Then a first attempt at a general "any cell with two controls" rule had to be abandoned: a cell whose buttons are the arms of a ternary renders only one and needs no Group, and excluding ternaries to allow for that also excluded the subscribe cell, whose `role={isSubscribed ? ... : ...}` says nothing about how many controls it holds. Named cells with a stated scope beat a general rule that quietly stops covering things. Two slips of mine in that file, both caught by running it: `expect(value, message)` is chai and throws in jest, and `onSave(pin.id, ...)` was not unique to the cell it named -- the edit row's TextInput calls it from onKeyDown in a different cell, so the check passed against the wrong one. 1132 jest / 64 suites, 243 in ui-layout.cy.js, clean npm run build. Confirmed live: three 30x30 controls, vertical spread 0, 10px gaps.
2026-08-02 17:44:25 -06:00
Group, Message, Pagination, Placeholder, Progress, SearchBox, Statistic, StatisticGroup, Status, TabBar, Table,
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
tabClassName, TextInput,
} from './index';
ui: cards get legible titles, contained posters, and meta beside the title Four defects on /videos, /docs and /archives. Titles were invisible outside light. `.card-link` carried a literal `color: black` from before the themes existed -- about 1.1:1 on the dark, night and amber panels. It applies to every card title and to the channel/author/domain line beside it. The date was fine, since it takes `--muted` from the card body, which is what made this look like a card bug rather than a link bug. Titles now take `--text`: they are links, but they are the card's text, not a wall of blue. Posters were cropped, not mis-proportioned. The image carried a fixed 290x163 box; a card in the default grid is about 233px wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle 233px of a 290px image. The ratio was right in the layout tree and wrong on screen. Replaced with caps on both axes -- the card's width and `--card-poster-max-height: 200px` -- with `width`/`height` left `auto` so the pair behaves as "contain". Bounding the width alone was tried first and is not enough: a square thumbnail then stands as tall as the card is wide, and a portrait book cover taller still. The meta line was foot-anchored, so on /docs a PDF with no author had its date shoved up to 55px below the title, at the bottom of a card that was tall only because of its neighbour in the row. It now sits directly under the title. Archive cards read buttons-then-domain, because the buttons were children and the meta was what got pushed to the foot. Card gains an `actions` slot, rendered last and anchored to the foot, so a row lines its buttons up however many lines each title took. Gallery gains a poster row covering all five ratios and a row showing meta/actions against unequal titles. 1076 jest tests, 145 in ui-layout.cy.js, clean build. Every new guard was checked against a planted regression: dropping the height cap reddens the square and portrait cases and leaves 16:9 green; `width: 100%` reddens containment; restoring `color: black` reddens dark/night/amber and leaves light green; re-anchoring the meta and swapping the slot order redden both the jest order test and the cypress geometry tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 09:16:31 -06:00
import {MemoryRouter} from 'react-router';
ui: act on review -- corner chrome, a swallowed className, and the poster frame Three real defects from the PR review, each reproduced before it was fixed. The tag mark and a video's duration were pinned to the poster BAND, which is the full width of the card, rather than to the painted image. Once the height cap landed the two stopped being the same box: measured, the mark sat 39px clear of a book cover, 56px clear of a small poster and 60px clear of a vertical video, and the duration 55px clear. It went unnoticed because on a 16:9 poster the image fills the band and the two pin to the same place -- so the tests cover the height-bound ratios, and assert the letterbox gap is really there before measuring into it. CardPoster now centres a frame that shrink-wraps the image, and the frame is what corner chrome is positioned against. VideoCard passes its duration through a new `overlay` prop rather than wrapping CardPoster in a box of its own. The mark also went back INSIDE the link. Splitting it out made the tagged corner a dead spot on an otherwise clickable poster. CardLink and ExternalCardLink wrote `className='...' {...props}`, so a caller's className replaced the pair instead of adding to it. Every archive title passes `card-title-ellipsis`, so every archive title lost `card-link` -- the one card type this PR migrates for layout was the one missing the title treatment. Both compose now. On the fourth comment, the breadth of the ActionIcon remap: it is deliberate and the numbers are small. 59 IconButton call sites, 52 of them at the default size, 7 at `xs` (one in Flasher, three in the inventory schema editor). The one library control that stands beside an input rather than a button is SearchBox's clear, and the remap is exactly what that scale is for -- it now matches its field to the pixel, where before it was 28px against a 36px input. Guarded by a test that fails at 42 vs 36 if the default is reverted. 1078 jest, 158 in ui-layout.cy.js, clean build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 11:35:49 -06:00
import {VideoCard} from '../Videos';
ui: cards get legible titles, contained posters, and meta beside the title Four defects on /videos, /docs and /archives. Titles were invisible outside light. `.card-link` carried a literal `color: black` from before the themes existed -- about 1.1:1 on the dark, night and amber panels. It applies to every card title and to the channel/author/domain line beside it. The date was fine, since it takes `--muted` from the card body, which is what made this look like a card bug rather than a link bug. Titles now take `--text`: they are links, but they are the card's text, not a wall of blue. Posters were cropped, not mis-proportioned. The image carried a fixed 290x163 box; a card in the default grid is about 233px wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle 233px of a 290px image. The ratio was right in the layout tree and wrong on screen. Replaced with caps on both axes -- the card's width and `--card-poster-max-height: 200px` -- with `width`/`height` left `auto` so the pair behaves as "contain". Bounding the width alone was tried first and is not enough: a square thumbnail then stands as tall as the card is wide, and a portrait book cover taller still. The meta line was foot-anchored, so on /docs a PDF with no author had its date shoved up to 55px below the title, at the bottom of a card that was tall only because of its neighbour in the row. It now sits directly under the title. Archive cards read buttons-then-domain, because the buttons were children and the meta was what got pushed to the foot. Card gains an `actions` slot, rendered last and anchored to the foot, so a row lines its buttons up however many lines each title took. Gallery gains a poster row covering all five ratios and a row showing meta/actions against unequal titles. 1076 jest tests, 145 in ui-layout.cy.js, clean build. Every new guard was checked against a planted regression: dropping the height cap reddens the square and portrait cases and leaves 16:9 green; `width: 100%` reddens containment; restoring `color: black` reddens dark/night/amber and leaves light green; re-anchoring the meta and swapping the slot order redden both the jest order test and the cypress geometry tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 09:16:31 -06:00
import {CardPoster, contrastingColor, HelpHeader, LoadStatistic} from '../Common';
test: prove the toast contrast fix in a browser, and fix the harness that hid it The title contrast was verified by hand and by nothing else. jsdom cannot check it: it resolves no `var()`, so the title's colour there is the literal string `var(--mantine-color-white)` and every contrast assertion passes. Six browser tests now cover it -- title and description at WCAG AA in each of the four themes, the title staying heavier than the message where night and amber drop its muting, and the toast taking `--panel` for its surface. The three that can fail were checked against the fix removed: 1.13:1 in dark, night and amber. Light passes either way, correctly, because Mantine's light-scheme title uses `--mantine-color-black`, which the bridge maps to `--text`. Getting there took three corrections, all of them mine: * `cy.mountUI` never set `forceColorScheme`, so every theme rendered against Mantine's LIGHT scheme. Mantine keys its own rules on data-mantine-color-scheme, and ThemeProvider sets it from the theme -- night and amber ride on dark. Any per-theme test could therefore pass on a page that was broken in the app. This is the harness the tag contrast tests use too. * The support file never imported `@mantine/notifications/styles.css`, which App.js does, so a Notification rendered unstyled and had no surface or title colour of Mantine's to be wrong about. * The spec's own helper mounted a second time to raise the toast, which reset the theme to the default. All four per-theme cases ran in light. For the record, the chain the fix breaks: `.m_3feedf16` (the title) in dark scheme is `color: var(--mantine-color-white)`, the bridge aliases that to `--btn-text`, and `--btn-text` is the text drawn on a filled button -- near-black in dark, night and amber. Mantine writes it through `:where(...)`, which has zero specificity, so a single-class override plus `html` outranks it.
2026-08-01 15:07:48 -06:00
import {Notifications} from '@mantine/notifications';
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>
2026-08-01 17:46:33 -06:00
import {clearToasts, toast} from './toast';
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
import {monochromeThemes, themeNames} from '../../themes/names';
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
import {navColorNames} from '../../themes/navColors';
import {NavBarSample} from '../ThemeSamplePage';
ui: the navbar corner was nudged rather than laid out, and it showed Three faults in the bar, all reproduced by measurement before being fixed. The indicators sat low. The slot carried `marginTop: 0.8em`, a nudge left over from Semantic's menu; the corner centres its children, and a top margin is part of the margin box being centred, so it applied as a ~6px downward shift. It read as an error on the hotspot and the theme picker but not on share or search, which is why it survived: an IconButton is a square ActionIcon that centres its glyph exactly, while a bare-icon anchor sits high inside a line box that reserves descender space for text that is not there. The nudge cancelled that out on one shape and was pure error on the other. Both are laid out now -- flex, centred, no nudge -- and the anchors get `display: flex` so they hug their glyph instead of a text line. Help and Admin highlighted only a box around their text while Videos and Statistics highlighted the full height. Same class, same rules, different parent: the bar stretches its children, but the corner is a nested flex container that centres its own, so a link inside it was sized to its content. The hover background is painted on the link box, so that box IS the affordance. The bar broke onto a second line at certain widths. Two measurement errors that only overlap in a narrow band, which is why it appeared while resizing rather than always. useOverflowNav measured the WRAPPER's offsetWidth and subtracted only the home link and the corner, missing the bar's own `padding: 0 0.25em` -- about 8px it believed it had. And the hidden "More" placeholder it measured was a plain button with no dropdown caret, about 21px narrower than the button that eventually rendered. The placeholder is now the same component as the real trigger, so the two cannot drift again. Tested in ui-layout.cy.js against the real <DesktopNav/>, which takes its colours, home link and indicators as props and so needs none of NavBar's polling hooks. Indicator centres are measured against the bar's centre rather than each other, because three things can be equally and consistently wrong and were. The wrap case sweeps 1180px down to 640px in 6px steps -- a spot check steps over a band that narrow. All three failed first: share 3.4px high, Help 24.8px against a 54.4px bar, and two rows at 1156px. Confirmed on the running app: every indicator at 0.0px from the bar's centre, Help and Admin at the full 54.4px, and no wrap anywhere from 1500px to 780px. 1115 jest / 62 suites, 182 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:25:04 -06:00
import {DesktopNav, NavIconWrapper} from '../Nav';
ui: the map pin buttons were three sizes for three reasons Reported as "all different sizes", and the pin row's three actions measured 46x30, 30x30 and 54x36. Three causes. APIButton dropped `size`. `useAPIButton` declared `size = 'medium'` as a parameter and then never put it into the props it hands to Button, so every APIButton in the app rendered at Mantine's default regardless of what its call site asked for -- seventeen call sites pass one, from `xs` on the map pins to `big` and `huge` on Settings. The delete pin was 36px tall beside two 30px siblings because of it. Passing the parameter default through would have fixed the bug by breaking everything else -- every APIButton naming no size would have grown from `sm` to `md` -- so the default is undefined now and Button's own default stands. Eight buttons on three other pages do grow as a result, which is their call sites finally being honoured: VideoPlayer's `large`, one of Channels' `big`, and Settings' two `big` and two `huge`. An icon-only Button was not square. A Button is as wide as its content plus its horizontal padding; an ActionIcon is square by construction; and the pin row mixes the two, because AddToPlaylistButton renders an IconButton when it has no label. Their heights already agreed -- ActionIcon's scale was remapped onto Button's some commits ago -- and this is the other axis of the same alignment, keyed off Mantine's own `--button-height` so the two stay in step through every size. They were also misaligned and touching, which is a third thing: bare inline-block siblings align on text BASELINES, and a Button's baseline is not an ActionIcon's, so the middle control sat 4.3px above the other two. A Group, as every other row of buttons in the app uses. Written test-first at Roland's request. Seven cypress cases went red on the sizes -- widths 46 against 30, 54 against 36, 62 against 42, 70 against 50, and "xs is shorter than lg: expected 36 to be below 32" for the dropped size -- with both inverses green throughout: a labelled button stays as wide as its label, and an APIButton naming no size keeps the height it had. The alignment claim is measured in ui-layout.cy.js, including the premise that bare siblings really are misaligned, since three controls of identical height not lining up is not believable otherwise. The call sites are held by a source guard, because MapPins fetches from the API and builds its rows through SortableTable. That guard earned itself twice over. Written for the pin rows, it found the map-files subscribe cell putting a preview button beside a subscribe button with the same defect. Then a first attempt at a general "any cell with two controls" rule had to be abandoned: a cell whose buttons are the arms of a ternary renders only one and needs no Group, and excluding ternaries to allow for that also excluded the subscribe cell, whose `role={isSubscribed ? ... : ...}` says nothing about how many controls it holds. Named cells with a stated scope beat a general rule that quietly stops covering things. Two slips of mine in that file, both caught by running it: `expect(value, message)` is chai and throws in jest, and `onSave(pin.id, ...)` was not unique to the cell it named -- the edit row's TextInput calls it from onKeyDown in a different cell, so the check passed against the wrong one. 1132 jest / 64 suites, 243 in ui-layout.cy.js, clean npm run build. Confirmed live: three 30x30 controls, vertical spread 0, 10px gaps.
2026-08-02 17:44:25 -06:00
import {APIButton} from '../Common';
ui: the corner triggers, the More button, and the search modal Four faults, each measured in the running app before and after. The search glyph carried Semantic's `item` class, which has had no rules at all since Semantic was removed: no pointer cursor, no hover, and an 18.6px hit area against a 54.4px bar. It is the same kind of thing as Help and Admin and now takes the same class. The share glyph did compute `cursor: pointer` -- it is an `<a href>` -- but its target was the 24px box the icon occupies, so the pointer appeared only if you found it exactly. Corner anchors now stretch and pad like a link. The More button rendered with NO class at all: a bare grey UA button while the rest of the bar took the user's colour. Menu.Target clones its child and hands it a className of its own, and the trigger spread those cloned props after its own `className` attribute, so the clone replaced ours. It is merged now. This was mine, from extracting NavDropdownTrigger last commit -- and it also made the previous commit's "measured and drawn are the same component" claim only half true, because the hidden placeholder is not cloned and so kept its class. The bar still wrapped, for a reason the padding fix could not reach: the corner does not keep a constant width. The Cmd-K hint renders only once useKeyboardDetected has seen a keypress, so it appears at an arbitrary later moment and widens the corner by ~30px; the load, memory, temperature and drive warnings come and go with the machine's state. None of that resizes the container, which was the only thing observed -- so nothing recalculated. That is the other half of "at certain widths": the same viewport wrapped or not depending on whether the user had touched a key. The corner and the home link are observed too now. The search modal showed an input and the first line of the first group. The suggestion list is absolutely positioned, which is right everywhere else -- a list that reflows the page while you type is unusable -- but in a modal it fails twice: an absolute list adds no height, so the panel sized itself to the search box alone at 114px, and the panel's own `overflow: auto` then clipped the list at that edge. In the modal the list sits in flow; the inverse is asserted so the rule cannot leak to the pages where overlaying is correct. Two of the new tests were wrong first and reverting the fix left them green: they asserted hand-written markup carrying the classes I expected the components to have, rather than the real SearchIconButton and ShareButton. They use the real components now. Every fix was then planted against: 5 red for the More class, 2 for the search class, 2 for the corner hit area, 1 for the observer, 2 for the modal. 1115 jest / 62 suites, 196 in ui-layout.cy.js, clean npm run build. Confirmed live: share and search both pointer at 54.4px, More white on the bar colour with a transparent face, and the modal's list in flow and unclipped.
2026-08-02 14:45:49 -06:00
import {ShareButton} from '../Share';
ui: a browser layer for the library, and the .media reset that never applied The PathInput overlap could not have been caught by jest -- jsdom computes no layout -- so the only guard was a grep for one spelling of one mistake. This adds the layer that can actually see it, and it found a real bug immediately. ui-layout.cy.js mounts library components in a real browser through a new cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and nothing else. That spartan setup is the point: these components read no ambient state, so a spec can assert what jsdom cannot compute -- real geometry, resolved custom properties, applied filters -- across all four themes. It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it still overlaps, because a geometry check that has never gone red is indistinguishable from one that cannot fail. The bug it found: the rule resetting `filter` on leaf media inside a `.media` wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost every time and never applied to anything. Every image inside a filtered wrapper has been through the luminance matrix twice since that rule landed -- markedly darker than its surroundings, which is exactly what it was written to prevent. tokens.test.js asserted only that the rule's text was present, and so stayed green throughout; it now compares the two selectors' specificity, which is computable without a browser and goes red on the old selector. Three guards in ui.test.js keep the library mock-free by construction rather than by habit: no jest.mock in its own tests, no fetch in any library file, and no useContext outside the theme controls, whose job is to read the theme. All three were verified red against planted violations. 959 jest tests, 14 new browser tests, clean cache-busted build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
ui: let a landscape poster fill a one-column card, and fix three scale-blind tests `--card-poster-max-height` is a fixed height, so it stops scaling with the card: held to 220px, a 16:9 thumbnail is 391px wide, and any card wider than that centred it with empty panel on both sides. That is every video card at one column -- a phone, or any window under about 456px of content width. The cap is now `max(var(--card-poster-max-height), 56.25cqw)` with the poster band as the query container. 56.25cqw is nine sixteenths of the card: exactly the height of a 16:9 image that fills the width, and the same number states the rule for every other ratio -- a poster may be as tall as a 16:9 slice of this card and no taller. So a portrait book cover still reads as a band rather than a column, and now grows with the card instead of stopping at 220px. `max()` rather than `min()` so the floor wins on a narrow card. The gap pre-dated the interface scale, below about 414px, but the scale widened the range it shows in: the track minimum went from 200px to 220px, so one column now starts at 456px of content width instead of 414. Every existing poster case mounted a 233px card, which is why the wide card's own failure went unseen for the whole migration. Two cases added on a 451px card: a landscape poster reaches the edges, and a portrait cover stays a band. Three tests carried a hardcoded px expectation, which is a hidden assertion that the interface scale is 1. All three failed at 1.1, in names that said nothing about size -- and I did not catch them because I ran jest and the build for the scale change but not cypress, which AGENTS.md asks for on frontend work: - `cardPosterCap()` read `--card-poster-max-height` with parseFloat. The cap is rem now, so it returned 12.5 and failed a within(80, 240) bound -- taking five poster tests with it. It resolves through the root font-size and checks the unit. - `inNarrowColumn` was a fixed 340px, chosen to hold two 150px statistic tracks. At 165px tracks it became one column, so a test about the gap BETWEEN columns had no second column. It is now 340px times the scale, because "narrow" means narrow relative to the type. - The APIButton size test asserted 36px for `small`. It now measures against a real `sm` button, which is the claim it was making -- that `small` resolves to `sm` -- and holds at any scale. A `uiScale()` helper reads the token so no further test has to name a pixel count. Verified: ui-layout 248 passing, 0 failing; 1141 jest tests / 65 suites; clean build; browser-checked at 400/451/500/700/1200px of grid width, no side gap at any of them. The 12 remaining component failures are the pre-existing Semantic-era selector failures in Tags, Channels, Download and Inventory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:02:15 -06:00
/*
* The interface scale, so a test can express a length the way the stylesheet does.
*
* A hardcoded px expectation is a hidden assertion that the scale is 1. Three tests here
* carried one -- a container width, a poster cap and a button height -- and all three failed
* when it became 1.1, in names that said nothing about size.
*/
const uiScale = () => {
const value = parseFloat(getComputedStyle(document.documentElement)
.getPropertyValue('--ui-scale'));
expect(value, 'the interface scale is declared').to.be.within(0.5, 3);
return value;
};
review: close the mixed-unit gaps the scale left behind Seven review comments, all valid. The common thread is the one the guard was supposed to catch and did not: geometry converted to rem beside geometry that stayed px. The guard was narrower than its name. It missed: - `transform`, `flex` and `flex-basis`, so `translateX(26px)` and `flex: 1 1 200px` were invisible on properties nobody thought to list; - every NEGATIVE length, because the lookbehind treated the minus sign as part of the preceding token -- `left: -7px` and `margin-top: -2.5px` position the eyelet on a tag whose diamond HAD been converted, and `right: -3px` / `bottom: -3px` place the corner badge on a converted icon. Each is a piece of geometry that stopped tracking the piece it belongs to. With both fixed it found nine values, including one no comment mentioned (`flex: 1 1 200px`). All nine converted, except the three in a dead `.toggle` / `.slider` block: nothing has referenced those classes since Toggle became a Mantine Switch, and it was ALREADY broken -- track and knob in rem, travel still `translateX(26px)`, so the thumb stopped ~4px short of a 54px track. Dead CSS that is also wrong is a trap for whoever revives it, so it is deleted. The tag eyelet is centred with `translateY(-50%)` rather than a negative margin of half its own height, so the two pieces cannot drift again whatever the scale. Also from the review: - A runtime check, which is what the source guards were missing. Three cases in ui-layout.cy.js measure the real thing: the root font-size is the declared multiple of 16, our text AND a Mantine control both grow by the same factor when the scale changes, and a hairline does not. The second is the one that catches `theme.scale` being set and silently cancelling the root. - `max-height: max(..., 56.25cqw)` now follows a plain rem declaration. An engine without container query units throws out the whole declaration, which would have left the poster with NO cap -- a portrait cover standing as tall as the card is wide. Older engines clamp; newer ones take the second. - `pxToRem` in components/ui/scale.ts, replacing the `/ 16` written out in CardGroup and Placeholder. - The map overlays: 20 values across the layer panel, add-pin dialog, search panel and context menu, whose type had grown 10% while their padding had not. Left in px on purpose: the context menu's `left`/`top` (a real click coordinate), maplibre's own `ScaleControl` maxWidth, and the `calc(100% - 100px)` reserve for maplibre's px-sized controls. The `100vh - 120px` reserve DID become rem, since the chrome it reserves for is ours. - The keyboard-shortcuts spec no longer deletes `.mantine-Notifications-root` from the DOM. The reviewer was right that it is brittle; the endpoints are mocked instead, now that the probe named them: `/api/tag`, `/api/events/feed`, `/api/files/search` and `/api/files/worker_status`. Two of those were already "mocked" as `/api/tags` and `/api/events`, which nothing calls -- the wrong paths were the reason a toast appeared at all. Verified under CI's condition (`forceNetworkError` on everything unmocked): 12 passing with no DOM surgery. What is NOT done, deliberately: about 176 numeric geometry values remain in 23 feature files. The map overlays were the visible ones. Sweeping the rest is a change to 23 files nobody has reviewed, so instead the guard's name now says "in our stylesheets" rather than implying the whole app, and a new ratchet keeps numeric geometry out of the component library so the eleventh inline `gap: 10` cannot be added there. Both new guards planted against. Verified: 1142 jest / 65 suites, 251 ui-layout + 10 modal-stack component tests, all 50 e2e specs, clean build, map overlays measured to track the scale (panel minWidth 200 -> 220, search 320 -> 352) and screenshotted.
2026-08-03 19:37:25 -06:00
describe('the interface scale actually reaches what it is supposed to', () => {
/*
* Every other check on the scale reads source text, which proves a declaration says `rem`
* and nothing about whether the browser then paints a larger control. This is the one
* that measures, and it is the reason the source guards are worth trusting: it fails if
* `--ui-scale` stops being applied to the root, if Mantine's `theme.scale` is set and
* cancels it, or if a rule someone adds later pins a px size over the top.
*/
/*
* The root of the application-under-test, not the runner's. Cypress mounts the
* component in an iframe and loads the stylesheets there, so `window.top` reads the
* runner's own document -- where `--ui-scale` is not declared, so it came back NaN.
* `Cypress.$` is scoped to the AUT.
*/
const root = () => Cypress.$('html')[0];
it('makes the root font-size the declared multiple of the browser default', () => {
cy.mountUI(<Button>Save</Button>);
cy.get('.mantine-Button-root').should(() => {
const scale = parseFloat(getComputedStyle(root()).getPropertyValue('--ui-scale'));
expect(scale, 'the scale is declared').to.be.within(0.5, 3);
// 16px is the browser default the percentage resolves against.
expect(parseFloat(getComputedStyle(root()).fontSize), 'root font-size')
.to.be.closeTo(16 * scale, 0.5);
});
});
it('grows a Mantine control and our own text together when the scale changes', () => {
/*
* Both halves in one measurement, because the failure that matters is them
* DISAGREEING: Mantine's sizes are `calc(Xrem * var(--mantine-scale))` and ours are
* plain rem, so a `theme.scale` of 1.1 alongside a 110% root would leave Mantine's
* buttons at the old size beside 10% larger card text.
*/
cy.mountUI(<Card title='Rainwater Harvesting' meta='engineering775.com'/>);
/*
* DOUBLE whatever the scale currently is, rather than setting it to 2. Setting the
* literal gave a ratio of 1.818 -- 2 divided by the 1.1 already in effect -- so the
* first version of this failed against a perfectly working scale.
*/
const doubled = () => {
const current = parseFloat(getComputedStyle(root()).getPropertyValue('--ui-scale'));
root().style.setProperty('--ui-scale', String(current * 2));
};
cy.get('.wrolpi-card-title').should(($title) => {
const before = parseFloat(getComputedStyle($title[0]).fontSize);
expect(before, 'the card title has a size to grow from').to.be.greaterThan(1);
doubled();
const after = parseFloat(getComputedStyle($title[0]).fontSize);
root().style.removeProperty('--ui-scale');
// A px declaration would not have moved at all.
expect(after / before, 'our own text tracks the scale').to.be.closeTo(2, 0.05);
});
cy.mountUI(<Button>Save</Button>);
cy.get('.mantine-Button-root').should(($button) => {
const before = $button[0].getBoundingClientRect().height;
doubled();
const after = $button[0].getBoundingClientRect().height;
root().style.removeProperty('--ui-scale');
expect(after / before, "Mantine's controls track it too, by the same factor")
.to.be.closeTo(2, 0.05);
});
});
it('leaves a hairline a hairline at any scale', () => {
// The inverse, and the whole reason rem was chosen over `zoom`.
cy.mountUI(<Panel>Structure</Panel>);
cy.get('.wrolpi-panel').should(($panel) => {
const before = parseFloat(getComputedStyle($panel[0]).borderTopWidth);
root().style.setProperty('--ui-scale', '2');
const after = parseFloat(getComputedStyle($panel[0]).borderTopWidth);
root().style.removeProperty('--ui-scale');
expect(before, 'the panel has a hairline border').to.be.within(0.5, 2);
expect(after, 'and it does not grow with the type').to.be.closeTo(before, 0.05);
});
});
});
ui: pages own the space between their blocks Panels shared edges: two 1px borders meeting, which reads as one tall surface with a rule across it rather than a seam between two. Done as `margin-bottom` on the panel first, which is the anti-pattern, and it failed in both of the ways that rule is known to fail before the reading was done. It compounded with the gap of every Stack that already held panels -- four of them, spacing those lists at 35.2px against the app's 17.6px -- and the `:last-child` reset meant to keep trailing space off the bottom of a container silently did nothing, because Media wrapping makes a panel the only child of its own wrapper. On Status that separated four pairs out of five and left the first touching. So the space belongs to whatever stacks the blocks. `.wrolpi-stack` is on PageContainer, which every page uses, and on the three wrappers that stack blocks somewhere the page's own stack cannot reach: Settings' panel wrapper, the block below the video player, and the Zim and Map route wrappers, which hold their tab bar outside PageContainer. A gap rather than `> * + * { margin-top }`, which was tried and is quietly broken here: Media injects `.fresnel-container { margin: 0; padding: 0 }` at runtime, same specificity, later source order, so every wrapped block threw the margin away. A child cannot zero its parent's gap. It also means Media's hidden half contributes nothing, where the owl selector spaced around something invisible. With the page owning the spacing, the blocks that owned some of it had to give it up, or their margin was added to the gap: the tab bar (33px against 17.6 everywhere else), the shared search control bar and paginator on Videos/Archives/Docs/Files, the card grid, the file browser's filter row and the inventory search. Two margins deliberately stay -- the file browser's 4em, which reserves room for the sticky buttons (62645831), and heading margins, which bind a heading to the content below it. Tests plant each of the three failures: the wrapped block, a child that zeroes its own margin, and a hidden Media half. Verified in the browser on sixteen routes and in all four themes -- every stacked pair 17.6px, the map's 85vh box and the video player unchanged, no horizontal overflow. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 15:40:27 -06:00
describe('a page stacks its own blocks', () => {
/*
* A page is built out of panels -- the dashboard is five, Status is six, Settings is six --
* and nothing put space between them, so every pair shared an edge. Two 1px borders meeting
* do not read as a seam between two surfaces; they read as one tall surface with a rule across
* it, and which heading owns which content stops being obvious.
*
* The space is the page's, not the panel's. How far a panel sits from its neighbour is a
* property of the two of them being stacked, and the same panel also appears inside modals,
* grids and Mantine `Stack`s that space it themselves. This was tried the other way first, as
* `margin-bottom` on `.wrolpi-panel`, and it failed in both of the ways that rule is known to
* fail -- see the sibling test below, which is what stops it being tried again.
*/
const gapsBetween = ($panels) => {
const rects = [...$panels].map((el) => el.getBoundingClientRect());
return rects.slice(1).map((rect, index) => rect.top - rects[index].bottom);
};
it('leaves a gap between the panels it stacks', () => {
cy.mountUI(<div className='wrolpi-stack'>
<Panel>Tags</Panel>
<Panel>Status</Panel>
<Panel>Calculators</Panel>
</div>);
review: finish the sweep the first pass claimed The review was right that completeness was not done. Every finding held up. Three more pages mounted a `PageContainer` inside a route that already provides page chrome -- `ManageMap`, `MapPins`, `ManageZim` -- so they sat a further 1em down and 1em in from the tab bar than the viewers beside them. The same defect as ArchiveSettings, in a shape the scan could not see: it keyed on `PageContainer` route wrappers, and Map and Zim wrap their content in a `wrolpi-stack` div instead. It now locates routers first and asks whether the enclosing return provides chrome either way, resolves `element={<ErrorBoundary><Page/></ErrorBoundary>}` as well as the bare form, and knows about `class` components -- `ManageZim` is one, and a scan that only knew functions reported it clean. Five top-level blocks still added their own margin to the stack's gap: the dashboard search row (52.8px against 17.6px, on the most-looked-at page in the app), the Playlists filter row, both Docs filter rows, and the Map pins filter. The extension page's hint panel had the same compound against a Mantine Stack's gap. ControllerPage held its four panel sections in a plain wrapper, so the admin page's stack saw one child and the panels kept sharing edges -- the exact hole Settings had. The dashboard was reported clean in the first pass and was not. The sweep measured wrapper-to-wrapper gaps, and that row's margin is INSIDE a Media wrapper, so it never appeared: the measurement, not the page, was at fault. Cypress gap assertions now derive from the stack's own `row-gap` instead of a 12-28px range that assumed the default interface scale and would have false-failed a correct layout at a larger one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 16:09:12 -06:00
cy.get('.wrolpi-stack').should(($stack) => {
/*
* Measured against the stack's own `row-gap` rather than a pixel range. The range was
* 12-28px, which assumes the default `--ui-scale`: at a larger scale the gap grows past
* 28 and a correct layout would have failed the assertion. A separate test covers the
* ratio; this one is about the panels really being that far apart.
*/
const declared = parseFloat(getComputedStyle($stack[0]).rowGap);
expect(declared, 'the stack declares a gap').to.be.greaterThan(0);
const gaps = gapsBetween($stack[0].querySelectorAll('.wrolpi-panel'));
ui: pages own the space between their blocks Panels shared edges: two 1px borders meeting, which reads as one tall surface with a rule across it rather than a seam between two. Done as `margin-bottom` on the panel first, which is the anti-pattern, and it failed in both of the ways that rule is known to fail before the reading was done. It compounded with the gap of every Stack that already held panels -- four of them, spacing those lists at 35.2px against the app's 17.6px -- and the `:last-child` reset meant to keep trailing space off the bottom of a container silently did nothing, because Media wrapping makes a panel the only child of its own wrapper. On Status that separated four pairs out of five and left the first touching. So the space belongs to whatever stacks the blocks. `.wrolpi-stack` is on PageContainer, which every page uses, and on the three wrappers that stack blocks somewhere the page's own stack cannot reach: Settings' panel wrapper, the block below the video player, and the Zim and Map route wrappers, which hold their tab bar outside PageContainer. A gap rather than `> * + * { margin-top }`, which was tried and is quietly broken here: Media injects `.fresnel-container { margin: 0; padding: 0 }` at runtime, same specificity, later source order, so every wrapped block threw the margin away. A child cannot zero its parent's gap. It also means Media's hidden half contributes nothing, where the owl selector spaced around something invisible. With the page owning the spacing, the blocks that owned some of it had to give it up, or their margin was added to the gap: the tab bar (33px against 17.6 everywhere else), the shared search control bar and paginator on Videos/Archives/Docs/Files, the card grid, the file browser's filter row and the inventory search. Two margins deliberately stay -- the file browser's 4em, which reserves room for the sticky buttons (62645831), and heading margins, which bind a heading to the content below it. Tests plant each of the three failures: the wrapped block, a child that zeroes its own margin, and a hidden Media half. Verified in the browser on sixteen routes and in all four themes -- every stacked pair 17.6px, the map's 85vh box and the video player unchanged, no horizontal overflow. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 15:40:27 -06:00
expect(gaps, 'both pairs measured').to.have.length(2);
review: finish the sweep the first pass claimed The review was right that completeness was not done. Every finding held up. Three more pages mounted a `PageContainer` inside a route that already provides page chrome -- `ManageMap`, `MapPins`, `ManageZim` -- so they sat a further 1em down and 1em in from the tab bar than the viewers beside them. The same defect as ArchiveSettings, in a shape the scan could not see: it keyed on `PageContainer` route wrappers, and Map and Zim wrap their content in a `wrolpi-stack` div instead. It now locates routers first and asks whether the enclosing return provides chrome either way, resolves `element={<ErrorBoundary><Page/></ErrorBoundary>}` as well as the bare form, and knows about `class` components -- `ManageZim` is one, and a scan that only knew functions reported it clean. Five top-level blocks still added their own margin to the stack's gap: the dashboard search row (52.8px against 17.6px, on the most-looked-at page in the app), the Playlists filter row, both Docs filter rows, and the Map pins filter. The extension page's hint panel had the same compound against a Mantine Stack's gap. ControllerPage held its four panel sections in a plain wrapper, so the admin page's stack saw one child and the panels kept sharing edges -- the exact hole Settings had. The dashboard was reported clean in the first pass and was not. The sweep measured wrapper-to-wrapper gaps, and that row's margin is INSIDE a Media wrapper, so it never appeared: the measurement, not the page, was at fault. Cypress gap assertions now derive from the stack's own `row-gap` instead of a 12-28px range that assumed the default interface scale and would have false-failed a correct layout at a larger one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 16:09:12 -06:00
gaps.forEach((gap) => expect(gap, 'gap between panels').to.be.closeTo(declared, 0.5));
ui: pages own the space between their blocks Panels shared edges: two 1px borders meeting, which reads as one tall surface with a rule across it rather than a seam between two. Done as `margin-bottom` on the panel first, which is the anti-pattern, and it failed in both of the ways that rule is known to fail before the reading was done. It compounded with the gap of every Stack that already held panels -- four of them, spacing those lists at 35.2px against the app's 17.6px -- and the `:last-child` reset meant to keep trailing space off the bottom of a container silently did nothing, because Media wrapping makes a panel the only child of its own wrapper. On Status that separated four pairs out of five and left the first touching. So the space belongs to whatever stacks the blocks. `.wrolpi-stack` is on PageContainer, which every page uses, and on the three wrappers that stack blocks somewhere the page's own stack cannot reach: Settings' panel wrapper, the block below the video player, and the Zim and Map route wrappers, which hold their tab bar outside PageContainer. A gap rather than `> * + * { margin-top }`, which was tried and is quietly broken here: Media injects `.fresnel-container { margin: 0; padding: 0 }` at runtime, same specificity, later source order, so every wrapped block threw the margin away. A child cannot zero its parent's gap. It also means Media's hidden half contributes nothing, where the owl selector spaced around something invisible. With the page owning the spacing, the blocks that owned some of it had to give it up, or their margin was added to the gap: the tab bar (33px against 17.6 everywhere else), the shared search control bar and paginator on Videos/Archives/Docs/Files, the card grid, the file browser's filter row and the inventory search. Two margins deliberately stay -- the file browser's 4em, which reserves room for the sticky buttons (62645831), and heading margins, which bind a heading to the content below it. Tests plant each of the three failures: the wrapped block, a child that zeroes its own margin, and a hidden Media half. Verified in the browser on sixteen routes and in all four themes -- every stacked pair 17.6px, the map's 85vh box and the video player unchanged, no horizontal overflow. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 15:40:27 -06:00
});
});
it('spaces a block that is wrapped as readily as a bare one', () => {
/*
* This is the case that chose where the rule lives. Several pages put a panel inside the
* responsive `Media` component, so the page's child is a wrapper rather than the panel.
*
* Spacing from the page handles that for free -- it spaces the wrapper, and the wrapper is
* the sibling. A `margin-bottom` on the panel plus the `:last-child` reset that would
* keep the trailing space off the bottom of a container does NOT: the panel is the only
* child of its wrapper, so `:last-child` matches it, zeroes the margin, and leaves it hard
* against the next panel. On Status that separated four pairs out of five and left the
* first touching -- one page showing both, which reads as a rendering glitch.
*/
cy.mountUI(<div className='wrolpi-stack'>
<div><Panel>Wrapped, as Media does it</Panel></div>
<Panel>Bare</Panel>
</div>);
cy.get('.wrolpi-panel').should(($panels) =>
expect(gapsBetween($panels)[0], 'gap across a wrapper').to.be.at.least(12));
});
it('survives a block that zeroes its own margin', () => {
/*
* The reason this is a gap and not `> * + * { margin-top }`. The responsive `Media`
* component injects `.fresnel-container { margin: 0; padding: 0 }` into the document at
* runtime -- same specificity as the owl selector, later in source order -- so a wrapped
* block threw the margin away and went on touching its neighbour, while the bare blocks
* on the same page separated. A gap is the parent's, and a child cannot zero it.
*
* The margin here stands in for fresnel's rule; the point is that the spacing does not
* depend on the child's own margin being left alone.
*/
cy.mountUI(<div className='wrolpi-stack'>
<Panel>Before</Panel>
<div style={{margin: 0}}><Panel>Zeroed its own margin</Panel></div>
</div>);
cy.get('.wrolpi-panel').should(($panels) =>
expect(gapsBetween($panels)[0], 'gap despite the child margin').to.be.at.least(12));
});
it('adds nothing before the first block or after the last', () => {
// A gap goes only between, so the page's own padding decides its edges.
cy.mountUI(<div className='wrolpi-stack'>
<Panel>First</Panel>
<Panel>Last</Panel>
</div>);
cy.get('.wrolpi-stack').should(($stack) => {
const stack = $stack[0].getBoundingClientRect();
const panels = [...$stack[0].querySelectorAll('.wrolpi-panel')]
.map(el => el.getBoundingClientRect());
expect(panels[0].top - stack.top, 'above the first').to.be.closeTo(0, 0.5);
expect(stack.bottom - panels[1].bottom, 'below the last').to.be.closeTo(0, 0.5);
});
});
it('grows the gap with the interface scale', () => {
// In px it would hold still while the panels either side of it grew.
cy.mountUI(<div className='wrolpi-stack'>
<Panel>One</Panel>
<Panel>Two</Panel>
</div>);
cy.get('.wrolpi-stack').should(($stack) => {
const before = parseFloat(getComputedStyle($stack[0]).rowGap);
const root = Cypress.$('html')[0];
const scale = parseFloat(getComputedStyle(root).getPropertyValue('--ui-scale')) || 1;
root.style.setProperty('--ui-scale', String(scale * 2));
const after = parseFloat(getComputedStyle($stack[0]).rowGap);
root.style.removeProperty('--ui-scale');
expect(before, 'the gap exists at all').to.be.greaterThan(0);
expect(after / before, 'and doubles with the scale').to.be.closeTo(2, 0.05);
});
});
it('contributes no gap for the half of a Media pair that is hidden', () => {
/*
* `Media` renders both viewports and hides one with `display: none`. A hidden flex item
* is not a flex item at all, so it takes no gap -- where `* + *` would have put space
* around something invisible and left a page with a stray 1rem hole in it.
*/
cy.mountUI(<div className='wrolpi-stack'>
<Panel>Shown</Panel>
<div style={{display: 'none'}}><Panel>The other viewport</Panel></div>
<Panel>Also shown</Panel>
</div>);
review: finish the sweep the first pass claimed The review was right that completeness was not done. Every finding held up. Three more pages mounted a `PageContainer` inside a route that already provides page chrome -- `ManageMap`, `MapPins`, `ManageZim` -- so they sat a further 1em down and 1em in from the tab bar than the viewers beside them. The same defect as ArchiveSettings, in a shape the scan could not see: it keyed on `PageContainer` route wrappers, and Map and Zim wrap their content in a `wrolpi-stack` div instead. It now locates routers first and asks whether the enclosing return provides chrome either way, resolves `element={<ErrorBoundary><Page/></ErrorBoundary>}` as well as the bare form, and knows about `class` components -- `ManageZim` is one, and a scan that only knew functions reported it clean. Five top-level blocks still added their own margin to the stack's gap: the dashboard search row (52.8px against 17.6px, on the most-looked-at page in the app), the Playlists filter row, both Docs filter rows, and the Map pins filter. The extension page's hint panel had the same compound against a Mantine Stack's gap. ControllerPage held its four panel sections in a plain wrapper, so the admin page's stack saw one child and the panels kept sharing edges -- the exact hole Settings had. The dashboard was reported clean in the first pass and was not. The sweep measured wrapper-to-wrapper gaps, and that row's margin is INSIDE a Media wrapper, so it never appeared: the measurement, not the page, was at fault. Cypress gap assertions now derive from the stack's own `row-gap` instead of a 12-28px range that assumed the default interface scale and would have false-failed a correct layout at a larger one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 16:09:12 -06:00
// One gap, not two: measured against the declared gap rather than a pixel ceiling, which
// would have false-failed at a larger interface scale instead of catching a doubled gap.
cy.get('.wrolpi-stack').should(($stack) => {
const declared = parseFloat(getComputedStyle($stack[0]).rowGap);
const shown = $stack[0].querySelectorAll('.wrolpi-panel:not([style*="none"])');
const visible = [...shown].filter((el) => el.offsetParent !== null);
expect(visible, 'the hidden panel is not measured').to.have.length(2);
expect(gapsBetween(visible)[0], 'one gap, not two').to.be.closeTo(declared, 0.5);
ui: pages own the space between their blocks Panels shared edges: two 1px borders meeting, which reads as one tall surface with a rule across it rather than a seam between two. Done as `margin-bottom` on the panel first, which is the anti-pattern, and it failed in both of the ways that rule is known to fail before the reading was done. It compounded with the gap of every Stack that already held panels -- four of them, spacing those lists at 35.2px against the app's 17.6px -- and the `:last-child` reset meant to keep trailing space off the bottom of a container silently did nothing, because Media wrapping makes a panel the only child of its own wrapper. On Status that separated four pairs out of five and left the first touching. So the space belongs to whatever stacks the blocks. `.wrolpi-stack` is on PageContainer, which every page uses, and on the three wrappers that stack blocks somewhere the page's own stack cannot reach: Settings' panel wrapper, the block below the video player, and the Zim and Map route wrappers, which hold their tab bar outside PageContainer. A gap rather than `> * + * { margin-top }`, which was tried and is quietly broken here: Media injects `.fresnel-container { margin: 0; padding: 0 }` at runtime, same specificity, later source order, so every wrapped block threw the margin away. A child cannot zero its parent's gap. It also means Media's hidden half contributes nothing, where the owl selector spaced around something invisible. With the page owning the spacing, the blocks that owned some of it had to give it up, or their margin was added to the gap: the tab bar (33px against 17.6 everywhere else), the shared search control bar and paginator on Videos/Archives/Docs/Files, the card grid, the file browser's filter row and the inventory search. Two margins deliberately stay -- the file browser's 4em, which reserves room for the sticky buttons (62645831), and heading margins, which bind a heading to the content below it. Tests plant each of the three failures: the wrapped block, a child that zeroes its own margin, and a hidden Media half. Verified in the browser on sixteen routes and in all four themes -- every stacked pair 17.6px, the map's 85vh box and the video player unchanged, no horizontal overflow. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 15:40:27 -06:00
});
});
it('leaves a panel with no outer margin, so a Stack can space it instead', () => {
/*
* The inverse rule, and the reason it is worth its own test: the moment a panel carries
* its own margin, it adds to the spacing of every container that already spaces its
* children. Four `Stack`s in the app hold nothing but panels -- the conflict list, both
* halves of the one-time pad, the electrical calculators -- and with `margin-bottom` on
* the panel they spaced those lists at 35.2px against the 17.6px used everywhere else.
*/
cy.mountUI(<Panel>Composable</Panel>);
cy.get('.wrolpi-panel').should(($panel) => {
const styles = getComputedStyle($panel[0]);
['marginTop', 'marginRight', 'marginBottom', 'marginLeft'].forEach((side) => {
expect(parseFloat(styles[side]), side).to.equal(0);
});
});
});
});
ui: a row of buttons is spaced by the row The archive page's six actions shared edges, and Update sat lower than the rest. Both come from the same thing: Semantic's Button carried `margin: 0 .25em .25em 0`, so a page could list buttons as bare siblings and they arrived spaced -- and separated from the line below when the row wrapped. Nothing replaced that margin. Two of those six answered with `marginTop: 0.5em`, which is the wrong axis: a Button is `display: inline-flex; vertical-align: middle`, and `vertical-align` is measured on the MARGIN box, so half of any top margin shows up as the visible button dropping. It was covering the wrapped-row case in the only axis a margin can, and paying for it in the other one. `.wrolpi-button-row` is a flex row with a gap, so both axes are covered at once and no button needs a margin of its own -- the same rule as `.wrolpi-stack`, along the other axis. Applied to the five rows in the app that had no gap: the archive page, the shared collection edit form (which three pages hand action buttons to, and where nine buttons plus Cancel carried `margin-top: 1em` each while Save carried none), the doc page's two responsive branches, and the downloads table's edit/restart pair. `.action-button-spacing` goes with them; it was that same margin, on Cancel. Guarded four ways. ui-layout.cy.js measures that the row really spaces what it holds, wraps rather than overflows, centres its buttons against a taller item beside them, and counts a confirmed APIButton as one item rather than two -- that one returns a fragment holding a `<Confirm/>`, which would open a hole in the row if it did not portal. Common.test.js scans for the two ways this comes back: a button in a row stamping a vertical margin, and a row of buttons that is not a row. Neither throws, which is how the app got here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 16:39:03 -06:00
describe('a row of buttons is spaced and aligned by the row', () => {
/*
* Semantic's Button carried `margin: 0 .25em .25em 0` of its own, so a page could list
* buttons as bare siblings and they arrived spaced. Nothing replaced that margin, and
* five pages still list them that way -- the archive page's six actions all shared edges.
*
* Two of those six also carried `marginTop: 0.5em`, which is what made "Update" sit lower
* than its neighbours: a Button is `display: inline-flex; vertical-align: middle`, and
* `vertical-align` aligns the MARGIN box, so half of any top margin pushes the visible
* button down. The margin was there to keep a wrapped row from touching vertically --
* the right thing, solved in the wrong axis. A flex row with `gap` covers both axes and
* needs no per-button margin, so the alignment comes back for free.
*/
const rowButtons = ($row) => [...$row[0].querySelectorAll('button')];
it('puts a gap between the buttons, horizontally and when wrapped', () => {
cy.mountUI(<div className='wrolpi-button-row'>
<Button>View</Button>
<Button>Read</Button>
<Button>Update</Button>
</div>);
cy.get('.wrolpi-button-row').should(($row) => {
const row = $row[0];
const styles = getComputedStyle(row);
const declared = parseFloat(styles.columnGap);
expect(declared, 'the row declares a gap').to.be.greaterThan(0);
expect(parseFloat(styles.rowGap), 'and the same one between wrapped lines')
.to.be.closeTo(declared, 0.5);
expect(styles.flexWrap, 'the row wraps rather than overflowing').to.equal('wrap');
/*
* Narrowed to exactly two buttons' worth, measured rather than guessed. A hardcoded
* 150px was a hidden assertion about both the font and the interface scale, and at 1.1
* it fitted one button, not the two the assertions below are about.
*/
const widths = rowButtons($row).map(el => el.getBoundingClientRect().width);
expect(widths, 'three buttons measured').to.have.length(3);
row.style.width = `${widths[0] + declared + widths[1] + 1}px`;
const rects = rowButtons($row).map(el => el.getBoundingClientRect());
const top = Math.min(...rects.map(rect => rect.top));
const first = rects.filter(rect => Math.round(rect.top) === Math.round(top));
expect(first, 'two buttons on the first line').to.have.length(2);
expect(first[1].left - first[0].right, 'gap along the line').to.be.closeTo(declared, 0.5);
// And the third dropped to a second line, held off the first by the same gap.
const wrapped = rects.find(rect => Math.round(rect.top) !== Math.round(top));
expect(wrapped, 'the third button wrapped').to.not.be.undefined;
expect(wrapped.top - first[0].bottom, 'gap between the lines')
.to.be.closeTo(declared, 0.5);
});
});
it('centres its buttons against a taller item beside them', () => {
/*
* A row is not always all buttons: the doc page puts its format picker beside its actions,
* and the downloads table an error trigger beside its two icon buttons. Whatever is
* tallest sets the line height, and `align-items: center` is what keeps the buttons reading
* as part of that line rather than hanging from the top of it.
*
* Written as tops first, which was a test with no teeth -- `stretch` stretches the WRAPPER
* and leaves the button at the top of it, so the tops agreed either way. Centres are what
* the property actually decides.
*
* The row is also mixed in the way the archive page's is: a button inside an `<a>`, a bare
* one, and an APIButton.
*/
cy.mountUI(<div className='wrolpi-button-row'>
<div style={{height: '80px', width: '40px'}}>Tall</div>
<a href='/media/archive.html'><Button>View</Button></a>
<Button>Read</Button>
<APIButton onClick={() => Promise.resolve()}>Update</APIButton>
</div>);
cy.get('.wrolpi-button-row').should(($row) => {
const row = $row[0].getBoundingClientRect();
expect(row.height, 'the tall item set the line height').to.be.at.least(80);
const centers = rowButtons($row).map((el) => {
const rect = el.getBoundingClientRect();
return rect.top + rect.height / 2;
});
expect(centers, 'three buttons measured').to.have.length(3);
const middle = row.top + row.height / 2;
centers.forEach(center => expect(center, 'centred in the line').to.be.closeTo(middle, 1));
});
});
it('counts a confirmed action as one item in the row, not two', () => {
/*
* `APIButton` with `confirmContent` returns a fragment -- the button AND a `<Confirm/>`.
* In a flex row those flatten into siblings, so a Confirm that rendered anything in
* place would take a gap of its own and open a hole between two buttons. It portals,
* and this is what says so; three of the archive page's six actions are confirmed.
*/
cy.mountUI(<div className='wrolpi-button-row'>
<Button>Plain</Button>
<APIButton confirmContent='Sure?' onClick={() => Promise.resolve()}>Delete</APIButton>
<Button>Also plain</Button>
</div>);
cy.get('.wrolpi-button-row').should(($row) => {
const declared = parseFloat(getComputedStyle($row[0]).columnGap);
const rects = rowButtons($row).map(el => el.getBoundingClientRect());
expect(rects, 'three buttons measured').to.have.length(3);
rects.slice(1).forEach((rect, index) => expect(
rect.left - rects[index].right, 'gap either side of the confirmed action',
).to.be.closeTo(declared, 0.5));
});
});
it('keeps its buttons their own width inside a page stack', () => {
/*
* `.wrolpi-stack` is a flex column at `align-items: stretch`, which is what keeps a panel
* full-width as it was as a block element -- and which stretched every page's Back button
* to the full width of the page, because a bare button was a direct child of it.
*
* The row is what absorbs that: the ROW is the stretched child, and it lays its buttons out
* at their own width. Both halves are asserted, because a row that also refused to stretch
* would pass a test that only looked at the button.
*/
cy.mountUI(<div className='wrolpi-stack'>
<div className='wrolpi-button-row'><Button>Back</Button></div>
<Panel>The page</Panel>
</div>);
cy.get('.wrolpi-stack').should(($stack) => {
const stack = $stack[0].getBoundingClientRect();
const row = $stack[0].querySelector('.wrolpi-button-row').getBoundingClientRect();
const button = $stack[0].querySelector('button').getBoundingClientRect();
expect(stack.width, 'the stack has a width to fill').to.be.greaterThan(200);
expect(row.width, 'the row stretches, as the panel does').to.be.closeTo(stack.width, 0.5);
expect(button.width, 'the button does not').to.be.lessThan(stack.width / 2);
});
});
ui: a row of buttons is spaced by the row The archive page's six actions shared edges, and Update sat lower than the rest. Both come from the same thing: Semantic's Button carried `margin: 0 .25em .25em 0`, so a page could list buttons as bare siblings and they arrived spaced -- and separated from the line below when the row wrapped. Nothing replaced that margin. Two of those six answered with `marginTop: 0.5em`, which is the wrong axis: a Button is `display: inline-flex; vertical-align: middle`, and `vertical-align` is measured on the MARGIN box, so half of any top margin shows up as the visible button dropping. It was covering the wrapped-row case in the only axis a margin can, and paying for it in the other one. `.wrolpi-button-row` is a flex row with a gap, so both axes are covered at once and no button needs a margin of its own -- the same rule as `.wrolpi-stack`, along the other axis. Applied to the five rows in the app that had no gap: the archive page, the shared collection edit form (which three pages hand action buttons to, and where nine buttons plus Cancel carried `margin-top: 1em` each while Save carried none), the doc page's two responsive branches, and the downloads table's edit/restart pair. `.action-button-spacing` goes with them; it was that same margin, on Cancel. Guarded four ways. ui-layout.cy.js measures that the row really spaces what it holds, wraps rather than overflows, centres its buttons against a taller item beside them, and counts a confirmed APIButton as one item rather than two -- that one returns a fragment holding a `<Confirm/>`, which would open a hole in the row if it did not portal. Common.test.js scans for the two ways this comes back: a button in a row stamping a vertical margin, and a row of buttons that is not a row. Neither throws, which is how the app got here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 16:39:03 -06:00
it('grows its gap with the interface scale', () => {
cy.mountUI(<div className='wrolpi-button-row'><Button>One</Button><Button>Two</Button></div>);
cy.get('.wrolpi-button-row').should(($row) => {
const before = parseFloat(getComputedStyle($row[0]).columnGap);
const root = Cypress.$('html')[0];
const scale = parseFloat(getComputedStyle(root).getPropertyValue('--ui-scale')) || 1;
root.style.setProperty('--ui-scale', String(scale * 2));
const after = parseFloat(getComputedStyle($row[0]).columnGap);
root.style.removeProperty('--ui-scale');
expect(before, 'the gap exists at all').to.be.greaterThan(0);
expect(after / before, 'and doubles with the scale').to.be.closeTo(2, 0.05);
});
});
});
test: prove the toast contrast fix in a browser, and fix the harness that hid it The title contrast was verified by hand and by nothing else. jsdom cannot check it: it resolves no `var()`, so the title's colour there is the literal string `var(--mantine-color-white)` and every contrast assertion passes. Six browser tests now cover it -- title and description at WCAG AA in each of the four themes, the title staying heavier than the message where night and amber drop its muting, and the toast taking `--panel` for its surface. The three that can fail were checked against the fix removed: 1.13:1 in dark, night and amber. Light passes either way, correctly, because Mantine's light-scheme title uses `--mantine-color-black`, which the bridge maps to `--text`. Getting there took three corrections, all of them mine: * `cy.mountUI` never set `forceColorScheme`, so every theme rendered against Mantine's LIGHT scheme. Mantine keys its own rules on data-mantine-color-scheme, and ThemeProvider sets it from the theme -- night and amber ride on dark. Any per-theme test could therefore pass on a page that was broken in the app. This is the harness the tag contrast tests use too. * The support file never imported `@mantine/notifications/styles.css`, which App.js does, so a Notification rendered unstyled and had no surface or title colour of Mantine's to be wrong about. * The spec's own helper mounted a second time to raise the toast, which reset the theme to the default. All four per-theme cases ran in light. For the record, the chain the fix breaks: `.m_3feedf16` (the title) in dark scheme is `color: var(--mantine-color-white)`, the bridge aliases that to `--btn-text`, and `--btn-text` is the text drawn on a filled button -- near-black in dark, night and amber. Mantine writes it through `:where(...)`, which has zero specificity, so a single-class override plus `html` outranks it.
2026-08-01 15:07:48 -06:00
/* `--panel` is authored as a hex; computed backgrounds come back as rgb(). */
const hexToRgb = (hex) => {
const value = hex.replace('#', '');
const [r, g, b] = [0, 2, 4].map(i => parseInt(value.slice(i, i + 2), 16));
return `rgb(${r}, ${g}, ${b})`;
};
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>
2026-08-01 17:46:33 -06:00
/*
* Normalise a color to rgb(), and REFUSE anything that is neither a hex nor already
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>
2026-08-01 17:46:33 -06:00
* rgb(). Strictness is the point: feeding an unresolved `var(--blue)` to a luminance
* calculation yields NaN, and `expect(NaN).to.not.equal(x)` passes -- a test that cannot
* fail. Better to blow up naming the value than to quietly measure nothing.
*
* Tokens do resolve: `getPropertyValue('--info')` returns `#20629c` in light, because
* custom properties are substituted at computed-value time. This guards the day that
* stops being true on some engine, and catches the hex/rgb mismatch that is easy to hit
* when reading a Mantine variable rather than a painted property.
*/
const toRgb = (value) => {
const trimmed = String(value).trim();
if (/^rgba?\(/.test(trimmed)) return trimmed;
if (/^#[0-9a-fA-F]{6}$/.test(trimmed)) return hexToRgb(trimmed);
throw new Error(`Not a resolved color: "${trimmed}"`);
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>
2026-08-01 17:46:33 -06:00
};
ui: a browser layer for the library, and the .media reset that never applied The PathInput overlap could not have been caught by jest -- jsdom computes no layout -- so the only guard was a grep for one spelling of one mistake. This adds the layer that can actually see it, and it found a real bug immediately. ui-layout.cy.js mounts library components in a real browser through a new cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and nothing else. That spartan setup is the point: these components read no ambient state, so a spec can assert what jsdom cannot compute -- real geometry, resolved custom properties, applied filters -- across all four themes. It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it still overlaps, because a geometry check that has never gone red is indistinguishable from one that cannot fail. The bug it found: the rule resetting `filter` on leaf media inside a `.media` wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost every time and never applied to anything. Every image inside a filtered wrapper has been through the luminance matrix twice since that rule landed -- markedly darker than its surroundings, which is exactly what it was written to prevent. tokens.test.js asserted only that the rule's text was present, and so stayed green throughout; it now compares the two selectors' specificity, which is computable without a browser and goes red on the old selector. Three guards in ui.test.js keep the library mock-free by construction rather than by habit: no jest.mock in its own tests, no fetch in any library file, and no useContext outside the theme controls, whose job is to read the theme. All three were verified red against planted violations. 959 jest tests, 14 new browser tests, clean cache-busted build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
/*
* Layout and theming assertions for the component library, run in a real browser.
*
* These belong here rather than in ui.test.js because jsdom parses CSS but never lays it
* out: getBoundingClientRect() returns zeros, getComputedStyle() will not resolve a custom
* property through the cascade, and no filter is ever applied. A jest test therefore
* cannot tell whether two boxes overlap, whether a token resolved, or whether media got
* tinted -- which is precisely how five unreadable inputs reached the Settings page.
*
* Keep this file to claims that need real layout. Behaviour that jsdom can judge belongs
* in ui.test.js, which runs in about two seconds against the whole library.
*/
describe('PathInput lays its prefix beside the value, never over it', () => {
// Every theme, because a theme is free to restyle borders and padding, and the fix has
// to hold in all four rather than in whichever one happened to be open.
themeNames.forEach((theme) => {
it(`keeps the prefix clear of the input in ${theme}`, () => {
cy.mountUI(
<PathInput
label='Archive Destination'
prefix='/media/wrolpi'
defaultValue='archive/%(domain)s'
/>,
{theme},
);
cy.shouldNotOverlap('.wrolpi-path-input-prefix', '.wrolpi-path-input-control input');
// Sharing one outline is the reason the pair reads as a single control; a gap
// would mean the flex row broke and they are two separate fields again.
cy.get('.wrolpi-path-input-prefix').then(($prefix) => {
cy.get('.wrolpi-path-input-control input').then(($input) => {
const prefix = $prefix[0].getBoundingClientRect();
const input = $input[0].getBoundingClientRect();
expect(input.left - prefix.right, 'gap between prefix and input')
.to.be.closeTo(0, 2);
});
});
});
});
it('shows the whole value, with room left to type', () => {
cy.mountUI(
<PathInput prefix='/media/wrolpi' defaultValue='archive/%(domain)s'/>,
);
/*
* scrollWidth well beyond clientWidth means the value is cut off -- the visible
* symptom when a prefix eats the input's usable width. Both are rounded to whole
* pixels from a fractional layout, so they disagree by a pixel on a field that fits
* perfectly; the tolerance is for that, and is far below the tens of pixels a real
* clip costs.
*/
cy.get('.wrolpi-path-input-control input').should(($input) => {
const el = $input[0];
expect(el.scrollWidth, 'value is not clipped').to.be.at.most(el.clientWidth + 2);
expect(el.clientWidth, 'input has usable width').to.be.greaterThan(80);
});
});
ui: name the directory fields, announce their help text, let long prefixes shrink Greptile's three findings on #590, all confirmed real before fixing, and each one verified red against the original code afterwards. P1, the directory fields had no accessible names. All five rendered their visible label as a bare <label> with no htmlFor while passing no label prop, so their inputs had a description ("/media/wrolpi/") and no name at all -- five fields in one grid, holding similar relative paths, indistinguishable to a screen reader. The labels now belong to the inputs, InfoPopup content and all. This predates PathInput; the old TextInput call sites had the same gap, and moving to a component that supports labels is what made it fixable. P1, description and error were rendered but never referenced. aria-describedby pointed only at the prefix, so the help text listing the variables a path accepts, and the reason a path was rejected, were both invisible to assistive technology. Both are now in the description, and an errored field reports aria-invalid. P2 was worse than reported: at `flex: none` a long prefix took the entire row and left the input eighteen pixels wide -- not "consumes the editable area" but a field nobody can type in. The media directory is whatever the API reports, so its length was never ours to assume. The prefix now shrinks and ellipsises at half the control, with the full path on `title` and in the accessible description. The naming fault could not have been caught where the others were. jsdom cannot see layout, and the Settings page needs enough mocking that it had no test at all -- which is why these five fields were uncovered when they broke. The new e2e spec intercepts the API and lets the real page render, so it measures the names and the geometry a user actually gets. Reverting one field to a bare label fails it; a long prefix fails the browser spec at 18px. 962 jest, 15 browser component, 46 e2e, clean cache-busted build, tsc clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:46:54 -06:00
it('still leaves somewhere to type when the media directory is a long path', () => {
/*
* The prefix is whatever the API reports as the media directory, so its length is not
* ours to assume. It is `/media/wrolpi` on a Pi, but a development box or an unusual
* Docker mount can report something far longer, and a prefix that refuses to shrink
* would take the whole row and leave the input at zero width -- a field that cannot
* be typed into at all.
*/
cy.mountUI(
<div style={{width: 320}}>
<PathInput
label='Archive Destination'
prefix='/mnt/storage/external/wrolpi-media-library-volume/'
defaultValue='archive/%(domain)s'
/>
</div>,
);
cy.shouldNotOverlap('.wrolpi-path-input-prefix', '.wrolpi-path-input-control input');
cy.get('.wrolpi-path-input-control input').should(($input) =>
expect($input[0].clientWidth, 'input keeps a usable width').to.be.greaterThan(60));
// The control must not spill out of the column it was given either.
cy.get('.wrolpi-path-input-control').should(($control) =>
expect($control[0].getBoundingClientRect().width).to.be.at.most(320));
});
ui: a browser layer for the library, and the .media reset that never applied The PathInput overlap could not have been caught by jest -- jsdom computes no layout -- so the only guard was a grep for one spelling of one mistake. This adds the layer that can actually see it, and it found a real bug immediately. ui-layout.cy.js mounts library components in a real browser through a new cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and nothing else. That spartan setup is the point: these components read no ambient state, so a spec can assert what jsdom cannot compute -- real geometry, resolved custom properties, applied filters -- across all four themes. It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it still overlaps, because a geometry check that has never gone red is indistinguishable from one that cannot fail. The bug it found: the rule resetting `filter` on leaf media inside a `.media` wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost every time and never applied to anything. Every image inside a filtered wrapper has been through the luminance matrix twice since that rule landed -- markedly darker than its surroundings, which is exactly what it was written to prevent. tokens.test.js asserted only that the rule's text was present, and so stayed green throughout; it now compares the two selectors' specificity, which is computable without a browser and goes red on the old selector. Three guards in ui.test.js keep the library mock-free by construction rather than by habit: no jest.mock in its own tests, no fetch in any library file, and no useContext outside the theme controls, whose job is to read the theme. All three were verified red against planted violations. 959 jest tests, 14 new browser tests, clean cache-busted build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
it('detects the overlap that started this, so the check has teeth', () => {
/*
* The original defect, reproduced deliberately: Mantine turns leftSectionWidth into
* --input-padding-inline-start, and `padding-inline-start: auto` is invalid, so it
* resolves to zero and the absolutely-positioned section prints over the value.
*
* Asserting that this DOES overlap proves shouldNotOverlap is measuring something
* real. A geometry check that has never once gone red is indistinguishable from a
* check that cannot fail.
*/
cy.mountUI(
<TextInput
leftSectionWidth='auto'
leftSection={<span className='probe-section'>/media/wrolpi</span>}
defaultValue='archive/%(domain)s'
/>,
);
cy.get('.probe-section').then(($section) => {
cy.get('input').then(($input) => {
const section = $section[0].getBoundingClientRect();
const input = $input[0].getBoundingClientRect();
expect(
section.right > input.left + 0.5,
'the historical bug still overlaps, so the geometry check is meaningful',
).to.equal(true);
});
});
});
});
describe('ActionInput', () => {
it('joins its button to the field without covering it', () => {
cy.mountUI(
<ActionInput
defaultValue='https://example.com'
action={<Button>Fetch</Button>}
/>,
);
cy.shouldNotOverlap('.wrolpi-action-input input', '.wrolpi-action-input button');
});
});
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
/* WCAG contrast between two rgb() strings, for judging how loud a border is. */
const luminance = (color) => {
const [r, g, b] = (color.match(/[\d.]+/g) || []).map(Number);
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
const channel = (v) => {
const s = v / 255;
return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
};
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
};
const contrast = (a, b) => {
const [x, y] = [luminance(a), luminance(b)].sort((p, q) => q - p);
return (x + 0.05) / (y + 0.05);
};
const sampleTable = <Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>URL</Table.HeaderCell>
<Table.HeaderCell>Size</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row><Table.Cell>one</Table.Cell><Table.Cell>1 kB</Table.Cell></Table.Row>
<Table.Row><Table.Cell>two</Table.Cell><Table.Cell>2 kB</Table.Cell></Table.Row>
<Table.Row><Table.Cell>three</Table.Cell><Table.Cell>3 kB</Table.Cell></Table.Row>
</Table.Body>
</Table>;
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
describe('semantic roles read as severity in every theme', () => {
/*
* The point of the roles, and the only thing that makes them worth having.
*
* Light and dark spend a hue per role, so this is nearly free there. Night is red and
* nothing else and amber is amber and nothing else, so a role there is a step on a
* brightness ramp -- and it has to be, because `--orange` in night is byte-identical to
* `--text` and `--yellow` to `--amber`. Picking between hue names in night is picking
* between synonyms, which is why all four toast kinds were the same pixel.
*
* None of this is checkable in jsdom: every value is a token behind two levels of
* var(), and the claim is about resolved luminance.
*/
const ROLES = ['neutral', 'info', 'success', 'warning', 'danger'];
const roleColors = () => {
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
const root = getComputedStyle(document.documentElement);
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>
2026-08-01 17:46:33 -06:00
const panel = toRgb(root.getPropertyValue('--panel'));
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
return {
panel,
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>
2026-08-01 17:46:33 -06:00
text: toRgb(root.getPropertyValue('--text')),
roles: ROLES.map(role => ({role, color: toRgb(root.getPropertyValue(`--${role}`))})),
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
};
};
themeNames.forEach((theme) => {
it(`gives every role a color of its own in ${theme}`, () => {
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
// True everywhere. Two roles resolving to the same value is the original bug.
cy.mountUI(<Panel>roles</Panel>, {theme});
cy.get('.wrolpi-panel').should(() => {
const {roles} = roleColors();
const colors = roles.map(r => r.color);
colors.forEach((color, index) => {
expect(color, `${roles[index].role} resolved`).to.match(/^rgb\(/);
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
});
expect(new Set(colors).size, `five distinct roles, got ${colors.join(' ')}`)
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
.to.equal(5);
});
});
it(`keeps every role legible in ${theme}`, () => {
cy.mountUI(<Panel>roles</Panel>, {theme});
cy.get('.wrolpi-panel').should(() => {
const {panel, roles} = roleColors();
roles.forEach(({role, color}) => {
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
/*
* 3:1 is the floor for anything that is not body text. `neutral` is
* allowed to sit at the bottom of the ramp -- for `pending` and disabled,
* being dim IS the signal -- but it still has to be visible at all.
*/
expect(contrast(color, panel), `${role} against the panel`)
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
.to.be.at.least(role === 'neutral' ? 2.5 : 3);
});
});
});
it(`gives each Status kind a color of its own in ${theme}`, () => {
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
/*
* The end of the chain, through a real component: four states, four distinct
* painted colors. In night these used to need three hand-written
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
* `html[data-theme="night"]` overrides; the roles replaced all of them.
*/
cy.mountUI(
<Panel>
<Status kind='complete'>complete</Status>
<Status kind='active'>downloading</Status>
<Status kind='pending'>pending</Status>
<Status kind='failed'>failed</Status>
</Panel>,
{theme},
);
cy.get('.wrolpi-status').should(($all) => {
expect($all.length).to.equal(4);
const colors = [...$all].map(el => getComputedStyle(el).color);
expect(new Set(colors).size, `four distinct colors, got ${colors.join(' ')}`)
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
.to.equal(4);
});
});
});
monochromeThemes.forEach((theme) => {
it(`orders the roles by brightness in ${theme}, which is all it has`, () => {
/*
* Only here. Light and dark spend a hue per role, so their contrast order is
* an accident of which hues were chosen -- in light, blue is DARKER than green
* on white, so asserting a ramp there fails on a design that is perfectly fine.
* With hue gone, though, ordering is the only thing severity can be encoded in.
*/
cy.mountUI(<Panel>roles</Panel>, {theme});
cy.get('.wrolpi-panel').should(() => {
const {panel, roles} = roleColors();
const ratios = roles.map(({role, color}) => ({role, ratio: contrast(color, panel)}));
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
ratios.slice(1).forEach((entry, index) => {
expect(entry.ratio, `${entry.role} is louder than ${ratios[index].role}`)
.to.be.greaterThan(ratios[index].ratio);
});
});
});
ui: lift warning above ordinary text in the monochrome themes A load reading under warning rendered marginally QUIETER than a healthy one: an uncoloured value inherits `--text`, 4.98:1 on a night panel, and `--warning` was 4.91:1. Amber had the same inversion, 7.43 against 8.59. Anything that means "look at this" has to be louder than the prose around it, and with no hue to carry the signal, louder means brighter. Both `warning` and `danger` now clear `--text` in night and amber: night warning #ee3434 -> #f54040 4.91 -> 5.40 (--text 4.98) danger #ff3e3e -> #ff5757 5.71 -> 6.41 amber warning #f18806 -> #fa9f31 7.43 -> 9.05 (--text 8.59) danger #ff9e29 -> #ffb760 9.15 -> 10.96 I said last time this would trade night's "red only" character for loudness. Having measured it, that was overstated. Red contributes 21% of luminance, so in night NOTHING above ~4.9:1 can be a pure hue -- `#ff0000` itself is only 4.99:1 there. `--text` is already `#e04a4a`, carrying 74 of green and blue. The new warning carries 64, LESS than the text beside it; only danger goes further, at 87. A pure-hue ramp above the text was never on the table. The rule is monochrome-only, like the ordering rule it sits beside. A light theme's text is near-black at ~14:1 and no warning colour will ever match it -- there, hue is what marks a reading as flagged. The guard now asserts warning as well as danger, and the LoadStatistic browser test makes the claim it previously had to document as unmet: warning is louder than a plain reading. Planted the reported bug back in both themes, plus two ordering breaks. One plant of mine came back green and was wrong, not the test: I set night's danger to `#f04a4a` expecting it to drop below warning, but that has MORE green and blue than `#f54040`, and green is 71% of luminance -- so it was still the brighter of the two. Re-planted with a value that is genuinely dimmer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 08:23:13 -06:00
it(`makes warning and danger louder than ordinary text in ${theme}`, () => {
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
/*
* Only here. A light theme's text is near-black at ~14:1 and no warning color
ui: lift warning above ordinary text in the monochrome themes A load reading under warning rendered marginally QUIETER than a healthy one: an uncoloured value inherits `--text`, 4.98:1 on a night panel, and `--warning` was 4.91:1. Amber had the same inversion, 7.43 against 8.59. Anything that means "look at this" has to be louder than the prose around it, and with no hue to carry the signal, louder means brighter. Both `warning` and `danger` now clear `--text` in night and amber: night warning #ee3434 -> #f54040 4.91 -> 5.40 (--text 4.98) danger #ff3e3e -> #ff5757 5.71 -> 6.41 amber warning #f18806 -> #fa9f31 7.43 -> 9.05 (--text 8.59) danger #ff9e29 -> #ffb760 9.15 -> 10.96 I said last time this would trade night's "red only" character for loudness. Having measured it, that was overstated. Red contributes 21% of luminance, so in night NOTHING above ~4.9:1 can be a pure hue -- `#ff0000` itself is only 4.99:1 there. `--text` is already `#e04a4a`, carrying 74 of green and blue. The new warning carries 64, LESS than the text beside it; only danger goes further, at 87. A pure-hue ramp above the text was never on the table. The rule is monochrome-only, like the ordering rule it sits beside. A light theme's text is near-black at ~14:1 and no warning colour will ever match it -- there, hue is what marks a reading as flagged. The guard now asserts warning as well as danger, and the LoadStatistic browser test makes the claim it previously had to document as unmet: warning is louder than a plain reading. Planted the reported bug back in both themes, plus two ordering breaks. One plant of mine came back green and was wrong, not the test: I set night's danger to `#f04a4a` expecting it to drop below warning, but that has MORE green and blue than `#f54040`, and green is 71% of luminance -- so it was still the brighter of the two. Re-planted with a value that is genuinely dimmer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 08:23:13 -06:00
* will ever match it -- there, hue is what marks a reading as flagged. On a
* single hue the roles and the text come off the same ramp, so anything meaning
* "look at this" has to outrank the prose or it does not read as flagged at all.
*
* This is the assertion the Status page needed: an uncolored load reading
ui: lift warning above ordinary text in the monochrome themes A load reading under warning rendered marginally QUIETER than a healthy one: an uncoloured value inherits `--text`, 4.98:1 on a night panel, and `--warning` was 4.91:1. Amber had the same inversion, 7.43 against 8.59. Anything that means "look at this" has to be louder than the prose around it, and with no hue to carry the signal, louder means brighter. Both `warning` and `danger` now clear `--text` in night and amber: night warning #ee3434 -> #f54040 4.91 -> 5.40 (--text 4.98) danger #ff3e3e -> #ff5757 5.71 -> 6.41 amber warning #f18806 -> #fa9f31 7.43 -> 9.05 (--text 8.59) danger #ff9e29 -> #ffb760 9.15 -> 10.96 I said last time this would trade night's "red only" character for loudness. Having measured it, that was overstated. Red contributes 21% of luminance, so in night NOTHING above ~4.9:1 can be a pure hue -- `#ff0000` itself is only 4.99:1 there. `--text` is already `#e04a4a`, carrying 74 of green and blue. The new warning carries 64, LESS than the text beside it; only danger goes further, at 87. A pure-hue ramp above the text was never on the table. The rule is monochrome-only, like the ordering rule it sits beside. A light theme's text is near-black at ~14:1 and no warning colour will ever match it -- there, hue is what marks a reading as flagged. The guard now asserts warning as well as danger, and the LoadStatistic browser test makes the claim it previously had to document as unmet: warning is louder than a plain reading. Planted the reported bug back in both themes, plus two ordering breaks. One plant of mine came back green and was wrong, not the test: I set night's danger to `#f04a4a` expecting it to drop below warning, but that has MORE green and blue than `#f54040`, and green is 71% of luminance -- so it was still the brighter of the two. Re-planted with a value that is genuinely dimmer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 08:23:13 -06:00
* inherits `--text`, and warning used to sit just below it.
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
*/
cy.mountUI(<Panel>roles</Panel>, {theme});
cy.get('.wrolpi-panel').should(() => {
const {panel, text, roles} = roleColors();
ui: lift warning above ordinary text in the monochrome themes A load reading under warning rendered marginally QUIETER than a healthy one: an uncoloured value inherits `--text`, 4.98:1 on a night panel, and `--warning` was 4.91:1. Amber had the same inversion, 7.43 against 8.59. Anything that means "look at this" has to be louder than the prose around it, and with no hue to carry the signal, louder means brighter. Both `warning` and `danger` now clear `--text` in night and amber: night warning #ee3434 -> #f54040 4.91 -> 5.40 (--text 4.98) danger #ff3e3e -> #ff5757 5.71 -> 6.41 amber warning #f18806 -> #fa9f31 7.43 -> 9.05 (--text 8.59) danger #ff9e29 -> #ffb760 9.15 -> 10.96 I said last time this would trade night's "red only" character for loudness. Having measured it, that was overstated. Red contributes 21% of luminance, so in night NOTHING above ~4.9:1 can be a pure hue -- `#ff0000` itself is only 4.99:1 there. `--text` is already `#e04a4a`, carrying 74 of green and blue. The new warning carries 64, LESS than the text beside it; only danger goes further, at 87. A pure-hue ramp above the text was never on the table. The rule is monochrome-only, like the ordering rule it sits beside. A light theme's text is near-black at ~14:1 and no warning colour will ever match it -- there, hue is what marks a reading as flagged. The guard now asserts warning as well as danger, and the LoadStatistic browser test makes the claim it previously had to document as unmet: warning is louder than a plain reading. Planted the reported bug back in both themes, plus two ordering breaks. One plant of mine came back green and was wrong, not the test: I set night's danger to `#f04a4a` expecting it to drop below warning, but that has MORE green and blue than `#f54040`, and green is 71% of luminance -- so it was still the brighter of the two. Re-planted with a value that is genuinely dimmer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 08:23:13 -06:00
const prose = contrast(text, panel);
['warning', 'danger'].forEach((name) => {
const role = roles.find(r => r.role === name).color;
ui: lift warning above ordinary text in the monochrome themes A load reading under warning rendered marginally QUIETER than a healthy one: an uncoloured value inherits `--text`, 4.98:1 on a night panel, and `--warning` was 4.91:1. Amber had the same inversion, 7.43 against 8.59. Anything that means "look at this" has to be louder than the prose around it, and with no hue to carry the signal, louder means brighter. Both `warning` and `danger` now clear `--text` in night and amber: night warning #ee3434 -> #f54040 4.91 -> 5.40 (--text 4.98) danger #ff3e3e -> #ff5757 5.71 -> 6.41 amber warning #f18806 -> #fa9f31 7.43 -> 9.05 (--text 8.59) danger #ff9e29 -> #ffb760 9.15 -> 10.96 I said last time this would trade night's "red only" character for loudness. Having measured it, that was overstated. Red contributes 21% of luminance, so in night NOTHING above ~4.9:1 can be a pure hue -- `#ff0000` itself is only 4.99:1 there. `--text` is already `#e04a4a`, carrying 74 of green and blue. The new warning carries 64, LESS than the text beside it; only danger goes further, at 87. A pure-hue ramp above the text was never on the table. The rule is monochrome-only, like the ordering rule it sits beside. A light theme's text is near-black at ~14:1 and no warning colour will ever match it -- there, hue is what marks a reading as flagged. The guard now asserts warning as well as danger, and the LoadStatistic browser test makes the claim it previously had to document as unmet: warning is louder than a plain reading. Planted the reported bug back in both themes, plus two ordering breaks. One plant of mine came back green and was wrong, not the test: I set night's danger to `#f04a4a` expecting it to drop below warning, but that has MORE green and blue than `#f54040`, and green is 71% of luminance -- so it was still the brighter of the two. Re-planted with a value that is genuinely dimmer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 08:23:13 -06:00
expect(contrast(role, panel), `${name} against --text on the panel`)
.to.be.greaterThan(prose);
});
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
});
});
});
it('does not leave failure to color alone', () => {
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
// Brightness is the first thing lost on a dim screen, and it is all night has.
cy.mountUI(
<Panel>
<Status kind='failed'>failed</Status>
<Status kind='complete'>complete</Status>
</Panel>,
{theme: 'night'},
);
cy.get('.wrolpi-status-failed').should(($failed) => {
const other = Cypress.$('.wrolpi-status-complete')[0];
expect(parseInt(getComputedStyle($failed[0]).fontWeight, 10), 'failed is heavier')
.to.be.greaterThan(parseInt(getComputedStyle(other).fontWeight, 10));
});
ui: route genuine success and failure through the roles Sixteen call sites, chosen by reading each one rather than by grepping for a hue. Four sub-agents judged them independently against one rule: convert only what genuinely means success or failure; identification, category and decoration stay hue-named. Converted: SMART drive health (all four branches -- PASS/WARN/FAIL/unknown) config validity: valid / invalid / empty "Failed to load preview" the two "Download error" triggers expired inventory items, desktop and mobile the refresh phases: complete / active / not reached a refresh Progress bar in its error state cookie status: Unlocked / Locked a chip-mismatch label on the flasher CPU load thresholds (LoadStatistic) the outcome of an API call in useAPIButton the gallery's "Danger zone" heading and its load readings Left alone, deliberately: the file browser toolbar -- every action has its own colour to be told apart, and delete already uses role='danger' (Roland's ruling) diff add/remove in the config and inventory import previews. Adding is not a success and removing is not a failure; in Overwrite mode the removals are exactly what the user asked for, and painting them danger would report their intended action as broken seasons in DatesSelector, the uploader star and favourite heart, TagIcon, downloader category buttons, "Recommended to Keep" Three sites were wrong in a way worth naming. Both "Download error" triggers guard on the same condition and render the same modal, but one was `orange` and the other `red` -- and `orange` is the single worst choice, byte-identical to `--text` in night, so that error button was indistinguishable from an ordinary control. Config validity drew its valid state in `--violet`, which no user parses as "valid". And `LoadStatistic` -- the thing users actually watch on the Status page -- rendered its warning threshold in that same invisible orange. Also fixed a stale comment in Videos.js that claimed no token existed for these. Two notes on the tests: The first LoadStatistic test I wrote rendered the component and asserted the inline colour. jsdom REJECTS `color: var(--danger)` as an invalid declaration and drops it, so every colour reads back as the empty string -- two of the four assertions passed for that reason alone and would have kept passing with the hues restored. It is a source guard now, with the painted result asserted in the browser instead. That browser test then found something real: an uncoloured reading inherits `--text`, which in night is 4.98:1 against `--warning`'s 4.91:1, so a machine under load is marginally QUIETER than one that is fine. Not fixed here. The only way up on a dark panel is lightness, and night's danger would desaturate from #ff3e3e to about #ff5d5d -- trading the theme's "red only" character for loudness. That is a palette decision, so the test documents it and asserts what does hold rather than quietly making it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:08:34 -06:00
});
});
describe('a load reading ranks itself in the monochrome themes', () => {
/*
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>
2026-08-01 18:17:18 -06:00
* The real `LoadStatistic`, at the real thresholds -- NOT a hand-built `Statistic` with
* the roles typed in. The first version of this did that, and it would have stayed green
* with `LoadStatistic` reverted to `orange`/`red`: it proved only that role tokens resolve
* distinctly, which the roles suite above already covers.
ui: route genuine success and failure through the roles Sixteen call sites, chosen by reading each one rather than by grepping for a hue. Four sub-agents judged them independently against one rule: convert only what genuinely means success or failure; identification, category and decoration stay hue-named. Converted: SMART drive health (all four branches -- PASS/WARN/FAIL/unknown) config validity: valid / invalid / empty "Failed to load preview" the two "Download error" triggers expired inventory items, desktop and mobile the refresh phases: complete / active / not reached a refresh Progress bar in its error state cookie status: Unlocked / Locked a chip-mismatch label on the flasher CPU load thresholds (LoadStatistic) the outcome of an API call in useAPIButton the gallery's "Danger zone" heading and its load readings Left alone, deliberately: the file browser toolbar -- every action has its own colour to be told apart, and delete already uses role='danger' (Roland's ruling) diff add/remove in the config and inventory import previews. Adding is not a success and removing is not a failure; in Overwrite mode the removals are exactly what the user asked for, and painting them danger would report their intended action as broken seasons in DatesSelector, the uploader star and favourite heart, TagIcon, downloader category buttons, "Recommended to Keep" Three sites were wrong in a way worth naming. Both "Download error" triggers guard on the same condition and render the same modal, but one was `orange` and the other `red` -- and `orange` is the single worst choice, byte-identical to `--text` in night, so that error button was indistinguishable from an ordinary control. Config validity drew its valid state in `--violet`, which no user parses as "valid". And `LoadStatistic` -- the thing users actually watch on the Status page -- rendered its warning threshold in that same invisible orange. Also fixed a stale comment in Videos.js that claimed no token existed for these. Two notes on the tests: The first LoadStatistic test I wrote rendered the component and asserted the inline colour. jsdom REJECTS `color: var(--danger)` as an invalid declaration and drops it, so every colour reads back as the empty string -- two of the four assertions passed for that reason alone and would have kept passing with the hues restored. It is a source guard now, with the painted result asserted in the browser instead. That browser test then found something real: an uncoloured reading inherits `--text`, which in night is 4.98:1 against `--warning`'s 4.91:1, so a machine under load is marginally QUIETER than one that is fine. Not fixed here. The only way up on a dark panel is lightness, and night's danger would desaturate from #ff3e3e to about #ff5d5d -- trading the theme's "red only" character for loudness. That is a palette decision, so the test documents it and asserts what does hold rather than quietly making it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:08:34 -06: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>
2026-08-01 18:17:18 -06:00
* This is the Status page's CPU load, and the clearest payoff of the roles outside the
* library: `orange` above half the cores was byte-identical to `--text` in night, so a
* machine under load rendered its warning as an ordinary uncolored number.
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>
2026-08-01 18:17:18 -06:00
*
* Only a browser can see it. jsdom rejects `color: var(--warning)` as invalid and drops
* it, so the inline color reads back empty whatever the component did.
ui: route genuine success and failure through the roles Sixteen call sites, chosen by reading each one rather than by grepping for a hue. Four sub-agents judged them independently against one rule: convert only what genuinely means success or failure; identification, category and decoration stay hue-named. Converted: SMART drive health (all four branches -- PASS/WARN/FAIL/unknown) config validity: valid / invalid / empty "Failed to load preview" the two "Download error" triggers expired inventory items, desktop and mobile the refresh phases: complete / active / not reached a refresh Progress bar in its error state cookie status: Unlocked / Locked a chip-mismatch label on the flasher CPU load thresholds (LoadStatistic) the outcome of an API call in useAPIButton the gallery's "Danger zone" heading and its load readings Left alone, deliberately: the file browser toolbar -- every action has its own colour to be told apart, and delete already uses role='danger' (Roland's ruling) diff add/remove in the config and inventory import previews. Adding is not a success and removing is not a failure; in Overwrite mode the removals are exactly what the user asked for, and painting them danger would report their intended action as broken seasons in DatesSelector, the uploader star and favourite heart, TagIcon, downloader category buttons, "Recommended to Keep" Three sites were wrong in a way worth naming. Both "Download error" triggers guard on the same condition and render the same modal, but one was `orange` and the other `red` -- and `orange` is the single worst choice, byte-identical to `--text` in night, so that error button was indistinguishable from an ordinary control. Config validity drew its valid state in `--violet`, which no user parses as "valid". And `LoadStatistic` -- the thing users actually watch on the Status page -- rendered its warning threshold in that same invisible orange. Also fixed a stale comment in Videos.js that claimed no token existed for these. Two notes on the tests: The first LoadStatistic test I wrote rendered the component and asserted the inline colour. jsdom REJECTS `color: var(--danger)` as an invalid declaration and drops it, so every colour reads back as the empty string -- two of the four assertions passed for that reason alone and would have kept passing with the hues restored. It is a source guard now, with the painted result asserted in the browser instead. That browser test then found something real: an uncoloured reading inherits `--text`, which in night is 4.98:1 against `--warning`'s 4.91:1, so a machine under load is marginally QUIETER than one that is fine. Not fixed here. The only way up on a dark panel is lightness, and night's danger would desaturate from #ff3e3e to about #ff5d5d -- trading the theme's "red only" character for loudness. That is a palette decision, so the test documents it and asserts what does hold rather than quietly making it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:08:34 -06:00
*/
monochromeThemes.forEach((theme) => {
it(`separates fine, warning and danger loads in ${theme}`, () => {
cy.mountUI(
<Panel>
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>
2026-08-01 18:17:18 -06:00
<LoadStatistic label='1 Min. Load' value={1.9} cores={4}/>
<LoadStatistic label='5 Min. Load' value={2.6} cores={4}/>
<LoadStatistic label='15 Min. Load' value={4.1} cores={4}/>
ui: route genuine success and failure through the roles Sixteen call sites, chosen by reading each one rather than by grepping for a hue. Four sub-agents judged them independently against one rule: convert only what genuinely means success or failure; identification, category and decoration stay hue-named. Converted: SMART drive health (all four branches -- PASS/WARN/FAIL/unknown) config validity: valid / invalid / empty "Failed to load preview" the two "Download error" triggers expired inventory items, desktop and mobile the refresh phases: complete / active / not reached a refresh Progress bar in its error state cookie status: Unlocked / Locked a chip-mismatch label on the flasher CPU load thresholds (LoadStatistic) the outcome of an API call in useAPIButton the gallery's "Danger zone" heading and its load readings Left alone, deliberately: the file browser toolbar -- every action has its own colour to be told apart, and delete already uses role='danger' (Roland's ruling) diff add/remove in the config and inventory import previews. Adding is not a success and removing is not a failure; in Overwrite mode the removals are exactly what the user asked for, and painting them danger would report their intended action as broken seasons in DatesSelector, the uploader star and favourite heart, TagIcon, downloader category buttons, "Recommended to Keep" Three sites were wrong in a way worth naming. Both "Download error" triggers guard on the same condition and render the same modal, but one was `orange` and the other `red` -- and `orange` is the single worst choice, byte-identical to `--text` in night, so that error button was indistinguishable from an ordinary control. Config validity drew its valid state in `--violet`, which no user parses as "valid". And `LoadStatistic` -- the thing users actually watch on the Status page -- rendered its warning threshold in that same invisible orange. Also fixed a stale comment in Videos.js that claimed no token existed for these. Two notes on the tests: The first LoadStatistic test I wrote rendered the component and asserted the inline colour. jsdom REJECTS `color: var(--danger)` as an invalid declaration and drops it, so every colour reads back as the empty string -- two of the four assertions passed for that reason alone and would have kept passing with the hues restored. It is a source guard now, with the painted result asserted in the browser instead. That browser test then found something real: an uncoloured reading inherits `--text`, which in night is 4.98:1 against `--warning`'s 4.91:1, so a machine under load is marginally QUIETER than one that is fine. Not fixed here. The only way up on a dark panel is lightness, and night's danger would desaturate from #ff3e3e to about #ff5d5d -- trading the theme's "red only" character for loudness. That is a palette decision, so the test documents it and asserts what does hold rather than quietly making it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:08:34 -06:00
</Panel>,
{theme},
);
cy.get('.wrolpi-statistic-value').should(($values) => {
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>
2026-08-01 18:17:18 -06:00
expect($values.length, 'three readings').to.equal(3);
ui: route genuine success and failure through the roles Sixteen call sites, chosen by reading each one rather than by grepping for a hue. Four sub-agents judged them independently against one rule: convert only what genuinely means success or failure; identification, category and decoration stay hue-named. Converted: SMART drive health (all four branches -- PASS/WARN/FAIL/unknown) config validity: valid / invalid / empty "Failed to load preview" the two "Download error" triggers expired inventory items, desktop and mobile the refresh phases: complete / active / not reached a refresh Progress bar in its error state cookie status: Unlocked / Locked a chip-mismatch label on the flasher CPU load thresholds (LoadStatistic) the outcome of an API call in useAPIButton the gallery's "Danger zone" heading and its load readings Left alone, deliberately: the file browser toolbar -- every action has its own colour to be told apart, and delete already uses role='danger' (Roland's ruling) diff add/remove in the config and inventory import previews. Adding is not a success and removing is not a failure; in Overwrite mode the removals are exactly what the user asked for, and painting them danger would report their intended action as broken seasons in DatesSelector, the uploader star and favourite heart, TagIcon, downloader category buttons, "Recommended to Keep" Three sites were wrong in a way worth naming. Both "Download error" triggers guard on the same condition and render the same modal, but one was `orange` and the other `red` -- and `orange` is the single worst choice, byte-identical to `--text` in night, so that error button was indistinguishable from an ordinary control. Config validity drew its valid state in `--violet`, which no user parses as "valid". And `LoadStatistic` -- the thing users actually watch on the Status page -- rendered its warning threshold in that same invisible orange. Also fixed a stale comment in Videos.js that claimed no token existed for these. Two notes on the tests: The first LoadStatistic test I wrote rendered the component and asserted the inline colour. jsdom REJECTS `color: var(--danger)` as an invalid declaration and drops it, so every colour reads back as the empty string -- two of the four assertions passed for that reason alone and would have kept passing with the hues restored. It is a source guard now, with the painted result asserted in the browser instead. That browser test then found something real: an uncoloured reading inherits `--text`, which in night is 4.98:1 against `--warning`'s 4.91:1, so a machine under load is marginally QUIETER than one that is fine. Not fixed here. The only way up on a dark panel is lightness, and night's danger would desaturate from #ff3e3e to about #ff5d5d -- trading the theme's "red only" character for loudness. That is a palette decision, so the test documents it and asserts what does hold rather than quietly making it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:08:34 -06:00
const [fine, warning, danger] = [...$values]
.map(el => toRgb(getComputedStyle(el).color));
const panel = toRgb(getComputedStyle(
Cypress.$('.wrolpi-panel')[0]).backgroundColor);
expect(new Set([fine, warning, danger]).size, 'three distinct readings').to.equal(3);
/*
ui: lift warning above ordinary text in the monochrome themes A load reading under warning rendered marginally QUIETER than a healthy one: an uncoloured value inherits `--text`, 4.98:1 on a night panel, and `--warning` was 4.91:1. Amber had the same inversion, 7.43 against 8.59. Anything that means "look at this" has to be louder than the prose around it, and with no hue to carry the signal, louder means brighter. Both `warning` and `danger` now clear `--text` in night and amber: night warning #ee3434 -> #f54040 4.91 -> 5.40 (--text 4.98) danger #ff3e3e -> #ff5757 5.71 -> 6.41 amber warning #f18806 -> #fa9f31 7.43 -> 9.05 (--text 8.59) danger #ff9e29 -> #ffb760 9.15 -> 10.96 I said last time this would trade night's "red only" character for loudness. Having measured it, that was overstated. Red contributes 21% of luminance, so in night NOTHING above ~4.9:1 can be a pure hue -- `#ff0000` itself is only 4.99:1 there. `--text` is already `#e04a4a`, carrying 74 of green and blue. The new warning carries 64, LESS than the text beside it; only danger goes further, at 87. A pure-hue ramp above the text was never on the table. The rule is monochrome-only, like the ordering rule it sits beside. A light theme's text is near-black at ~14:1 and no warning colour will ever match it -- there, hue is what marks a reading as flagged. The guard now asserts warning as well as danger, and the LoadStatistic browser test makes the claim it previously had to document as unmet: warning is louder than a plain reading. Planted the reported bug back in both themes, plus two ordering breaks. One plant of mine came back green and was wrong, not the test: I set night's danger to `#f04a4a` expecting it to drop below warning, but that has MORE green and blue than `#f54040`, and green is 71% of luminance -- so it was still the brighter of the two. Re-planted with a value that is genuinely dimmer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 08:23:13 -06:00
* Both flagged readings outrank a plain one. This is what the ramp change
* bought: warning used to sit just UNDER `--text`, so a machine under load
* rendered marginally quieter than a healthy one.
ui: route genuine success and failure through the roles Sixteen call sites, chosen by reading each one rather than by grepping for a hue. Four sub-agents judged them independently against one rule: convert only what genuinely means success or failure; identification, category and decoration stay hue-named. Converted: SMART drive health (all four branches -- PASS/WARN/FAIL/unknown) config validity: valid / invalid / empty "Failed to load preview" the two "Download error" triggers expired inventory items, desktop and mobile the refresh phases: complete / active / not reached a refresh Progress bar in its error state cookie status: Unlocked / Locked a chip-mismatch label on the flasher CPU load thresholds (LoadStatistic) the outcome of an API call in useAPIButton the gallery's "Danger zone" heading and its load readings Left alone, deliberately: the file browser toolbar -- every action has its own colour to be told apart, and delete already uses role='danger' (Roland's ruling) diff add/remove in the config and inventory import previews. Adding is not a success and removing is not a failure; in Overwrite mode the removals are exactly what the user asked for, and painting them danger would report their intended action as broken seasons in DatesSelector, the uploader star and favourite heart, TagIcon, downloader category buttons, "Recommended to Keep" Three sites were wrong in a way worth naming. Both "Download error" triggers guard on the same condition and render the same modal, but one was `orange` and the other `red` -- and `orange` is the single worst choice, byte-identical to `--text` in night, so that error button was indistinguishable from an ordinary control. Config validity drew its valid state in `--violet`, which no user parses as "valid". And `LoadStatistic` -- the thing users actually watch on the Status page -- rendered its warning threshold in that same invisible orange. Also fixed a stale comment in Videos.js that claimed no token existed for these. Two notes on the tests: The first LoadStatistic test I wrote rendered the component and asserted the inline colour. jsdom REJECTS `color: var(--danger)` as an invalid declaration and drops it, so every colour reads back as the empty string -- two of the four assertions passed for that reason alone and would have kept passing with the hues restored. It is a source guard now, with the painted result asserted in the browser instead. That browser test then found something real: an uncoloured reading inherits `--text`, which in night is 4.98:1 against `--warning`'s 4.91:1, so a machine under load is marginally QUIETER than one that is fine. Not fixed here. The only way up on a dark panel is lightness, and night's danger would desaturate from #ff3e3e to about #ff5d5d -- trading the theme's "red only" character for loudness. That is a palette decision, so the test documents it and asserts what does hold rather than quietly making it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:08:34 -06:00
*/
ui: lift warning above ordinary text in the monochrome themes A load reading under warning rendered marginally QUIETER than a healthy one: an uncoloured value inherits `--text`, 4.98:1 on a night panel, and `--warning` was 4.91:1. Amber had the same inversion, 7.43 against 8.59. Anything that means "look at this" has to be louder than the prose around it, and with no hue to carry the signal, louder means brighter. Both `warning` and `danger` now clear `--text` in night and amber: night warning #ee3434 -> #f54040 4.91 -> 5.40 (--text 4.98) danger #ff3e3e -> #ff5757 5.71 -> 6.41 amber warning #f18806 -> #fa9f31 7.43 -> 9.05 (--text 8.59) danger #ff9e29 -> #ffb760 9.15 -> 10.96 I said last time this would trade night's "red only" character for loudness. Having measured it, that was overstated. Red contributes 21% of luminance, so in night NOTHING above ~4.9:1 can be a pure hue -- `#ff0000` itself is only 4.99:1 there. `--text` is already `#e04a4a`, carrying 74 of green and blue. The new warning carries 64, LESS than the text beside it; only danger goes further, at 87. A pure-hue ramp above the text was never on the table. The rule is monochrome-only, like the ordering rule it sits beside. A light theme's text is near-black at ~14:1 and no warning colour will ever match it -- there, hue is what marks a reading as flagged. The guard now asserts warning as well as danger, and the LoadStatistic browser test makes the claim it previously had to document as unmet: warning is louder than a plain reading. Planted the reported bug back in both themes, plus two ordering breaks. One plant of mine came back green and was wrong, not the test: I set night's danger to `#f04a4a` expecting it to drop below warning, but that has MORE green and blue than `#f54040`, and green is 71% of luminance -- so it was still the brighter of the two. Re-planted with a value that is genuinely dimmer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 08:23:13 -06:00
expect(contrast(warning, panel), 'warning is louder than a plain reading')
.to.be.greaterThan(contrast(fine, panel));
expect(contrast(danger, panel), 'danger is louder than warning')
.to.be.greaterThan(contrast(warning, panel));
ui: route genuine success and failure through the roles Sixteen call sites, chosen by reading each one rather than by grepping for a hue. Four sub-agents judged them independently against one rule: convert only what genuinely means success or failure; identification, category and decoration stay hue-named. Converted: SMART drive health (all four branches -- PASS/WARN/FAIL/unknown) config validity: valid / invalid / empty "Failed to load preview" the two "Download error" triggers expired inventory items, desktop and mobile the refresh phases: complete / active / not reached a refresh Progress bar in its error state cookie status: Unlocked / Locked a chip-mismatch label on the flasher CPU load thresholds (LoadStatistic) the outcome of an API call in useAPIButton the gallery's "Danger zone" heading and its load readings Left alone, deliberately: the file browser toolbar -- every action has its own colour to be told apart, and delete already uses role='danger' (Roland's ruling) diff add/remove in the config and inventory import previews. Adding is not a success and removing is not a failure; in Overwrite mode the removals are exactly what the user asked for, and painting them danger would report their intended action as broken seasons in DatesSelector, the uploader star and favourite heart, TagIcon, downloader category buttons, "Recommended to Keep" Three sites were wrong in a way worth naming. Both "Download error" triggers guard on the same condition and render the same modal, but one was `orange` and the other `red` -- and `orange` is the single worst choice, byte-identical to `--text` in night, so that error button was indistinguishable from an ordinary control. Config validity drew its valid state in `--violet`, which no user parses as "valid". And `LoadStatistic` -- the thing users actually watch on the Status page -- rendered its warning threshold in that same invisible orange. Also fixed a stale comment in Videos.js that claimed no token existed for these. Two notes on the tests: The first LoadStatistic test I wrote rendered the component and asserted the inline colour. jsdom REJECTS `color: var(--danger)` as an invalid declaration and drops it, so every colour reads back as the empty string -- two of the four assertions passed for that reason alone and would have kept passing with the hues restored. It is a source guard now, with the painted result asserted in the browser instead. That browser test then found something real: an uncoloured reading inherits `--text`, which in night is 4.98:1 against `--warning`'s 4.91:1, so a machine under load is marginally QUIETER than one that is fine. Not fixed here. The only way up on a dark panel is lightness, and night's danger would desaturate from #ff3e3e to about #ff5d5d -- trading the theme's "red only" character for loudness. That is a palette decision, so the test documents it and asserts what does hold rather than quietly making it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:08:34 -06:00
});
});
ui: headings open their section, and keep their help icon on one line Two things, and the second was a regression this migration caused. A heading had `margin: 0 0 10px` -- no top margin at all -- so it sat flush against whatever came before and read as part of it rather than as the start of the next thing. On /more/statistics "Tags" touched the panel above it with a 0px gap. Now 22px above and 10px below, because a heading belongs to what follows it. `* + .wrolpi-header` rather than a blanket margin, for the same reason StatisticGroup needed it: a heading that opens a Panel or a page is already where it should be, and pushing it down just dents the top of its own container. The help icon on every HelpHeader and InfoHeader had dropped to its own line -- "Root CA Certificate" in Settings is the clearest one. `.inline-header` set `h1..h5 {display: inline-block}` so the heading and a sibling `<span>` shared a row, which worked while these were a bare `<h2>` and stopped the moment they gained a block wrapper: the `<label>`'s block child forced a break. Fixed in the library rather than patched in App.css. `Header` takes an `after` slot rendered inside the heading element, where the existing flex row already handles alignment and spacing. Both wrappers pass their icon through it, the `<label>` moves inside the heading so `for_` keeps associating the text with its field (three call sites rely on it), and the `.inline-header` rules are deleted. Fifteen call sites are fixed by fixing the two wrappers. Tests: containment in jest, and the part jsdom cannot judge -- that the two boxes actually share a line, and that the heading stays one row tall -- in a browser. Planted both original shapes: the margin removed, a blanket margin denting its container, and the control moved back outside the heading element. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:41:58 -06:00
});
});
describe('a heading keeps its trailing control on its own line', () => {
/*
* The defect this fixes: `.wrolpi-header` is a block, so a help icon placed after it
* wrapped to the next line -- every `HelpHeader` and `InfoHeader` in the app, most
* visibly "Root CA Certificate" on the Settings page.
*
* A pure layout claim, so jsdom cannot judge it: getBoundingClientRect returns zeros
* there, and containment alone (which the jest tests assert) does not prove two boxes
* share a line.
*/
test: act on review — and one of the seven turned out to be undemonstrable Six real fixes and one honest retraction. The control is now a SIBLING of the heading inside a flex row, not a child of it. Inside the `<h3>` it joined the heading's accessible name, so screen reader heading navigation announced "Root CA Certificate Help". The row is what keeps them on one line, and it is only rendered when there is something to sit beside, so the markup for the other 46 call sites is unchanged. `style` now lands on the wrapper. It used to reach the outer div; going through Header put it on the inner heading, where a margin sets space INSIDE the wrapper and only worked at all through margin collapse -- which stops the moment the wrapper gains padding or a border. Status's "Drive Bandwidth" is the live case: verified 16px on the block, 0 on the h2. Text properties still arrive, because colour and text-align inherit; the `color` PROP stays on the heading. A `<label>` only when `for_` names a field. Several call sites pass an InfoHeader as the `label` prop of InputForm/ToggleForm, which wraps it in a label of its own -- an unconditional one nested labels, which is invalid and makes clicking the text ambiguous. Verified: zero `label label` on /videos/settings, where "Video Resolutions" keeps its label and "Video File Format" no longer has one. The help controls carried `iconStyle: {margin: '0.5em'}`, which separated a free-floating sibling and, inside the row, added to the gap on every side. Zeroed; the row's gap is the spacing. The browser test mounted a plain Button in an `after` slot rather than a real HelpHeader, so the default icon chrome above was exactly what it could not see. It mounts the real wrapper now. Two of my assertions were also too weak to catch what they claimed: the gap was measured to `.wrolpi-header-after`, a flex container whose own rect does not move when a child gains a margin, so it had to measure the button; and the squeeze case used a title of ordinary words, which simply wraps and never puts the row under pressure. Renamed the suites -- "keeps the icon on its own line" read as the opposite of the fix. The retraction: `flex-shrink: 0` is declared but has NO test. Three attempts could not find a width where removing it changes what is painted -- the row's only other item is a heading, and its automatic minimum size absorbs the pressure; the help control is an ActionIcon with a min-width it will not go below either. The declaration stays as a statement of intent, with a comment saying it is unproven, rather than a green test that does not discriminate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:00:32 -06:00
/*
* The REAL wrapper, not a plain Button in an `after` slot. A hand-built fixture would
* miss the thing most likely to be wrong: `HelpModal` and `InfoPopup` carry their own
* `iconStyle` default of `margin: 0.5em`, which was there to separate a free-floating
* sibling and adds to the row's gap on every side once it is inside the row.
*/
ui: headings open their section, and keep their help icon on one line Two things, and the second was a regression this migration caused. A heading had `margin: 0 0 10px` -- no top margin at all -- so it sat flush against whatever came before and read as part of it rather than as the start of the next thing. On /more/statistics "Tags" touched the panel above it with a 0px gap. Now 22px above and 10px below, because a heading belongs to what follows it. `* + .wrolpi-header` rather than a blanket margin, for the same reason StatisticGroup needed it: a heading that opens a Panel or a page is already where it should be, and pushing it down just dents the top of its own container. The help icon on every HelpHeader and InfoHeader had dropped to its own line -- "Root CA Certificate" in Settings is the clearest one. `.inline-header` set `h1..h5 {display: inline-block}` so the heading and a sibling `<span>` shared a row, which worked while these were a bare `<h2>` and stopped the moment they gained a block wrapper: the `<label>`'s block child forced a break. Fixed in the library rather than patched in App.css. `Header` takes an `after` slot rendered inside the heading element, where the existing flex row already handles alignment and spacing. Both wrappers pass their icon through it, the `<label>` moves inside the heading so `for_` keeps associating the text with its field (three call sites rely on it), and the `.inline-header` rules are deleted. Fifteen call sites are fixed by fixing the two wrappers. Tests: containment in jest, and the part jsdom cannot judge -- that the two boxes actually share a line, and that the heading stays one row tall -- in a browser. Planted both original shapes: the margin removed, a blanket margin denting its container, and the control moved back outside the heading element. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:41:58 -06:00
themeNames.forEach((theme) => {
test: act on review — and one of the seven turned out to be undemonstrable Six real fixes and one honest retraction. The control is now a SIBLING of the heading inside a flex row, not a child of it. Inside the `<h3>` it joined the heading's accessible name, so screen reader heading navigation announced "Root CA Certificate Help". The row is what keeps them on one line, and it is only rendered when there is something to sit beside, so the markup for the other 46 call sites is unchanged. `style` now lands on the wrapper. It used to reach the outer div; going through Header put it on the inner heading, where a margin sets space INSIDE the wrapper and only worked at all through margin collapse -- which stops the moment the wrapper gains padding or a border. Status's "Drive Bandwidth" is the live case: verified 16px on the block, 0 on the h2. Text properties still arrive, because colour and text-align inherit; the `color` PROP stays on the heading. A `<label>` only when `for_` names a field. Several call sites pass an InfoHeader as the `label` prop of InputForm/ToggleForm, which wraps it in a label of its own -- an unconditional one nested labels, which is invalid and makes clicking the text ambiguous. Verified: zero `label label` on /videos/settings, where "Video Resolutions" keeps its label and "Video File Format" no longer has one. The help controls carried `iconStyle: {margin: '0.5em'}`, which separated a free-floating sibling and, inside the row, added to the gap on every side. Zeroed; the row's gap is the spacing. The browser test mounted a plain Button in an `after` slot rather than a real HelpHeader, so the default icon chrome above was exactly what it could not see. It mounts the real wrapper now. Two of my assertions were also too weak to catch what they claimed: the gap was measured to `.wrolpi-header-after`, a flex container whose own rect does not move when a child gains a margin, so it had to measure the button; and the squeeze case used a title of ordinary words, which simply wraps and never puts the row under pressure. Renamed the suites -- "keeps the icon on its own line" read as the opposite of the fix. The retraction: `flex-shrink: 0` is declared but has NO test. Three attempts could not find a width where removing it changes what is painted -- the row's only other item is a heading, and its automatic minimum size absorbs the pressure; the help control is an ActionIcon with a min-width it will not go below either. The declaration stays as a statement of intent, with a comment saying it is unproven, rather than a green test that does not discriminate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:00:32 -06:00
it(`sits a real help control beside the text in ${theme}`, () => {
cy.mountUI(
<HelpHeader headerSize='h3' headerContent='Root CA Certificate'
helpPath='/system/certificates/'/>,
{theme},
);
cy.get('.wrolpi-header-after').should(($after) => {
const control = $after[0].getBoundingClientRect();
const text = $after[0].previousElementSibling.getBoundingClientRect();
expect(control.top, 'control starts above the text baseline')
.to.be.lessThan(text.bottom);
expect(text.top, 'text starts above the control baseline')
.to.be.lessThan(control.bottom);
expect(control.left, 'control is after the text').to.be.at.least(text.right);
/*
* Measured to the BUTTON, not to `.wrolpi-header-after`. That wrapper is a
* flex container, so a margin on the button sits inside it and the wrapper's
* own rect does not move -- measuring the wrapper cannot see the margin at
* all, which is how this assertion first passed with it restored.
*/
const button = $after[0].querySelector('button').getBoundingClientRect();
expect(button.left - text.right, 'the row gap alone, no icon margin on top')
.to.be.at.most(12);
});
});
it(`sits an arbitrary control beside the text in ${theme}`, () => {
ui: headings open their section, and keep their help icon on one line Two things, and the second was a regression this migration caused. A heading had `margin: 0 0 10px` -- no top margin at all -- so it sat flush against whatever came before and read as part of it rather than as the start of the next thing. On /more/statistics "Tags" touched the panel above it with a 0px gap. Now 22px above and 10px below, because a heading belongs to what follows it. `* + .wrolpi-header` rather than a blanket margin, for the same reason StatisticGroup needed it: a heading that opens a Panel or a page is already where it should be, and pushing it down just dents the top of its own container. The help icon on every HelpHeader and InfoHeader had dropped to its own line -- "Root CA Certificate" in Settings is the clearest one. `.inline-header` set `h1..h5 {display: inline-block}` so the heading and a sibling `<span>` shared a row, which worked while these were a bare `<h2>` and stopped the moment they gained a block wrapper: the `<label>`'s block child forced a break. Fixed in the library rather than patched in App.css. `Header` takes an `after` slot rendered inside the heading element, where the existing flex row already handles alignment and spacing. Both wrappers pass their icon through it, the `<label>` moves inside the heading so `for_` keeps associating the text with its field (three call sites rely on it), and the `.inline-header` rules are deleted. Fifteen call sites are fixed by fixing the two wrappers. Tests: containment in jest, and the part jsdom cannot judge -- that the two boxes actually share a line, and that the heading stays one row tall -- in a browser. Planted both original shapes: the margin removed, a blanket margin denting its container, and the control moved back outside the heading element. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:41:58 -06:00
cy.mountUI(
<Header as='h3' after={<Button role='cancel' size='xs'>Help</Button>}>
Root CA Certificate
</Header>,
{theme},
);
cy.get('.wrolpi-header-after').should(($after) => {
const control = $after[0].getBoundingClientRect();
const text = $after[0].previousElementSibling.getBoundingClientRect();
// Beside, not below: they overlap vertically and the control is to the right.
expect(control.top, 'control starts above the text baseline')
.to.be.lessThan(text.bottom);
expect(text.top, 'text starts above the control baseline')
.to.be.lessThan(control.bottom);
expect(control.left, 'control is after the text').to.be.at.least(text.right);
});
});
});
it('does not stretch the heading to make room', () => {
// A wrapped control would make the heading two lines tall. One line is the claim.
cy.mountUI(
<Header as='h3' after={<Button role='cancel' size='xs'>Help</Button>}>
Root CA Certificate
</Header>,
{theme: 'light'},
);
cy.get('.wrolpi-header-text').should(($heading) => {
const control = Cypress.$('.wrolpi-header-after')[0].getBoundingClientRect();
expect($heading[0].getBoundingClientRect().height, 'heading is one row tall')
.to.be.lessThan(control.height * 2);
});
});
});
describe('a heading opens a section rather than closing the last one', () => {
it('leaves room above a heading that follows something', () => {
/*
* With no top margin a heading sat flush against the panel above it and read as part
* of it -- "Tags" on /more/statistics touched the panel above with a 0px gap.
*/
cy.mountUI(
<div>
<Panel>Files</Panel>
<Header as='h3'>Tags</Header>
<Panel>34 tags</Panel>
</div>,
{theme: 'light'},
);
cy.get('.wrolpi-header').should(($header) => {
const panel = Cypress.$('.wrolpi-panel')[0].getBoundingClientRect();
const gap = $header[0].getBoundingClientRect().top - panel.bottom;
expect(gap, 'gap above the heading').to.be.at.least(12);
// And more above than below, because the heading belongs to what follows it.
const below = Cypress.$('.wrolpi-panel')[1].getBoundingClientRect().top
- $header[0].getBoundingClientRect().bottom;
expect(gap, 'more air above the heading than below it').to.be.greaterThan(below);
});
});
it('does not dent the top of its own container', () => {
// A blanket margin would push a heading that opens a Panel away from the Panel's edge.
cy.mountUI(<Panel><Header as='h3'>Downloads</Header><p>body</p></Panel>, {theme: 'light'});
cy.get('.wrolpi-header').should(($header) => {
expect(getComputedStyle($header[0]).marginTop, 'first child has no top margin')
.to.equal('0px');
});
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
});
});
describe('a progress bar has room for the label inside it', () => {
const bar = (props) => <Panel><Progress {...props}/></Panel>;
it('leaves air above and below the text', () => {
/*
* The Status page draws 44 of these. At 16px tall the 11px bold label left about
* half a pixel of air, which is legible only if you already know what it says.
*/
cy.mountUI(bar({percent: 62, label: 'CPU Usage (16 cores)'}), {theme: 'light'});
cy.get('.wrolpi-progress').should(($bar) => {
const box = $bar[0].getBoundingClientRect();
expect(box.height, 'bar height').to.be.at.least(20);
test: act on review — a test that could not pass with Reduce Motion on The indeterminate test read the band's position out of a running animation and asserted it had left the box. Two problems, and the second is the serious one: it samples a moving target, and under `prefers-reduced-motion` the slide is replaced by `width: 100%` with no negative margin, so the band never leaves the box and the assertion is permanently false. Anyone with Reduce Motion turned on -- or a CI host with it set -- gets a hard failure on a correct build. Reproduced it rather than taking it on faith: forcing the reduced-motion branch for the whole run fails the old form and passes the new one. The band is pinned now, to where the animation's first keyframe puts it, and the assertion is on the clip plus that escape. Deterministic, and true on any machine. Added the other branch too: with motion suppressed the bar fills instead of sliding, and a band that never moves must never leave the box. `text-overflow: ellipsis` on the label. `nowrap` alone stopped it wrapping and being bisected by the clip, but left a hard mid-glyph cut, and the call sites that feed this are exactly the ones with long strings -- Upload.js and FileBrowser.js label with a filename, Files.js with the error string. The one-line test was close to circular: with `nowrap` applied, one line box is almost a restatement of the rule. It now also asserts the computed `nowrap` and `ellipsis`, and that the line is genuinely WIDER than the space it has -- without that, a label that simply fits would satisfy it. Dropped a dead ternary from the air-around-label test; it built a rect nothing used and made it look as though the measurement came from somewhere it did not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:03:31 -06:00
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
// The line box, measured from the text node itself rather than its stretched
// flex container, which is inset:0 and therefore always the bar's height.
const range = document.createRange();
range.selectNodeContents($bar[0].querySelector('.wrolpi-progress-text'));
test: act on review — a test that could not pass with Reduce Motion on The indeterminate test read the band's position out of a running animation and asserted it had left the box. Two problems, and the second is the serious one: it samples a moving target, and under `prefers-reduced-motion` the slide is replaced by `width: 100%` with no negative margin, so the band never leaves the box and the assertion is permanently false. Anyone with Reduce Motion turned on -- or a CI host with it set -- gets a hard failure on a correct build. Reproduced it rather than taking it on faith: forcing the reduced-motion branch for the whole run fails the old form and passes the new one. The band is pinned now, to where the animation's first keyframe puts it, and the assertion is on the clip plus that escape. Deterministic, and true on any machine. Added the other branch too: with motion suppressed the bar fills instead of sliding, and a band that never moves must never leave the box. `text-overflow: ellipsis` on the label. `nowrap` alone stopped it wrapping and being bisected by the clip, but left a hard mid-glyph cut, and the call sites that feed this are exactly the ones with long strings -- Upload.js and FileBrowser.js label with a filename, Files.js with the error string. The one-line test was close to circular: with `nowrap` applied, one line box is almost a restatement of the rule. It now also asserts the computed `nowrap` and `ellipsis`, and that the line is genuinely WIDER than the space it has -- without that, a label that simply fits would satisfy it. Dropped a dead ternary from the air-around-label test; it built a rect nothing used and made it look as though the measurement came from somewhere it did not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:03:31 -06:00
expect(box.height - range.getBoundingClientRect().height, 'air around the label')
.to.be.at.least(4);
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
});
});
themeNames.forEach((theme) => {
it(`draws no outline of its own in ${theme}, and is the size it was with one`, () => {
/*
* The border came off. Both halves matter: the bar must not be the 1px smaller
* inside that removing an outline usually makes it -- it is not, because
* `box-sizing: border-box` is global and the declared height was always the outer
* box -- and the empty part of the track has to keep an edge of its own now that
* no line is drawing one, which is why the track paints `--head` rather than the
* `--bg` / `--panel` pair that a bar sits on.
*
* Measured against `rem`, not px: 1.375rem and 7.5rem move with `--ui-scale`.
*/
cy.mountUI(bar({percent: 40, label: 'CPU Usage'}), {theme});
cy.get('.wrolpi-progress').should(($bar) => {
const style = getComputedStyle($bar[0]);
['Top', 'Right', 'Bottom', 'Left'].forEach(side =>
expect(style[`border${side}Width`], `no border on the ${side} edge`)
.to.equal('0px'));
const rem = 16 * uiScale();
expect($bar[0].getBoundingClientRect().height, 'the bar is the height it was')
.to.be.closeTo(1.375 * rem, 0.5);
expect(parseFloat(style.minWidth), 'and the width it was')
.to.be.closeTo(7.5 * rem, 0.5);
});
// The Panel the bar sits on, which is what the track has to stay off.
cy.get('.wrolpi-progress').should(($bar) => {
const track = getComputedStyle($bar[0]).backgroundColor;
const panel = getComputedStyle($bar[0].closest('.wrolpi-panel')).backgroundColor;
expect(track, 'the track paints a surface of its own')
.to.not.match(/^rgba\(.*,\s*0(\.0+)?\)$/);
expect(contrast(toRgb(track), toRgb(panel)), 'track against the panel under it')
.to.be.greaterThan(1.05);
});
});
});
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
it('keeps a long label on one line', () => {
/*
* `white-space: nowrap` on the label. The first version of this asserted the bar did
* not get wider -- which it cannot: the label is `position: absolute; inset: 0`, so it
* takes no part in its parent's width and the claim was unfalsifiable. What a long
* label really does is wrap to a second line inside a 22px bar and get cut in half by
* the clip, so that is what is measured.
*/
cy.mountUI(
<div style={{width: 200}}>
<Progress percent={40} label='nbd0 read 128.4 MBps sustained over 5 minutes'/>
</div>,
{theme: 'light'},
);
cy.get('.wrolpi-progress-text').should(($text) => {
test: act on review — a test that could not pass with Reduce Motion on The indeterminate test read the band's position out of a running animation and asserted it had left the box. Two problems, and the second is the serious one: it samples a moving target, and under `prefers-reduced-motion` the slide is replaced by `width: 100%` with no negative margin, so the band never leaves the box and the assertion is permanently false. Anyone with Reduce Motion turned on -- or a CI host with it set -- gets a hard failure on a correct build. Reproduced it rather than taking it on faith: forcing the reduced-motion branch for the whole run fails the old form and passes the new one. The band is pinned now, to where the animation's first keyframe puts it, and the assertion is on the clip plus that escape. Deterministic, and true on any machine. Added the other branch too: with motion suppressed the bar fills instead of sliding, and a band that never moves must never leave the box. `text-overflow: ellipsis` on the label. `nowrap` alone stopped it wrapping and being bisected by the clip, but left a hard mid-glyph cut, and the call sites that feed this are exactly the ones with long strings -- Upload.js and FileBrowser.js label with a filename, Files.js with the error string. The one-line test was close to circular: with `nowrap` applied, one line box is almost a restatement of the rule. It now also asserts the computed `nowrap` and `ellipsis`, and that the line is genuinely WIDER than the space it has -- without that, a label that simply fits would satisfy it. Dropped a dead ternary from the air-around-label test; it built a rect nothing used and made it look as though the measurement came from somewhere it did not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:03:31 -06:00
const style = getComputedStyle($text[0]);
expect(style.whiteSpace, 'label does not wrap').to.equal('nowrap');
expect(style.textOverflow, 'and is cut with an ellipsis, not mid-glyph')
.to.equal('ellipsis');
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
const range = document.createRange();
range.selectNodeContents($text[0]);
test: act on review — a test that could not pass with Reduce Motion on The indeterminate test read the band's position out of a running animation and asserted it had left the box. Two problems, and the second is the serious one: it samples a moving target, and under `prefers-reduced-motion` the slide is replaced by `width: 100%` with no negative margin, so the band never leaves the box and the assertion is permanently false. Anyone with Reduce Motion turned on -- or a CI host with it set -- gets a hard failure on a correct build. Reproduced it rather than taking it on faith: forcing the reduced-motion branch for the whole run fails the old form and passes the new one. The band is pinned now, to where the animation's first keyframe puts it, and the assertion is on the clip plus that escape. Deterministic, and true on any machine. Added the other branch too: with motion suppressed the bar fills instead of sliding, and a band that never moves must never leave the box. `text-overflow: ellipsis` on the label. `nowrap` alone stopped it wrapping and being bisected by the clip, but left a hard mid-glyph cut, and the call sites that feed this are exactly the ones with long strings -- Upload.js and FileBrowser.js label with a filename, Files.js with the error string. The one-line test was close to circular: with `nowrap` applied, one line box is almost a restatement of the rule. It now also asserts the computed `nowrap` and `ellipsis`, and that the line is genuinely WIDER than the space it has -- without that, a label that simply fits would satisfy it. Dropped a dead ternary from the air-around-label test; it built a rect nothing used and made it look as though the measurement came from somewhere it did not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:03:31 -06:00
expect(range.getClientRects().length, 'one line box').to.equal(1);
/*
* And that one line is genuinely wider than the space it has -- otherwise the
* test proves nothing, since a label that fits occupies one line either way.
* This is the case that used to wrap and get bisected by the clip.
*/
expect(range.getBoundingClientRect().width, 'the label really is too long')
.to.be.greaterThan($text[0].getBoundingClientRect().width);
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
});
});
it('separates bars that are stacked directly on one another', () => {
// The Status page's CPU and RAM bars are bare siblings in a Panel and were touching.
cy.mountUI(
<Panel>
<Progress percent={20} label='CPU Usage'/>
<Progress percent={70} label='RAM Usage'/>
</Panel>,
{theme: 'light'},
);
cy.get('.wrolpi-progress').should(($bars) => {
const [first, second] = [...$bars].map(b => b.getBoundingClientRect());
expect(second.top - first.bottom, 'gap between stacked bars').to.be.at.least(6);
});
});
it('adds no gap to a bar its container already spaces', () => {
/*
* The other half, and the reason for `* +` rather than a blanket margin: the drive
* bandwidth bars each sit alone in a Grid column, which supplies the gutters. A
* blanket margin would add a second one on top.
*/
cy.mountUI(
<Panel>
<div><Progress percent={20} label='nbd0 read'/></div>
<div><Progress percent={30} label='nbd0 write'/></div>
</Panel>,
{theme: 'light'},
);
cy.get('.wrolpi-progress').should(($bars) => {
[...$bars].forEach((bar, index) =>
expect(getComputedStyle(bar).marginTop, `bar ${index} is an only child`)
.to.equal('0px'));
});
});
themeNames.forEach((theme) => {
it(`reads its label against the track in ${theme}`, () => {
/*
* The label spans the whole bar, so it sits on the fill AND on the track. This
* asserts the track half only, and that is deliberate: over the FILL it measures
* 5.49 in light but 2.35 / 2.48 / 2.74 in dark, night and amber -- below any
* legibility floor. Fixing that needs a per-half text color, which is a design
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
* decision rather than a bug fix, so it is reported rather than quietly asserted
* at a threshold low enough to pass. See the note in ui.css.
*/
cy.mountUI(bar({percent: 20, label: 'CPU Usage'}), {theme});
cy.get('.wrolpi-progress').should(($bar) => {
const text = toRgb(getComputedStyle(
$bar[0].querySelector('.wrolpi-progress-text')).color);
const track = toRgb(getComputedStyle($bar[0]).backgroundColor);
expect(contrast(text, track), 'label against the empty part of the bar')
.to.be.at.least(4.5);
});
});
});
it('keeps the indeterminate band inside the bar', () => {
/*
test: act on review — a test that could not pass with Reduce Motion on The indeterminate test read the band's position out of a running animation and asserted it had left the box. Two problems, and the second is the serious one: it samples a moving target, and under `prefers-reduced-motion` the slide is replaced by `width: 100%` with no negative margin, so the band never leaves the box and the assertion is permanently false. Anyone with Reduce Motion turned on -- or a CI host with it set -- gets a hard failure on a correct build. Reproduced it rather than taking it on faith: forcing the reduced-motion branch for the whole run fails the old form and passes the new one. The band is pinned now, to where the animation's first keyframe puts it, and the assertion is on the clip plus that escape. Deterministic, and true on any machine. Added the other branch too: with motion suppressed the bar fills instead of sliding, and a band that never moves must never leave the box. `text-overflow: ellipsis` on the label. `nowrap` alone stopped it wrapping and being bisected by the clip, but left a hard mid-glyph cut, and the call sites that feed this are exactly the ones with long strings -- Upload.js and FileBrowser.js label with a filename, Files.js with the error string. The one-line test was close to circular: with `nowrap` applied, one line box is almost a restatement of the rule. It now also asserts the computed `nowrap` and `ellipsis`, and that the line is genuinely WIDER than the space it has -- without that, a label that simply fits would satisfy it. Dropped a dead ternary from the air-around-label test; it built a rect nothing used and made it look as though the measurement came from somewhere it did not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:03:31 -06:00
* The band slides on `margin-left` from -35% to 100%, so it genuinely does extend
* past both edges and `getBoundingClientRect` reports that whether or not it is
* painted. The clip is what keeps it out of sight.
*
* The band is PINNED here rather than sampled mid-animation. Reading a running
* animation made this both flaky and, worse, permanently false for anyone with
* Reduce Motion turned on: `prefers-reduced-motion` replaces the slide with
* `width: 100%` and no negative margin, so the band never leaves the box and an
* assertion that it does could not pass on that machine at all.
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
*/
cy.mountUI(bar({indeterminate: true, label: 'Uploading…'}), {theme: 'light'});
cy.get('.wrolpi-progress-indeterminate').should(($bar) => {
expect(getComputedStyle($bar[0]).overflow, 'the bar clips its contents')
.to.equal('hidden');
test: act on review — a test that could not pass with Reduce Motion on The indeterminate test read the band's position out of a running animation and asserted it had left the box. Two problems, and the second is the serious one: it samples a moving target, and under `prefers-reduced-motion` the slide is replaced by `width: 100%` with no negative margin, so the band never leaves the box and the assertion is permanently false. Anyone with Reduce Motion turned on -- or a CI host with it set -- gets a hard failure on a correct build. Reproduced it rather than taking it on faith: forcing the reduced-motion branch for the whole run fails the old form and passes the new one. The band is pinned now, to where the animation's first keyframe puts it, and the assertion is on the clip plus that escape. Deterministic, and true on any machine. Added the other branch too: with motion suppressed the bar fills instead of sliding, and a band that never moves must never leave the box. `text-overflow: ellipsis` on the label. `nowrap` alone stopped it wrapping and being bisected by the clip, but left a hard mid-glyph cut, and the call sites that feed this are exactly the ones with long strings -- Upload.js and FileBrowser.js label with a filename, Files.js with the error string. The one-line test was close to circular: with `nowrap` applied, one line box is almost a restatement of the rule. It now also asserts the computed `nowrap` and `ellipsis`, and that the line is genuinely WIDER than the space it has -- without that, a label that simply fits would satisfy it. Dropped a dead ternary from the air-around-label test; it built a rect nothing used and made it look as though the measurement came from somewhere it did not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:03:31 -06:00
const fill = $bar[0].querySelector('.wrolpi-progress-fill');
// Where the animation's first keyframe puts it, held still.
fill.style.animation = 'none';
fill.style.width = '35%';
fill.style.marginLeft = '-35%';
const box = $bar[0].getBoundingClientRect();
const band = fill.getBoundingClientRect();
expect(band.left, 'the band does leave the box, so the clip is load-bearing')
.to.be.lessThan(box.left - 1);
});
});
it('does not move the band at all when motion is suppressed', () => {
/*
* The other branch, and the reason the test above pins rather than samples: with
* Reduce Motion the bar fills instead of sliding, because motion was the only signal
* it had. A band that never moves must also never leave the box.
*/
cy.mountUI(bar({indeterminate: true}), {theme: 'light'});
cy.get('.wrolpi-progress-fill').should('exist');
cy.document().then((doc) => {
const probe = doc.createElement('style');
probe.textContent = `
.wrolpi-progress-indeterminate .wrolpi-progress-fill {
animation: none; width: 100%; opacity: 0.5;
}`;
doc.head.appendChild(probe);
});
cy.get('.wrolpi-progress-indeterminate').should(($bar) => {
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
const box = $bar[0].getBoundingClientRect();
const band = $bar[0].querySelector('.wrolpi-progress-fill').getBoundingClientRect();
test: act on review — a test that could not pass with Reduce Motion on The indeterminate test read the band's position out of a running animation and asserted it had left the box. Two problems, and the second is the serious one: it samples a moving target, and under `prefers-reduced-motion` the slide is replaced by `width: 100%` with no negative margin, so the band never leaves the box and the assertion is permanently false. Anyone with Reduce Motion turned on -- or a CI host with it set -- gets a hard failure on a correct build. Reproduced it rather than taking it on faith: forcing the reduced-motion branch for the whole run fails the old form and passes the new one. The band is pinned now, to where the animation's first keyframe puts it, and the assertion is on the clip plus that escape. Deterministic, and true on any machine. Added the other branch too: with motion suppressed the bar fills instead of sliding, and a band that never moves must never leave the box. `text-overflow: ellipsis` on the label. `nowrap` alone stopped it wrapping and being bisected by the clip, but left a hard mid-glyph cut, and the call sites that feed this are exactly the ones with long strings -- Upload.js and FileBrowser.js label with a filename, Files.js with the error string. The one-line test was close to circular: with `nowrap` applied, one line box is almost a restatement of the rule. It now also asserts the computed `nowrap` and `ellipsis`, and that the line is genuinely WIDER than the space it has -- without that, a label that simply fits would satisfy it. Dropped a dead ternary from the air-around-label test; it built a rect nothing used and made it look as though the measurement came from somewhere it did not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:03:31 -06:00
expect(band.left, 'band starts at the bar').to.be.closeTo(box.left, 2);
expect(band.right, 'band ends at the bar').to.be.closeTo(box.right, 2);
ui: progress bars get room for their label, and keep their band inside Three things, plus an answer to why two sets of bars on the same page were spaced differently. The bar was 16px tall with an 11px bold label, leaving about half a pixel of air above and below. On the Status page that is 44 of them. Now 22px with a 12px label -- these labels carry device names and units, not just a number. The indeterminate band escaped the bar. It slides on `margin-left` from -35% to 100%, and nothing clipped it, so the animation ran from outside the left edge to outside the right one. `overflow: hidden` on the bar. The CPU and RAM bars were touching while the drive-bandwidth bars on the same page were not, and the difference was not the bars: CPU and RAM are bare siblings inside a Panel, while each bandwidth bar sits alone in a Grid column and takes its spacing from the Grid. `* + .wrolpi-progress` distinguishes those two by itself -- it fires only when a bar actually follows something, so an only-child bar in a column is untouched. A blanket margin would have doubled the Grid's gutter, and that is asserted too. The gallery gains a Progress section: six percentages, custom labels, no label, indeterminate, and the four roles. Its own demo gaps were removed so what it shows is the spacing the component really has. MEASURED while building the gallery, and NOT fixed: the label reads 5.49:1 against the fill in light -- the brightness filter is what buys that -- but 2.35 in dark, 2.48 in night and 2.74 in amber. Against the empty track it is 5.2 to 15:1 everywhere. Reaching AA over the fill needs the label drawn twice and clipped at the fill boundary so each half takes its own colour, and in night not even that suffices: `--text` is only about 4:1 against pure black and a fill is lighter than black by definition. Recorded in ui.css and in the test, which asserts the track half only rather than picking a threshold low enough to pass. One test was unfalsifiable and is rewritten. "Keeps a long label from widening the bar" cannot fail: the label is `position: absolute; inset: 0` and takes no part in its parent's width. What a long label actually does is wrap to a second line inside a 22px bar and get cut in half by the new clip, so the test measures line boxes now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:52:10 -06:00
});
ui: semantic roles, so night and amber can tell severity apart at all A component now asks for what a colour MEANS -- `danger` -- and the theme decides how that looks. Five roles: neutral, info, success, warning, danger. The names are the ones already in the tree. `--primary/--success/--warning/ --danger` were declared in tokens.css with ZERO consumers, and `MessageKind` was already `info|success|warning|error`; this is one vocabulary instead of three. `error` stays a valid kind because 26 call sites write it, and `danger` is the same thing under the token's name for new code. The token set is the easy half. Light and dark spend a hue per role. Night is red and nothing else and amber is amber and nothing else, and there a role has to be a step on a BRIGHTNESS ramp -- which is why this was worth doing: night --orange is byte-identical to --text --yellow is byte-identical to --amber amber the same collisions, one hue over A call site picking between hue names in those themes is picking between synonyms. That is why all four toast kinds were the same pixel in night, and why an error and an informational message were indistinguishable. Both ramps are built rather than copied: every role clears 3:1 on the panel (neutral is allowed lower -- for pending and disabled, dim IS the signal), severity is strictly increasing in contrast, and danger reaches that theme's own --text brightness so the loudest role is never quieter than prose. Amber needed its own scale, not night's: its --text is 8.6:1 where night's is 5.0:1, so night's ramp would have left every role dimmer than ordinary text. Fixes in passing: night's info was 2.29:1, under the 3:1 floor. And Status loses its three `html[data-theme="night"]` overrides entirely -- it was the one component already encoding severity by brightness by hand, and the roles are that generalised. Roles are registered as Mantine colors too, so `color='danger'` works anywhere `color='red'` does. `isMonochromeTheme` is a new predicate in themes/names. It is the same set as `explicitOnlyThemes` today and deliberately separate: one is about how a theme is chosen, the other about what a theme has to work with. Scope: tokens plus the library. The ~24 app-level `color='...'` call sites are a follow-up -- they need a judgement per site, and two of them already disagree (Downloads.js colours the same "Download error" label `orange` on one line and `red` on another). The 22 `violet` uses are not semantic at all and stay hues. Tests: the ramp claims are asserted per theme in a browser, and the ordering and danger-vs-text claims run ONLY for the monochrome themes -- in light, blue is darker than green on white, so a brightness ramp there would fail a design that is perfectly fine. Every guard checked red against a planted regression, including the original bug (warning and danger collapsed to one value in night) and night's info back at its old 2.29:1. The roles were folded into each theme's own block rather than kept in a standalone one, so the existing "same tokens in every theme" and "only red hues in night" guards cover them for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:31:44 -06:00
});
});
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
describe('a table header is a surface, not just bold text', () => {
themeNames.forEach((theme) => {
it(`separates the header from every body row in ${theme}`, () => {
/*
* Mantine gives thead no background, so the header painted whatever was behind
* the table -- which is exactly what an unstriped body row paints. Against a
* striped body the header read as one more stripe, and weight was the only
* thing telling them apart. None of this is visible to jsdom: the colors are
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
* tokens, and "what is behind an unstriped row" is a question about painting.
*/
cy.mountUI(sampleTable, {theme});
cy.get('thead th').first().should(($th) => {
const header = getComputedStyle($th[0]).backgroundColor;
expect(header, 'the header paints a surface of its own')
.to.not.match(/^rgba\(.*,\s*0(\.0+)?\)$/);
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
const page = hexToRgb(getComputedStyle(document.documentElement)
.getPropertyValue('--bg').trim());
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
const rows = [...Cypress.$('tbody tr')].map(row => {
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
/*
* An unstriped row paints nothing, so what shows through is the page.
* That is `--bg`, taken from the token -- NOT
* getComputedStyle(documentElement).backgroundColor, which is
* `rgba(0, 0, 0, 0)` because `body` carries the page color and the root
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
* element carries none. Comparing an opaque header against that string
* can never fail, which is how this passed before it was fixed.
*/
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
const own = getComputedStyle(row).backgroundColor;
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
return /^rgba\(.*,\s*0(\.0+)?\)$/.test(own) ? page : own;
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
});
expect(rows.length).to.be.greaterThan(2);
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
// Both kinds have to be present or the comparison only covers one of them.
expect(new Set(rows).size, 'the body is striped').to.equal(2);
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
rows.forEach((row, index) => {
expect(header, `header vs body row ${index}`).to.not.equal(row);
});
});
});
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
it(`rules off the header more heavily than it rules between rows in ${theme}`, () => {
/*
* The header/body division is the one that carries meaning -- everything above
* it names, everything below is data -- so it is the one line allowed to be
* loud. Per theme, because a theme is free to restyle borders.
*/
cy.mountUI(sampleTable, {theme});
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
cy.get('thead th').first().should(($th) => {
const header = getComputedStyle($th[0]);
const row = getComputedStyle(Cypress.$('tbody tr')[0]);
expect(parseFloat(header.borderBottomWidth), 'header rule width')
.to.be.greaterThan(parseFloat(row.borderBottomWidth));
});
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
});
});
});
describe('table rules', () => {
themeNames.forEach((theme) => {
it(`keeps the rule between rows quieter than the table outline in ${theme}`, () => {
/*
* With a rule under every row at full border strength, a long table reads as a
* stack of boxes rather than a list. `--table-line` is the quieter token; the
* outline around the table is not a row rule and keeps `--border`.
*
* Measured as contrast against the row's own surface rather than compared to a
* token, so the claim is about what the eye gets.
*/
cy.mountUI(sampleTable, {theme});
cy.get('tbody tr').first().should(($row) => {
const table = Cypress.$('table')[0];
const token = (name) => hexToRgb(getComputedStyle(document.documentElement)
.getPropertyValue(name).trim());
/*
* Against `--panel`, the surface a row paints on. Not against the root
* background: nothing paints <html> under a mounted component, so it reads
* `rgba(0, 0, 0, 0)`, and measuring both lines against black ranks the
* *paler* one as louder -- which is how this assertion first passed
* backwards.
*/
const surface = token('--panel');
const rule = contrast(getComputedStyle($row[0]).borderBottomColor, surface);
const outline = contrast(getComputedStyle(table).borderTopColor, surface);
expect(rule, 'row rule is quieter than the table outline').to.be.lessThan(outline);
});
});
it(`draws nothing between the cells of a row in ${theme}`, () => {
cy.mountUI(sampleTable, {theme});
cy.get('tbody tr').first().find('td').first().should(($cell) => {
expect(parseFloat(getComputedStyle($cell[0]).borderRightWidth),
'no rule between columns').to.equal(0);
});
});
});
});
describe('a file row lines its icon up with its name', () => {
/*
* The file browser writes an icon and a filename as inline siblings in one cell. An
* inline SVG sits on the text baseline, so a 24px glyph beside 13px text hangs well
* above it -- the icon looked centred in the row and the name looked like it was
* resting on the icon's floor.
*
* Purely a question of layout: jsdom returns zeros from getBoundingClientRect, so
* nothing there can tell a centred glyph from one hanging off a baseline.
*/
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
/*
* 24px, which is what the app renders. A file row calls `<FileIcon size={null}/>`, and
* a null size falls past Icon's 'small' default to Tabler's own 24. The default 16px
* icon is a much easier centring case and can look fine while the real one is visibly
* off, so a fixture using it would be testing a size the file browser never draws.
*/
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
const fileRow = <Table>
<Table.Body>
<Table.Row>
<Table.Cell className='file-path'>
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
<Icon name='file audio' size={24}/>
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
big_buck_bunny.mp3
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>;
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
// A folder that is also ignored draws two glyphs before its name; they touched too.
const folderRow = <Table>
<Table.Body>
<Table.Row>
<Table.Cell className='file-path'>
<Icon name='folder' size={24}/>
<Icon name='eye slash' size={24}/>
config/
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>;
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
it('centres the glyph against the text rather than sitting it on the baseline', () => {
cy.mountUI(fileRow, {theme: 'light'});
cy.get('td.file-path svg').should(($icon) => {
const icon = $icon[0].getBoundingClientRect();
// The text node's own box, which is what the eye compares the icon to.
const range = document.createRange();
range.selectNodeContents($icon[0].nextSibling);
const text = range.getBoundingClientRect();
const iconCentre = icon.top + icon.height / 2;
const textCentre = text.top + text.height / 2;
expect(Math.abs(iconCentre - textCentre), 'icon centre vs text centre')
.to.be.at.most(2);
});
});
it('leaves a gap between the glyph and the name', () => {
// They touched: the folder icon ran into the first letter of its own folder name.
cy.mountUI(fileRow, {theme: 'light'});
cy.get('td.file-path svg').should(($icon) => {
const range = document.createRange();
range.selectNodeContents($icon[0].nextSibling);
const gap = range.getBoundingClientRect().left - $icon[0].getBoundingClientRect().right;
expect(gap, 'gap between icon and filename').to.be.greaterThan(2);
});
});
test: act on review — two of the new table guards could not fail The jest column-border test asserted the TABLE lacks `data-with-column-border`. Mantine puts that marker on the cells, never on the table, so the expectation held whether column borders were on or off. It now looks for the marker anywhere in the tree. I did plant a regression for this one -- and ran it against cypress only, where a different test caught it. The plant was right and the suite was wrong, which is a new way to get a false green and worth naming: run every suite that claims the behaviour, not the one that happens to be open. The header-surface test fell back to `getComputedStyle(documentElement) .backgroundColor` for an unstriped row. `body` carries the page colour and the root element carries none, so that is `rgba(0, 0, 0, 0)` and any opaque header passed. It now compares against the `--bg` token, which is what actually shows through an unstriped row, and additionally asserts the body really is striped so both kinds are covered. Planted the exact case the old form could not see -- a header painted `--bg` -- and it goes red in all four themes. The file-row fixture rendered a 16px icon; the app renders 24. A file row calls `<FileIcon size={null}/>`, and a null size falls past Icon's 'small' default to Tabler's 24 -- the harder centring case, and the one the CSS comment describes. Added the two-glyph row as well, since a folder that is also ignored draws two icons before its name and those touched each other too. The header-rule-width assertion now runs per theme with the rest of the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 17:04:53 -06:00
it('keeps two glyphs apart, and both clear of the name', () => {
cy.mountUI(folderRow, {theme: 'light'});
cy.get('td.file-path svg').should(($icons) => {
expect($icons.length, 'two glyphs').to.equal(2);
const [folder, ignored] = [...$icons].map(icon => icon.getBoundingClientRect());
expect(ignored.left - folder.right, 'gap between the two glyphs')
.to.be.greaterThan(2);
const range = document.createRange();
range.selectNodeContents($icons[1].nextSibling);
expect(range.getBoundingClientRect().left - ignored.right, 'gap before the name')
.to.be.greaterThan(2);
// And the second glyph is centred on the name as well, not just the first.
const text = range.getBoundingClientRect();
expect(Math.abs((ignored.top + ignored.height / 2) - (text.top + text.height / 2)),
'second glyph centre vs text centre').to.be.at.most(2);
});
});
ui: give tables a real header, drop the column grid, quiet the row rules Three things the file browser made obvious. The header was not a surface. Mantine gives thead no background at all, so the header painted whatever was behind the table -- which is exactly what an unstriped body row paints. Against a striped body it read as one more stripe, and bold type was the only thing distinguishing it. It now carries `--head`, the token that already means "recessed surface", with a full-strength 2px rule under it: the header/body division is the one line in a table that carries meaning, so it is the one allowed to be loud. Column borders are gone. A line around every cell is a lot of ink to repeat what the column headings already say, and it was half of why the header disappeared -- a bordered header cell looks like a cell in a grid. Row rules were `--border`, the same weight as the outline around the table, so a long table read as a stack of boxes. They now use `--table-line`, a new token per theme sitting between the surface and `--border`. The table outline is not a row rule and keeps `--border`; Mantine draws both from `--table-border-color`, so that had to be restated. In the file browser an icon and a filename are inline siblings in one cell. An inline SVG sits on the text baseline, so a 24px glyph beside 13px text hung above it -- the icon looked centred in the row and the name looked like it was resting on the icon's floor. `vertical-align: middle` centres it, and the margin is a gap that was never there at all: the folder icon touched the first letter of its own name. Cypress now loads App.css, as the app does. Without it a spec covering the file browser rows measures a component the app never renders. One jest test and eleven browser tests, each checked red against a planted regression. Two notes for the next person: - `html .mantine-Table-table` is specificity, not decoration. Mantine declares --table-border-color on its own hashed class, which ties with `.mantine-Table-table` and wins on source order. - the "quieter than the outline" test measures both lines against `--panel`. Nothing paints <html> under a mounted component, so measuring against the root background compares them to black, which ranks the *paler* line as the louder one -- the assertion passed backwards until it was pointed at the surface the rules actually sit on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:46:50 -06:00
});
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
describe('StatisticGroup separates its statistics with nothing but space', () => {
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
/*
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
* The group has no frame, no rules between cells and no surface of its own: the
* statistics sit on whatever they were dropped onto and take its color. That leaves
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
* the gap as the only thing keeping them apart, and `auto-fit` decides how many rows
* there are at paint time -- so whether they actually stay apart is a question only a
* browser can answer. jsdom has no tracks, no rows and no widths.
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
*/
// Narrow enough that six statistics cannot fit on one row at a 150px minimum.
ui: let a landscape poster fill a one-column card, and fix three scale-blind tests `--card-poster-max-height` is a fixed height, so it stops scaling with the card: held to 220px, a 16:9 thumbnail is 391px wide, and any card wider than that centred it with empty panel on both sides. That is every video card at one column -- a phone, or any window under about 456px of content width. The cap is now `max(var(--card-poster-max-height), 56.25cqw)` with the poster band as the query container. 56.25cqw is nine sixteenths of the card: exactly the height of a 16:9 image that fills the width, and the same number states the rule for every other ratio -- a poster may be as tall as a 16:9 slice of this card and no taller. So a portrait book cover still reads as a band rather than a column, and now grows with the card instead of stopping at 220px. `max()` rather than `min()` so the floor wins on a narrow card. The gap pre-dated the interface scale, below about 414px, but the scale widened the range it shows in: the track minimum went from 200px to 220px, so one column now starts at 456px of content width instead of 414. Every existing poster case mounted a 233px card, which is why the wide card's own failure went unseen for the whole migration. Two cases added on a 451px card: a landscape poster reaches the edges, and a portrait cover stays a band. Three tests carried a hardcoded px expectation, which is a hidden assertion that the interface scale is 1. All three failed at 1.1, in names that said nothing about size -- and I did not catch them because I ran jest and the build for the scale change but not cypress, which AGENTS.md asks for on frontend work: - `cardPosterCap()` read `--card-poster-max-height` with parseFloat. The cap is rem now, so it returned 12.5 and failed a within(80, 240) bound -- taking five poster tests with it. It resolves through the root font-size and checks the unit. - `inNarrowColumn` was a fixed 340px, chosen to hold two 150px statistic tracks. At 165px tracks it became one column, so a test about the gap BETWEEN columns had no second column. It is now 340px times the scale, because "narrow" means narrow relative to the type. - The APIButton size test asserted 36px for `small`. It now measures against a real `sm` button, which is the claim it was making -- that `small` resolves to `sm` -- and holds at any scale. A `uiScale()` helper reads the token so no further test has to name a pixel count. Verified: ui-layout 248 passing, 0 failing; 1141 jest tests / 65 suites; clean build; browser-checked at 400/451/500/700/1200px of grid width, no side gap at any of them. The 12 remaining component failures are the pre-existing Semantic-era selector failures in Tags, Channels, Download and Inventory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:02:15 -06:00
/*
* "Narrow" has to mean narrow RELATIVE TO THE TYPE, or the width stops meaning anything
* when the interface scale changes. At a fixed 340px this held two 150px statistic
* tracks; the scale took the track to 165px and 340px became a single column, so a test
* about the gap between columns had no second column to measure.
*/
const inNarrowColumn = (children) =>
<div style={{width: `${Math.round(340 * uiScale())}px`}}>{children}</div>;
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
const sixStatistics = <StatisticGroup>
<Statistic value='1,432' label='Videos'/>
<Statistic value='896' label='Archives'/>
<Statistic value='12,904' label='Files'/>
<Statistic value='87.4 GiB' label='Free space'/>
<Statistic value='14' label='Zim files'/>
<Statistic value='312' label='eBooks'/>
</StatisticGroup>;
const rowTops = (cells) => [...new Set(
[...cells].map((cell) => Math.round(cell.getBoundingClientRect().top))
)].sort((a, b) => a - b);
it('wraps into rows at this width, so the rest of these tests mean something', () => {
cy.mountUI(inNarrowColumn(sixStatistics));
cy.get('.wrolpi-statistic-cell').should(($cells) =>
expect(rowTops($cells).length, 'rows the group wrapped into').to.be.greaterThan(1));
});
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
it('leaves real space between wrapped rows', () => {
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
/*
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
* With nothing drawn between them, the space *is* the separation. The old group ruled
* columns only -- a `border-right` on every cell but the last, which says nothing about
* rows -- so wrapped rows sat flush and the Docs page's seven statistics ran together
* into one block on a phone. A row boundary has to be a gap you can see.
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
*/
cy.mountUI(inNarrowColumn(sixStatistics));
cy.get('.wrolpi-statistic-cell').should(($cells) => {
const cells = [...$cells].map((cell) => cell.getBoundingClientRect());
const tops = rowTops($cells);
for (let row = 1; row < tops.length; row++) {
const previousRowBottom = Math.max(...cells
.filter((rect) => Math.round(rect.top) === tops[row - 1])
.map((rect) => rect.bottom));
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
expect(tops[row] - previousRowBottom, `space above row ${row + 1}`)
.to.be.at.least(12);
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
}
});
});
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
it('leaves more space between columns than between rows', () => {
/*
* Two statistics side by side have only air between them, and a value sitting close to
* the label of the one beside it reads as a single column of text. Stacked statistics
* already have the label's own line between them, so they need less.
*/
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
cy.mountUI(inNarrowColumn(sixStatistics));
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
cy.get('.wrolpi-statistic-group').should(($group) => {
const styles = getComputedStyle($group[0]);
const columnGap = parseFloat(styles.columnGap);
const rowGap = parseFloat(styles.rowGap);
expect(rowGap, 'row gap').to.be.at.least(12);
expect(columnGap, 'column gap is the wider of the two').to.be.greaterThan(rowGap);
});
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
cy.get('.wrolpi-statistic-cell').should(($cells) => {
const cells = [...$cells].map((cell) => cell.getBoundingClientRect());
const firstRow = cells
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
.filter((rect) => Math.round(rect.top) === rowTops($cells)[0])
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
.sort((a, b) => a.left - b.left);
expect(firstRow.length, 'columns in the first row').to.be.greaterThan(1);
for (let column = 1; column < firstRow.length; column++) {
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
expect(firstRow[column].left - firstRow[column - 1].right, 'space between columns')
.to.be.at.least(20);
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
}
});
});
it('takes no color of its own, so it sits on the surface it is given', () => {
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
/*
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
* This is the point of having no chrome: dropped on the page it reads as page, dropped
* in a Panel it reads as panel. A background on the group or a cell -- which is how
* this was built first, to carry hairlines -- would show as a patch of the wrong color
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
* on every surface but the one it was picked for.
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
*/
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
cy.mountUI(<div style={{background: 'rgb(1, 2, 3)', padding: 10}}>{sixStatistics}</div>);
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
cy.get('.wrolpi-statistic-group').should(($group) => {
const styles = getComputedStyle($group[0]);
expect(styles.backgroundColor, 'group is transparent').to.equal('rgba(0, 0, 0, 0)');
expect(styles.borderTopWidth, 'no frame').to.equal('0px');
expect(styles.borderRightWidth, 'no frame').to.equal('0px');
expect(styles.borderBottomWidth, 'no frame').to.equal('0px');
expect(styles.borderLeftWidth, 'no frame').to.equal('0px');
expect(styles.outlineStyle, 'no outline standing in for a frame').to.equal('none');
});
cy.get('.wrolpi-statistic-cell').each(($cell) => {
const styles = getComputedStyle($cell[0]);
expect(styles.backgroundColor, 'cell is transparent').to.equal('rgba(0, 0, 0, 0)');
expect(styles.borderRightWidth, 'no rule between cells').to.equal('0px');
expect(styles.outlineStyle, 'no rule between cells').to.equal('none');
});
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
});
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
it('clears whatever precedes it, but does not indent itself', () => {
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
/*
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
* Nothing frames the group any more, so a Header directly above it put the heading
* text against the first row of values. A plain `margin-top` fixed that and broke
* Apps, which opens each of its Panels with a group: the values were pushed down off
* the panel's top padding while the bottom stayed put, leaving every panel lopsided.
* So the margin is conditional on having a sibling before it.
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
*/
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
cy.mountUI(<div>
<div className='probe-panel' style={{padding: 20}}>
<StatisticGroup>
<Statistic value='1,097' label='All files'/>
</StatisticGroup>
</div>
<div className='probe-with-header' style={{padding: 20}}>
<Header as='h2'>Files</Header>
<StatisticGroup>
<Statistic value='1,097' label='All files'/>
</StatisticGroup>
</div>
</div>);
cy.get('.probe-panel .wrolpi-statistic-group').should(($group) =>
expect(getComputedStyle($group[0]).marginTop, 'first child of a panel adds nothing')
.to.equal('0px'));
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
cy.get('.probe-with-header').then(($panel) => {
const header = $panel[0].querySelector('.wrolpi-header').getBoundingClientRect();
const group = $panel[0].querySelector('.wrolpi-statistic-group').getBoundingClientRect();
expect(group.top - header.bottom, 'space below a heading').to.be.at.least(10);
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
});
});
it('hides the cell of a statistic that rendered nothing', () => {
/*
* Status omits the fan reading on a device with no fan connector -- most of them --
* by returning null from FanRPMStatistic. The group still emits its cell, because it
* cannot render a child to find out, so `:empty` has to take the cell out of the grid.
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
* Left in, it held a track open and opened a hole in the middle of the row.
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
*/
const NoFanFitted = () => null;
cy.mountUI(<StatisticGroup>
<Statistic value='0.4' label='1 Min. Load'/>
<NoFanFitted/>
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
<Statistic value='48' label='Temp C'/>
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
</StatisticGroup>);
cy.get('.wrolpi-statistic-cell').should('have.length', 3);
cy.get('.wrolpi-statistic-cell').filter(':empty').should('not.be.visible');
cy.get('.wrolpi-statistic-cell').filter(':empty').should(($cell) =>
expect($cell[0].getBoundingClientRect().width, 'the empty cell takes no track').to.equal(0));
});
themeNames.forEach((theme) => {
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
it(`reads its value and label from ${theme}'s tokens`, () => {
// The contrast between value and label is all that structures a statistic now that
// there is no cell around it, so both colors have to resolve in every theme.
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
cy.mountUI(inNarrowColumn(sixStatistics), {theme});
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
cy.get('.wrolpi-statistic-value').first().then(($value) => {
const value = getComputedStyle($value[0]).color;
cy.get('.wrolpi-statistic-label').first().should(($label) => {
const label = getComputedStyle($label[0]).color;
expect(value, 'value color resolved').to.match(/^rgba?\(/);
expect(label, 'label color resolved').to.match(/^rgba?\(/);
ui: statistics carry no chrome, only spacing The group had a frame, a surface and a hairline between every cell. It now has none of those: a plain responsive grid, transparent, so the statistics sit on whatever they were dropped onto and take its colour -- the page on the gallery, a Panel on Apps and Status. That also retires the problem the previous commit went two rounds on. Ruling the cells needs a technique that survives wrapping, because `auto-fit` settles the number of rows at paint time: a border per cell rules columns but not rows, and a border-coloured background behind a 1px gap rules both but paints every track no cell landed in. With no rules to draw, neither case exists. The gap is wider across than down, since two statistics side by side have only air between them while stacked ones already have the label's line. The margin above the group is conditional on having a sibling before it. A plain `margin-top` reads correctly under the Header that precedes most groups, but Apps opens each of its Panels with one, and there it pushed the values down off the panel's top padding while the bottom stayed put, leaving every panel lopsided. Five browser tests described hairlines that no longer exist. They are replaced by the claims that now hold -- real space between wrapped rows, a wider column gap than row gap, transparency and no frame anywhere, and the conditional margin -- each verified red first: against flush rows for the spacing, against a background-carried hairline for the transparency, and against an unconditional margin for the panel case. Per-theme, the pair to check is no longer the hairline and the surface but the value and the label: with nothing framing a statistic, the contrast between those two is the only thing giving it structure.
2026-07-30 19:17:38 -06:00
// The label is the muted token and the value is body text; if either fell
// back the two would come out the same and the statistic would flatten.
expect(label, 'label is distinct from the value').to.not.equal(value);
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
});
});
});
});
});
describe('a tag is legible in every theme, whatever color the user picked', () => {
/*
* Tag colors are the user's, stored per tag -- the only thing in the app painted with a
* value no theme chose. Tags.js calculates black or light text against that fill, and
* night discards the fill entirely (a filled tag would be a bright patch) while amber
* replaces it with its own. Whether the text still reads afterwards is a question about
* resolved color against a real painted surface, so it can only be asked here.
*/
// The extremes of the black-or-light decision, plus a mid tone.
const TAG_COLORS = [
['Reference', '#f2f2f2'], // near-white: text is calculated black
['Archived', '#1b1c1d'], // near-black: text is calculated light
['Water', '#2185d0'],
];
const tags = <div>
{TAG_COLORS.map(([name, color]) => <span
key={name}
className='wrolpi-label wrolpi-tag'
data-tag={name}
style={{'--label-color': color, '--label-text': contrastingColor(color)}}
>{name}</span>)}
</div>;
themeNames.forEach((theme) => {
TAG_COLORS.forEach(([name]) => {
it(`reads ${name} against its real surface in ${theme}`, () => {
cy.mountUI(tags, {theme});
/*
* 4.5:1 is WCAG AA for body text. Before this, night measured 1.1:1 on a
* near-white tag -- the black text calculated for that fill, painted onto a
* transparent tag over a near-black page. The tag was readable only as an
* empty outline.
*/
cy.contrastRatio(`[data-tag="${name}"]`).should('be.at.least', 4.5);
});
});
});
it('detects the unreadable tag this started as, so the check has teeth', () => {
/*
* The original defect, reproduced deliberately: the calculated text color written to
* `color` inline, which no stylesheet rule can outrank. In night the tag becomes a
* transparent outline over a near-black page, so the black text calculated for a
* near-white fill is painted onto near-black.
*
* Asserting that this IS unreadable proves contrastRatio measures the surface actually
* behind the text rather than the tag's own missing background. A contrast check that
* has never gone red is indistinguishable from one that cannot.
*/
cy.mountUI(
<span
className='wrolpi-label wrolpi-tag'
data-tag='Legacy'
style={{'--label-color': '#f2f2f2', color: contrastingColor('#f2f2f2')}}
>Reference</span>,
{theme: 'night'},
);
cy.contrastRatio('[data-tag="Legacy"]').should('be.lessThan', 1.5);
});
it('is at least as large as the Semantic label it replaced', () => {
// The first pass came out at 11.5px against Semantic's 12px and read as shrunken.
// A tag is a hit target as well as a word, so it also has to stay tall enough to hit.
cy.mountUI(tags);
cy.get('.wrolpi-tag').first().should(($tag) => {
expect(parseFloat(getComputedStyle($tag[0]).fontSize), 'font size').to.be.at.least(12);
expect($tag[0].getBoundingClientRect().height, 'height').to.be.at.least(26);
});
});
ui: larger tags, tighter rows A tag's word was 78% of the size of the body text beside it, which is right for a label -- an annotation on something else, like the count next to a tab's name -- and wrong for a tag, which is the whole content of its chip and the thing a wall of them is scanned for. On the dashboard, where the tags are the page, it read as a footnote. Now 87.5%. The point grew with it, because it has to: its diagonal is the body's height, or its two edges meet the body short of the corners and it reads as a notch stuck on the side. 21px a side for the 30.2px body. That is also the one length here that went UP -- the margin reserving room for the point was a third of a pixel short of the larger one, which is enough to clip against the tag before it. Padding is unchanged. The gaps are two defects rather than a design: - The link wrapper carried 0.3em either side, from when these were Semantic labels with no margin of their own. A tag already reserves the room its point needs, so that was 0.3em twice on top of it: two tags 34.7px apart where the point needs 18.4px. Now 25.3px, leaving about 7px of visible space. - TagsLinkGroup spread its props down to every chip, so the dashboard's marginTop -- meant to space the row below its heading -- landed on all 34 tags. That is not a margin above the row; it is 7.7px added between every wrapped row of it. Row gaps 18.5px -> 12px. Tests first: both margins fail on the real values (0.3em on the link, 0.5em on the chip), and the size is asserted as a ratio to body text so it cannot be satisfied by the interface scale, which raised tag and prose together and left the tag exactly as small next to it. Verified in all four themes, including night, where the point is two strokes rather than a solid diamond and so shows a corner mismatch plainly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 15:20:47 -06:00
it("sets a tag's word within a fifth of the body text it sits beside", () => {
/*
* Matching Semantic was the wrong target for this one. A tag is not an annotation on
* something else -- it is the whole content of its chip, and the thing a user scans a
* wall of them for -- so it wants to read as text, not as a footnote. At 12.5px design
* against a 16px base it was 78% of the prose around it, and on the dashboard, where
* the tags ARE the content, that read as small.
*
* Expressed as a ratio rather than a pixel count so the assertion cannot be satisfied
* by the interface scale alone: 1.1 raised the tag to 13.75px and the prose to 17.6px
* at the same time, leaving the tag exactly as small next to it as before.
*/
cy.mountUI(tags);
cy.get('.wrolpi-tag').first().should(($tag) => {
const tag = parseFloat(getComputedStyle($tag[0]).fontSize);
const body = parseFloat(getComputedStyle(Cypress.$('html')[0]).fontSize);
expect(tag / body, "the tag's share of body text").to.be.at.least(0.8);
// And is still a chip rather than prose in a colored box.
expect(tag / body, 'but not the same size as prose').to.be.at.most(0.95);
});
});
});
describe('a tag looks like a physical tag', () => {
const tag = <span
className='wrolpi-label wrolpi-tag'
style={{'--label-color': '#2185d0', '--label-text': '#ffffff'}}
>Water</span>;
it('has a pointed left edge that spans the full height', () => {
/*
* The point is a square rotated 45 degrees behind the left edge. Its diagonal has to
* equal the body's height, or the two edges meet the body short of its corners and the
* result reads as a notch stuck on the side rather than one tag-shaped outline.
*/
cy.mountUI(tag);
cy.get('.wrolpi-tag').should(($tag) => {
const el = $tag[0];
const height = el.getBoundingClientRect().height;
const side = parseFloat(getComputedStyle(el, '::before').width);
expect(side, 'the point is drawn at all').to.be.greaterThan(0);
expect(side * Math.SQRT2, "the point's diagonal matches the body height")
.to.be.closeTo(height, 2);
});
});
/*
* Where the tip of the point actually lands, relative to the body's left edge.
*
* The square's box spans [-side, 0] in padding-box coordinates (`right: 100%`), is shifted
* by the transform's resolved horizontal translation, and then rotates about its own centre
* -- so the tip reaches half a diagonal beyond that centre. Padding-box coordinates are
* inside the border, which is the whole reason the point needed nudging, so the border
* width comes off at the end.
*/
const tipOffset = (el) => {
const before = getComputedStyle(el, '::before');
const side = parseFloat(before.width);
const translateX = parseFloat(before.transform.match(/matrix\(([^)]+)\)/)[1].split(',')[4]);
const centre = -side + translateX + side / 2;
return centre - (side * Math.SQRT2 / 2) - parseFloat(getComputedStyle(el).borderLeftWidth);
};
/* Where the point's centre sits, relative to the body's visible (border-box) left edge. */
const pointCentreOffset = (el) => {
const before = getComputedStyle(el, '::before');
const side = parseFloat(before.width);
const translateX = parseFloat(before.transform.match(/matrix\(([^)]+)\)/)[1].split(',')[4]);
return (-side + translateX + side / 2) - parseFloat(getComputedStyle(el).borderLeftWidth);
};
it('grows the point out of the left edge rather than setting it into the body', () => {
/*
* `right: 100%` positions against the containing block's *padding* box, and the body
* carries a 1px border -- so a square centred there sits a pixel inside the visible left
* edge, and the point reads as set into the tag instead of growing out of it.
*
* Asserting the tip lands somewhere far to the left does not catch this: the un-nudged
* version's tip is only 2px further right, still well clear of the body. The claim is
* about where the point is *centred*, which is the thing that differs.
*/
cy.mountUI(tag);
cy.get('.wrolpi-tag').should(($tag) =>
expect(pointCentreOffset($tag[0]), 'the point is centred left of the visible edge')
.to.be.at.most(-2));
});
it('reserves exactly the room the point takes', () => {
// Without a margin covering the full protrusion the point prints over whatever sits to
// its left -- the previous tag in the row. The old value, 15px, was 2px short of this.
cy.mountUI(tag);
cy.get('.wrolpi-tag').should(($tag) => {
const el = $tag[0];
const needed = Math.abs(tipOffset(el));
const margin = parseFloat(getComputedStyle(el).marginLeft);
expect(margin, 'margin covers the protrusion').to.be.at.least(needed - 0.5);
// And is not wasteful about it, or tags drift apart for no visible reason.
expect(margin, 'margin is not far beyond it').to.be.at.most(needed + 3);
});
});
it('does not print the point over the first letter', () => {
/*
* A positioned pseudo-element paints above the parent's text, not behind it, and the
* point's inner half lies over the body. Removing the left padding once hid the first
* character of every tag: "Water" read as "ater".
*/
cy.mountUI(tag);
cy.get('.wrolpi-tag').should(($tag) => {
const el = $tag[0];
const styles = getComputedStyle(el);
const overlapIntoBody = parseFloat(getComputedStyle(el, '::before').width) / 2;
const textStartsAt = parseFloat(styles.paddingLeft) + parseFloat(styles.borderLeftWidth);
expect(textStartsAt, 'text starts clear of the point').to.be.greaterThan(overlapIntoBody);
});
});
it('keeps wrapped rows of tags off each other', () => {
// Tags wrap wherever they are listed, and a wrapped row was sitting on the row above.
cy.mountUI(<div style={{width: 240}}>
{['Water', 'Food', 'Medical', 'Shelter', 'Power', 'Comms'].map((name) => <span
key={name}
className='wrolpi-label wrolpi-tag'
style={{'--label-color': '#2185d0', '--label-text': '#ffffff'}}
>{name}</span>)}
</div>);
cy.get('.wrolpi-tag').should(($tags) => {
const rects = [...$tags].map((el) => el.getBoundingClientRect());
const rows = [...new Set(rects.map((r) => Math.round(r.top)))].sort((a, b) => a - b);
expect(rows.length, 'the tags wrapped').to.be.greaterThan(1);
for (let row = 1; row < rows.length; row++) {
const previousBottom = Math.max(...rects
.filter((r) => Math.round(r.top) === rows[row - 1])
.map((r) => r.bottom));
expect(rows[row] - previousBottom, `gap above row ${row + 1}`).to.be.at.least(3);
}
});
});
});
describe('tabs', () => {
themeNames.forEach((theme) => {
it(`gives an inactive tab no surface of its own in ${theme}`, () => {
/*
* A tab is a NavLink in the app's nav bars but a <button> on Inventory and in the
* gallery, and a button carries the UA's `buttonface` background -- rgb(239,239,239).
* Only the active tab set a background, so every inactive one was a near-white block
* in dark, night and amber.
*/
cy.mountUI(<TabBar>
<button className={tabClassName(true)}>Videos</button>
<button className={tabClassName(false)}>Channels</button>
</TabBar>, {theme});
cy.contains('button', 'Channels').should(($tab) =>
expect(getComputedStyle($tab[0]).backgroundColor, 'inactive tab is transparent')
.to.equal('rgba(0, 0, 0, 0)'));
test: prove the toast contrast fix in a browser, and fix the harness that hid it The title contrast was verified by hand and by nothing else. jsdom cannot check it: it resolves no `var()`, so the title's colour there is the literal string `var(--mantine-color-white)` and every contrast assertion passes. Six browser tests now cover it -- title and description at WCAG AA in each of the four themes, the title staying heavier than the message where night and amber drop its muting, and the toast taking `--panel` for its surface. The three that can fail were checked against the fix removed: 1.13:1 in dark, night and amber. Light passes either way, correctly, because Mantine's light-scheme title uses `--mantine-color-black`, which the bridge maps to `--text`. Getting there took three corrections, all of them mine: * `cy.mountUI` never set `forceColorScheme`, so every theme rendered against Mantine's LIGHT scheme. Mantine keys its own rules on data-mantine-color-scheme, and ThemeProvider sets it from the theme -- night and amber ride on dark. Any per-theme test could therefore pass on a page that was broken in the app. This is the harness the tag contrast tests use too. * The support file never imported `@mantine/notifications/styles.css`, which App.js does, so a Notification rendered unstyled and had no surface or title colour of Mantine's to be wrong about. * The spec's own helper mounted a second time to raise the toast, which reset the theme to the default. All four per-theme cases ran in light. For the record, the chain the fix breaks: `.m_3feedf16` (the title) in dark scheme is `color: var(--mantine-color-white)`, the bridge aliases that to `--btn-text`, and `--btn-text` is the text drawn on a filled button -- near-black in dark, night and amber. Mantine writes it through `:where(...)`, which has zero specificity, so a single-class override plus `html` outranks it.
2026-08-01 15:07:48 -06:00
});
});
});
describe('a toast is readable in every theme', () => {
/*
* Mantine paints a dark-scheme notification title with `--mantine-color-white`, and the
* bridge aliases that to `--btn-text` -- the text drawn on a filled button, which is
* near-black in dark, night and amber. The title measured about 1.1:1 against the toast's
* own surface: present, and invisible.
*
* Only a browser can catch that. jsdom resolves no `var()`, so the title's color there is
test: prove the toast contrast fix in a browser, and fix the harness that hid it The title contrast was verified by hand and by nothing else. jsdom cannot check it: it resolves no `var()`, so the title's colour there is the literal string `var(--mantine-color-white)` and every contrast assertion passes. Six browser tests now cover it -- title and description at WCAG AA in each of the four themes, the title staying heavier than the message where night and amber drop its muting, and the toast taking `--panel` for its surface. The three that can fail were checked against the fix removed: 1.13:1 in dark, night and amber. Light passes either way, correctly, because Mantine's light-scheme title uses `--mantine-color-black`, which the bridge maps to `--text`. Getting there took three corrections, all of them mine: * `cy.mountUI` never set `forceColorScheme`, so every theme rendered against Mantine's LIGHT scheme. Mantine keys its own rules on data-mantine-color-scheme, and ThemeProvider sets it from the theme -- night and amber ride on dark. Any per-theme test could therefore pass on a page that was broken in the app. This is the harness the tag contrast tests use too. * The support file never imported `@mantine/notifications/styles.css`, which App.js does, so a Notification rendered unstyled and had no surface or title colour of Mantine's to be wrong about. * The spec's own helper mounted a second time to raise the toast, which reset the theme to the default. All four per-theme cases ran in light. For the record, the chain the fix breaks: `.m_3feedf16` (the title) in dark scheme is `color: var(--mantine-color-white)`, the bridge aliases that to `--btn-text`, and `--btn-text` is the text drawn on a filled button -- near-black in dark, night and amber. Mantine writes it through `:where(...)`, which has zero specificity, so a single-class override plus `html` outranks it.
2026-08-01 15:07:48 -06:00
* the literal string `var(--mantine-color-white)` and every contrast check passes.
*/
/*
* Mounts once, with the theme, and raises a toast. Mounting a second time to raise it --
* which is how this was first written -- resets the theme to the default, so all four
* per-theme cases silently ran in light and none of them could fail.
*/
const showToast = (theme) => {
cy.mountUI(<>
<Notifications position='top-right' limit={5}/>
<button type='button' onClick={() => toast({
type: 'error', title: 'Download failed',
description: 'HTTP 403 from the remote server after 3 attempts.',
})}>Raise one</button>
</>, {theme});
cy.contains('button', 'Raise one').click();
cy.get('[class*="mantine-Notification-root"]').should('exist');
};
themeNames.forEach((theme) => {
it(`reads its title and message in ${theme}`, () => {
showToast(theme);
// WCAG AA for both. The description is the message itself, so it is held to the
// same bar as the title rather than treated as decoration.
cy.contrastRatio('[class*="mantine-Notification-title"]').should('be.at.least', 4.5);
cy.contrastRatio('[class*="mantine-Notification-description"]').should('be.at.least', 4.5);
});
});
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>
2026-08-01 17:46:33 -06:00
monochromeThemes.forEach((theme) => {
it(`tells its four kinds apart in ${theme}, which is the bug roles exist for`, () => {
/*
* The end of the chain, measured rather than inferred. The jest tests assert the
* Mantine variable NAME on the style attribute, which would still pass if someone
* put four hue names back -- four distinct strings that resolve to two colors here.
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>
2026-08-01 17:46:33 -06:00
* This reads what is painted.
*/
cy.mountUI(<>
<Notifications position='top-right' limit={5}/>
<button type='button' onClick={() => {
/*
* Mantine's notification store is module scope and outlives the mount, so
* a toast raised by an earlier test in this file is still queued here --
* which is how this first ran with five.
*/
clearToasts();
['info', 'success', 'warning', 'error'].forEach(type =>
toast({type, title: type, time: 0}));
}}>Raise all four</button>
</>, {theme});
cy.contains('button', 'Raise all four').click();
cy.get('[class*="mantine-Notification-root"]').should('have.length', 4);
cy.get('[class*="mantine-Notification-root"]').should(($toasts) => {
const colors = [...$toasts].map(t =>
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>
2026-08-01 17:46:33 -06:00
getComputedStyle(t).getPropertyValue('--notification-color').trim());
expect(new Set(colors).size, `four distinct kinds, got ${colors.join(' ')}`)
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>
2026-08-01 17:46:33 -06:00
.to.equal(4);
/*
* Distinctness alone does not catch the regression this is for. Reverting to
* hue names gives four distinct values in night too -- blue, green, yellow and
* red are not the same color there. What they are is cramped and badly
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>
2026-08-01 17:46:33 -06:00
* ranked, with `--blue` at 2.29:1 against the toast surface: present, and
* invisible. So the floor is the assertion that has teeth.
*/
const surface = toRgb(getComputedStyle($toasts[0]).backgroundColor);
colors.forEach((color, index) => {
expect(contrast(toRgb(color), surface), `toast ${index} against its surface`)
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>
2026-08-01 17:46:33 -06:00
.to.be.at.least(3);
});
});
});
it(`tells four Messages apart in ${theme}`, () => {
cy.mountUI(
<Panel>
<Message kind='info' title='info'/>
<Message kind='success' title='success'/>
<Message kind='warning' title='warning'/>
<Message kind='error' title='error'/>
</Panel>,
{theme},
);
cy.get('.wrolpi-message').should(($all) => {
expect($all.length).to.equal(4);
const colors = [...$all].map(m =>
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>
2026-08-01 17:46:33 -06:00
getComputedStyle(m).getPropertyValue('--message-color').trim());
expect(new Set(colors).size, `four distinct kinds, got ${colors.join(' ')}`)
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>
2026-08-01 17:46:33 -06:00
.to.equal(4);
});
});
});
test: prove the toast contrast fix in a browser, and fix the harness that hid it The title contrast was verified by hand and by nothing else. jsdom cannot check it: it resolves no `var()`, so the title's colour there is the literal string `var(--mantine-color-white)` and every contrast assertion passes. Six browser tests now cover it -- title and description at WCAG AA in each of the four themes, the title staying heavier than the message where night and amber drop its muting, and the toast taking `--panel` for its surface. The three that can fail were checked against the fix removed: 1.13:1 in dark, night and amber. Light passes either way, correctly, because Mantine's light-scheme title uses `--mantine-color-black`, which the bridge maps to `--text`. Getting there took three corrections, all of them mine: * `cy.mountUI` never set `forceColorScheme`, so every theme rendered against Mantine's LIGHT scheme. Mantine keys its own rules on data-mantine-color-scheme, and ThemeProvider sets it from the theme -- night and amber ride on dark. Any per-theme test could therefore pass on a page that was broken in the app. This is the harness the tag contrast tests use too. * The support file never imported `@mantine/notifications/styles.css`, which App.js does, so a Notification rendered unstyled and had no surface or title colour of Mantine's to be wrong about. * The spec's own helper mounted a second time to raise the toast, which reset the theme to the default. All four per-theme cases ran in light. For the record, the chain the fix breaks: `.m_3feedf16` (the title) in dark scheme is `color: var(--mantine-color-white)`, the bridge aliases that to `--btn-text`, and `--btn-text` is the text drawn on a filled button -- near-black in dark, night and amber. Mantine writes it through `:where(...)`, which has zero specificity, so a single-class override plus `html` outranks it.
2026-08-01 15:07:48 -06:00
it('keeps the title more prominent than the message', () => {
/*
* Night and amber drop the description's muting, because `--muted` on a panel is 2.0:1
* in night. Weight has to carry the hierarchy once color cannot.
test: prove the toast contrast fix in a browser, and fix the harness that hid it The title contrast was verified by hand and by nothing else. jsdom cannot check it: it resolves no `var()`, so the title's colour there is the literal string `var(--mantine-color-white)` and every contrast assertion passes. Six browser tests now cover it -- title and description at WCAG AA in each of the four themes, the title staying heavier than the message where night and amber drop its muting, and the toast taking `--panel` for its surface. The three that can fail were checked against the fix removed: 1.13:1 in dark, night and amber. Light passes either way, correctly, because Mantine's light-scheme title uses `--mantine-color-black`, which the bridge maps to `--text`. Getting there took three corrections, all of them mine: * `cy.mountUI` never set `forceColorScheme`, so every theme rendered against Mantine's LIGHT scheme. Mantine keys its own rules on data-mantine-color-scheme, and ThemeProvider sets it from the theme -- night and amber ride on dark. Any per-theme test could therefore pass on a page that was broken in the app. This is the harness the tag contrast tests use too. * The support file never imported `@mantine/notifications/styles.css`, which App.js does, so a Notification rendered unstyled and had no surface or title colour of Mantine's to be wrong about. * The spec's own helper mounted a second time to raise the toast, which reset the theme to the default. All four per-theme cases ran in light. For the record, the chain the fix breaks: `.m_3feedf16` (the title) in dark scheme is `color: var(--mantine-color-white)`, the bridge aliases that to `--btn-text`, and `--btn-text` is the text drawn on a filled button -- near-black in dark, night and amber. Mantine writes it through `:where(...)`, which has zero specificity, so a single-class override plus `html` outranks it.
2026-08-01 15:07:48 -06:00
*/
showToast('night');
cy.get('[class*="mantine-Notification-title"]').then(($title) => {
cy.get('[class*="mantine-Notification-description"]').should(($description) => {
const weight = (el) => parseInt(getComputedStyle(el).fontWeight, 10);
expect(weight($title[0]), 'title weight')
.to.be.greaterThan(weight($description[0]));
});
});
});
it('takes its surface from the theme, not from Mantine', () => {
// A toast is a panel. Left to Mantine it would be `--mantine-color-body`, which is not
// one of our tokens and does not follow night or amber.
showToast('night');
cy.get('[class*="mantine-Notification-root"]').should(($toast) => {
const panel = getComputedStyle(document.documentElement).getPropertyValue('--panel').trim();
expect(getComputedStyle($toast[0]).backgroundColor).to.equal(hexToRgb(panel));
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
});
});
});
/*
* The color a box actually shows, looking through the layers in the order given.
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
*
* The order is the caller's business, because "the background" is ambiguous once
* pseudo-elements are involved and picking wrong makes a test vacuous rather than wrong.
* A Skeleton is three layers: the element paints nothing, ::before paints
* --mantine-color-body (our `--bg`) at z-index 10, and ::after paints the bar the user
* actually sees -- --mantine-color-gray-3 in light, --mantine-color-dark-4 in dark, which
* themes/mantine.ts maps to `--head` and `--border` -- at z-index 11, on top. Walk from
* the element outward and you get `--bg` and compare the page background to the panel,
* which differ by design in every theme, so the bars could vanish and nothing would fail.
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
*/
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
const paintedBackground = (el, order = [null, '::before', '::after']) => {
for (const pseudo of order) {
const color = getComputedStyle(el, pseudo).backgroundColor;
if (color && !/^rgba\(.*,\s*0(\.0+)?\)$/.test(color) && color !== 'transparent') {
return color;
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
}
}
return null;
};
describe('a loading placeholder is visible on the surface it covers', () => {
themeNames.forEach((theme) => {
it(`separates the skeleton from the panel in ${theme}`, () => {
/*
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
* `--head` and `--border` are what the bars come out as, and neither was chosen
* with a panel behind it in mind. If they land on the panel's own color there
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
* is no placeholder at all, only an empty box, and jsdom cannot see that.
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
*/
cy.mountUI(<Panel><Placeholder lines={3}/></Panel>, {theme});
cy.get('.mantine-Skeleton-root').first().should(($line) => {
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
// Topmost layer first for the bar; the panel paints on the element itself.
const line = paintedBackground($line[0], ['::after', '::before', null]);
const panel = paintedBackground($line[0].closest('.wrolpi-panel'), [null]);
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
expect(line, 'the skeleton paints something').to.not.equal(null);
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
expect(panel, 'the panel paints something').to.not.equal(null);
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
expect(line, 'the skeleton is not the panel it sits on').to.not.equal(panel);
});
});
});
it('keeps the last line short so the block reads as text', () => {
// The jest test asserts the declared width; this asserts it survived layout.
cy.mountUI(<Panel><Placeholder lines={3}/></Panel>, {theme: 'light'});
cy.get('.mantine-Skeleton-root').should(($lines) => {
const widths = [...$lines].map(line => line.getBoundingClientRect().width);
expect(widths[2], 'last line').to.be.lessThan(widths[0] * 0.75);
expect(widths[0], 'first two lines are the same length').to.be.closeTo(widths[1], 1);
});
});
});
describe('a spinner is visible in every theme', () => {
themeNames.forEach((theme) => {
it(`resolves the loader color in ${theme}`, () => {
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
// `color='var(--blue)'` reaches Mantine as a string it does not understand and
// passes straight through to CSS. If the token were misspelled the property
// would resolve to nothing and the spinner would paint in currentColor -- or,
// for the segmented variants, not at all.
cy.mountUI(<Loading>Loading backups…</Loading>, {theme});
cy.get('.mantine-Loader-root').should(($loader) => {
const blue = getComputedStyle(document.documentElement)
.getPropertyValue('--blue').trim();
const resolved = getComputedStyle($loader[0])
.getPropertyValue('--loader-color').trim();
expect(resolved, '--loader-color resolved through the token')
.to.be.oneOf([blue, hexToRgb(blue)]);
});
cy.get('.mantine-Loader-root').should('be.visible');
});
});
});
describe('an icon stack carries the surface it was placed on', () => {
/*
* The corner glyph paints a disc behind itself so the two sets of strokes do not cross.
* That disc was hardcoded to the page background, which is right in the nav bar and
* wrong inside the file browser's filled blue button, where it read as a hole punched
* through the button. It is now `--icon-stack-bg`, and the call site says.
*/
themeNames.forEach((theme) => {
it(`matches a filled button in ${theme}`, () => {
cy.mountUI(
<Button color='blue'>
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
{/* No style: a filled button supplies the surface through the cascade,
which is the point -- the call site cannot know it is about to be
disabled and repainted. */}
<IconStack corner={<Icon name='add'/>} label='New folder'>
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
<Icon name='folder'/>
</IconStack>
</Button>,
{theme},
);
cy.get('.wrolpi-icon-stack-corner').should(($corner) => {
const disc = getComputedStyle($corner[0]).backgroundColor;
const button = getComputedStyle($corner[0].closest('button')).backgroundColor;
expect(disc, 'the disc is the button fill').to.equal(button);
});
});
});
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
it('follows a filled button when it is disabled', () => {
/*
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
* The file browser's New Folder button is disabled in WROL mode. The disc has to
* follow the button into that state, whatever the state happens to look like -- and
* it has now looked like two different things. Mantine used to repaint a disabled
* button with `--mantine-color-disabled`, so a disc pinned to `--blue` became a blue
* chip on a grey surface; disabled buttons keep their own fill now, so the disc must
* be blue again. This caught the disc still pinned to the old grey the moment that
* changed, which is exactly what it is for.
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
*/
cy.mountUI(
<Button color='blue' disabled>
<IconStack corner={<Icon name='add'/>} label='New folder'>
<Icon name='folder'/>
</IconStack>
</Button>,
{theme: 'light'},
);
cy.get('.wrolpi-icon-stack-corner').should(($corner) => {
const disc = getComputedStyle($corner[0]).backgroundColor;
const button = getComputedStyle($corner[0].closest('button')).backgroundColor;
expect(disc, 'the disc is the disabled fill').to.equal(button);
});
});
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
it('takes the surface from an ancestor, which is how the nav bar sets it', () => {
/*
* The nav bar's color is a user setting written inline on the <nav>, so the stack
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
* inside it cannot name a token. It sets --icon-stack-bg on the bar itself and lets
* it inherit -- and this is the test for that, because setting the property on the
* stack (as the file browser does) would pass even if inheritance were broken.
*/
cy.mountUI(
<div style={{background: 'var(--red)', '--icon-stack-bg': 'var(--red)', padding: 20}}>
<IconStack corner={<Icon name='question'/>} label='WiFi status unknown'>
<Icon name='wifi'/>
</IconStack>
</div>,
{theme: 'light'},
);
cy.get('.wrolpi-icon-stack-corner').should(($corner) => {
const red = getComputedStyle(document.documentElement).getPropertyValue('--red').trim();
expect(getComputedStyle($corner[0]).backgroundColor).to.equal(hexToRgb(red));
});
});
it('defaults to the page background when nothing says otherwise', () => {
test: act on review — the skeleton guard was reading the wrong layer The "separates the skeleton from the panel" cases could not fail. A Skeleton is three layers: the element paints nothing, ::before paints --mantine-color-body (`--bg`) at z-index 10, and ::after paints the bar the user actually sees (`--head` in light, `--border` in dark) at z-index 11, on top. `paintedBackground` walked outward from the element and returned the first paint, which is ::before -- so all four cases compared the page background to the panel. Those differ by design in every theme, so the bars could have collapsed into the panel entirely and every assertion stayed green. My planted regression did not catch it because the plant was broader than the claim: it forced all three layers to the panel colour, so the test went red for a reason the fix did not depend on. The plant now sets only ::after, and a second plant sets only ::before and must stay GREEN. The layer order is now the caller's argument, since "the background" is ambiguous once pseudo-elements are involved and guessing makes a test vacuous rather than wrong. Also from review: The disc on a filled button was pinned to `--blue` at the call site, but WROL mode disables that button and Mantine repaints it `--mantine-color-disabled` -- a blue chip on a grey button, the original hole inverted. The surface now comes from the cascade (`--button-bg`, and the disabled colour for any variant), so the call site says nothing at all and cannot be wrong about a state it does not control. Keying on `[data-variant="filled"]` alone matched none of our buttons: Mantine omits the attribute when a call site names a colour but no variant, which is how every filled button here is written. The Checkbox behaviour test asserted only that a handler fired, against a box held at `checked={false}` that could never change. It is now uncontrolled and asserts the box is checked, plus a second test that the handler sees the new state -- read inside the handler, because `currentTarget` is null by the time a mock is inspected. The empty-caption test counted every div in the container; it counts the loader's siblings now. Two comments corrected: Pill emits no `--pill-radius` at all and its own stylesheet falls back to `1000rem`, and the nav bar no longer relies on the default surface. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:05:29 -06:00
// The fallback, for a stack standing on the page rather than under something that
// sets a surface. Both stacks in the app are covered by the two tests above -- the
// nav bar by inheritance, the file browser by the button cascade -- so this one
// guards the default that everything else is defined against.
ui: test the last four components, and put the last four in the gallery Closes the tail of the library: `Loader`, `Loading`, `Placeholder` and `Checkbox` had no test of their own, and `IconStack`, `MediaFilterToggle`, `MultiSelect` and `NumberInput` were not in the gallery, which the project rule says every component must be. Putting them in the gallery is what found the rest of this. An IconStack's corner glyph paints a disc of the surface behind itself so the two sets of strokes do not cross, and that surface was hardcoded to the page background. It is right in exactly one of the three places a stack appears. The nav bar showed a white disc on the red bar, and the file browser's "New Folder" button showed one punched through the blue fill. It is now `--icon-stack-bg`, defaulting to the page: the file browser passes the button's fill, and the nav bar sets it on the <nav> beside the colour it already writes there, so it inherits -- the bar's colour is a user setting and cannot be named by a token. A MultiSelect's chosen options are Mantine Pills, and Pill is the one component that ignores the radius theme: it writes `--pill-radius: rem(1000)` onto the element, which zeroing `--mantine-radius-xl` cannot reach. They were lozenges on a page of square boxes. Twelve jest tests and sixteen browser tests. The browser half covers what jsdom cannot judge: that a Skeleton is a different colour from the panel it covers in all four themes (its greys are remapped to our tokens, and neither `--border` nor `--bg` was picked with a panel behind it), that the loader colour resolves through the token, and that the corner disc matches its surface. Every one was checked red against a planted regression first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 15:48:10 -06:00
cy.mountUI(
<IconStack corner={<Icon name='question'/>} label='WiFi status unknown'>
<Icon name='wifi'/>
</IconStack>,
{theme: 'night'},
);
cy.get('.wrolpi-icon-stack-corner').should(($corner) => {
const background = getComputedStyle(document.documentElement)
.getPropertyValue('--bg').trim();
expect(getComputedStyle($corner[0]).backgroundColor).to.equal(hexToRgb(background));
});
});
});
describe('corners stay hard', () => {
it('squares off the pills a MultiSelect renders for its chosen options', () => {
/*
* The design has no rounded corners, and mantine.ts zeroes every radius variable so
* a component that asks for `radius="md"` still gets none. Pill escapes that: it
* writes `--pill-radius: rem(1000)` onto the element, which outranks the theme, and
* the tags in a MultiSelect came out as lozenges among a page of square boxes.
*/
cy.mountUI(
<MultiSelect data={['Preserve', 'Radio']} defaultValue={['Preserve']} label='Tags'/>,
{theme: 'light'},
);
cy.get('[class*="mantine-Pill-root"]').should(($pill) => {
expect(getComputedStyle($pill[0]).borderRadius).to.equal('0px');
ui: Statistic and StatisticGroup, and the four defects they had These three exports had no test of their own. Statistic had already been caught out once -- it relied on Semantic's `Statistic.Group` for its spacing, so it broke silently when that was uninstalled -- and they are on the Status, Dashboard, Apps, Docs, Videos, Archive and Channels pages. Four defects, each with a test that goes red without the fix: * StatisticGroup ruled between columns only, with a `border-right` on every cell but the last. `auto-fit` wraps, so the seven statistics on the Docs page became four rows on a phone with no rule between them, and the cell ending each earlier row drew its border straight onto the group's outer one, making that edge 2px on the right and 1px on the left. The hairlines are now a 1px grid gap filled by an outline on each cell, which rules both axes however the tracks fall. Ruling the gaps with a border-coloured background behind the grid -- which is where this went first -- has the same reach but paints every track no cell landed in: an odd count left the last slot a solid grey block. An outline is drawn only where a cell is. Both of these are guarded, because the second was introduced while fixing the first. * A statistic that renders nothing left a padded cell and a stray hairline mid-row. FanRPMStatistic returns null on a device with no fan connector, which is most of them, so this was the Status page's normal appearance. The group cannot render a child to find out, so the cell is still emitted and `:empty` takes it out of the grid -- which is why the cells carry no inline style for that rule to have to outrank. * Statistic destructured five props and dropped the rest. LoadStatistic and the four Status wrappers all end in `{...props}`, so anything passed through a wrapper vanished with no error anywhere. * VideosStatistics passed `style={{margin: '2em'}}` to every statistic, Semantic-era spacing that the grid now provides. It beat the group's own rule, being inline, and made that one page's statistics sit differently from the six others. CardGroup was the only component in the library with no class of its own, which left nothing to assert against -- `container.firstChild` in jsdom is Mantine's injected <style> element. It has one now, and takes className/style/rest like its siblings. The gallery grows a seventh statistic, so the group wraps at a normal window width where the row hairlines can be seen, and a second group of coloured readings as Status renders them. Geometry, hairlines and per-theme token resolution are in ui-layout.cy.js rather than jest: jsdom returns zeros from getBoundingClientRect and never resolves a var(), so it cannot judge any of it.
2026-07-30 19:08:44 -06:00
});
});
});
ui: a browser layer for the library, and the .media reset that never applied The PathInput overlap could not have been caught by jest -- jsdom computes no layout -- so the only guard was a grep for one spelling of one mistake. This adds the layer that can actually see it, and it found a real bug immediately. ui-layout.cy.js mounts library components in a real browser through a new cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and nothing else. That spartan setup is the point: these components read no ambient state, so a spec can assert what jsdom cannot compute -- real geometry, resolved custom properties, applied filters -- across all four themes. It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it still overlaps, because a geometry check that has never gone red is indistinguishable from one that cannot fail. The bug it found: the rule resetting `filter` on leaf media inside a `.media` wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost every time and never applied to anything. Every image inside a filtered wrapper has been through the luminance matrix twice since that rule landed -- markedly darker than its surroundings, which is exactly what it was written to prevent. tokens.test.js asserted only that the rule's text was present, and so stayed green throughout; it now compares the two selectors' specificity, which is computable without a browser and goes red on the old selector. Three guards in ui.test.js keep the library mock-free by construction rather than by habit: no jest.mock in its own tests, no fetch in any library file, and no useContext outside the theme controls, whose job is to read the theme. All three were verified red against planted violations. 959 jest tests, 14 new browser tests, clean cache-busted build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
describe('theme tokens actually resolve', () => {
themeNames.forEach((theme) => {
it(`paints text and borders from ${theme}'s table`, () => {
cy.mountUI(<PathInput prefix='/media/wrolpi' defaultValue='x'/>, {theme});
/*
* A token that a theme forgot to define resolves to the empty string, and the
* property falls back to something inherited -- usually black text on a dark
* panel. jsdom cannot catch that; it does not resolve var() at all.
*/
cy.get('.wrolpi-path-input-control input').should(($input) => {
const color = getComputedStyle($input[0]).color;
expect(color, 'input text color resolved').to.match(/^rgba?\(/);
ui: a browser layer for the library, and the .media reset that never applied The PathInput overlap could not have been caught by jest -- jsdom computes no layout -- so the only guard was a grep for one spelling of one mistake. This adds the layer that can actually see it, and it found a real bug immediately. ui-layout.cy.js mounts library components in a real browser through a new cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and nothing else. That spartan setup is the point: these components read no ambient state, so a spec can assert what jsdom cannot compute -- real geometry, resolved custom properties, applied filters -- across all four themes. It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it still overlaps, because a geometry check that has never gone red is indistinguishable from one that cannot fail. The bug it found: the rule resetting `filter` on leaf media inside a `.media` wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost every time and never applied to anything. Every image inside a filtered wrapper has been through the luminance matrix twice since that rule landed -- markedly darker than its surroundings, which is exactly what it was written to prevent. tokens.test.js asserted only that the rule's text was present, and so stayed green throughout; it now compares the two selectors' specificity, which is computable without a browser and goes red on the old selector. Three guards in ui.test.js keep the library mock-free by construction rather than by habit: no jest.mock in its own tests, no fetch in any library file, and no useContext outside the theme controls, whose job is to read the theme. All three were verified red against planted violations. 959 jest tests, 14 new browser tests, clean cache-busted build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
// Only an rgba() alpha of zero is invisible. Matching a trailing ", 0)"
// loosely would flag amber's opaque rgb(255, 149, 0) for its blue channel.
expect(color, 'input text is not transparent')
ui: a browser layer for the library, and the .media reset that never applied The PathInput overlap could not have been caught by jest -- jsdom computes no layout -- so the only guard was a grep for one spelling of one mistake. This adds the layer that can actually see it, and it found a real bug immediately. ui-layout.cy.js mounts library components in a real browser through a new cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and nothing else. That spartan setup is the point: these components read no ambient state, so a spec can assert what jsdom cannot compute -- real geometry, resolved custom properties, applied filters -- across all four themes. It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it still overlaps, because a geometry check that has never gone red is indistinguishable from one that cannot fail. The bug it found: the rule resetting `filter` on leaf media inside a `.media` wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost every time and never applied to anything. Every image inside a filtered wrapper has been through the luminance matrix twice since that rule landed -- markedly darker than its surroundings, which is exactly what it was written to prevent. tokens.test.js asserted only that the rule's text was present, and so stayed green throughout; it now compares the two selectors' specificity, which is computable without a browser and goes red on the old selector. Three guards in ui.test.js keep the library mock-free by construction rather than by habit: no jest.mock in its own tests, no fetch in any library file, and no useContext outside the theme controls, whose job is to read the theme. All three were verified red against planted violations. 959 jest tests, 14 new browser tests, clean cache-busted build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
.not.to.match(/^rgba\(.*,\s*0(\.0+)?\)$/);
});
cy.get('.wrolpi-path-input-control').should(($control) => {
expect(getComputedStyle($control[0]).borderTopColor, 'border resolved')
.to.match(/^rgba?\(/);
});
});
});
});
describe('media filtering', () => {
it('tints a bare image in night', () => {
cy.mountUI(<img alt='poster' src='/logo.png' width='80' height='80'/>,
{theme: 'night', mediaFilter: 'night-red'});
cy.get('img').should(($img) =>
expect(getComputedStyle($img[0]).filter).to.contain('wrolpi-night-red'));
});
it('filters a .media wrapper once, not its contents twice', () => {
/*
* Two passes of a luminance-to-red matrix is not the same as one -- the second pass
* takes the luminance of an already-red pixel and the image comes out markedly
* darker than its surroundings. So a `.media` wrapper is filtered as a unit and the
* leaf inside it must come back `none`.
*/
cy.mountUI(
<div className='media'>
<img alt='poster' src='/logo.png' width='80' height='80'/>
</div>,
{theme: 'night', mediaFilter: 'night-red'},
);
cy.get('.media').should(($wrapper) =>
expect(getComputedStyle($wrapper[0]).filter).to.contain('wrolpi-night-red'));
cy.get('.media img').should(($img) =>
expect(getComputedStyle($img[0]).filter).to.equal('none'));
});
it('leaves media alone when the user has turned the filter off', () => {
// The attribute is absent rather than empty when filtering is off, so night with the
// setting disabled must match no rule at all.
cy.mountUI(<img alt='poster' src='/logo.png' width='80' height='80'/>,
{theme: 'night'});
cy.get('img').should(($img) =>
expect(getComputedStyle($img[0]).filter).to.equal('none'));
});
});
ui: cards get legible titles, contained posters, and meta beside the title Four defects on /videos, /docs and /archives. Titles were invisible outside light. `.card-link` carried a literal `color: black` from before the themes existed -- about 1.1:1 on the dark, night and amber panels. It applies to every card title and to the channel/author/domain line beside it. The date was fine, since it takes `--muted` from the card body, which is what made this look like a card bug rather than a link bug. Titles now take `--text`: they are links, but they are the card's text, not a wall of blue. Posters were cropped, not mis-proportioned. The image carried a fixed 290x163 box; a card in the default grid is about 233px wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle 233px of a 290px image. The ratio was right in the layout tree and wrong on screen. Replaced with caps on both axes -- the card's width and `--card-poster-max-height: 200px` -- with `width`/`height` left `auto` so the pair behaves as "contain". Bounding the width alone was tried first and is not enough: a square thumbnail then stands as tall as the card is wide, and a portrait book cover taller still. The meta line was foot-anchored, so on /docs a PDF with no author had its date shoved up to 55px below the title, at the bottom of a card that was tall only because of its neighbour in the row. It now sits directly under the title. Archive cards read buttons-then-domain, because the buttons were children and the meta was what got pushed to the foot. Card gains an `actions` slot, rendered last and anchored to the foot, so a row lines its buttons up however many lines each title took. Gallery gains a poster row covering all five ratios and a row showing meta/actions against unequal titles. 1076 jest tests, 145 in ui-layout.cy.js, clean build. Every new guard was checked against a planted regression: dropping the height cap reddens the square and portrait cases and leaves 16:9 green; `width: 100%` reddens containment; restoring `color: black` reddens dark/night/amber and leaves light green; re-anchoring the meta and swapping the slot order redden both the jest order test and the cypress geometry tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 09:16:31 -06:00
/*
* A poster of exact intrinsic dimensions. It has to come over the wire rather than as a
* data: URI, because CardPoster rewrites whatever it is given into `/media/<path>` -- so
* the bytes are served by an intercept and the component builds its own URL, which is the
* URL the app actually requests.
*/
const posterFile = (width, height) => ({
id: 1,
tags: [],
poster_path: `videos/poster-${width}x${height}.svg`,
primary_path: 'videos/one.mp4',
});
const servePoster = (width, height) => cy.intercept(
'GET', `**/media/videos/poster-${width}x${height}.svg`,
{
headers: {'content-type': 'image/svg+xml'},
body: `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}'>` +
`<rect width='100%' height='100%' fill='#888'/></svg>`,
},
);
/* A card as narrow as the default grid makes them, which is where the cropping showed. */
const narrowCard = (children) =>
<MemoryRouter><div style={{width: 233}}>{children}</div></MemoryRouter>;
ui: let a landscape poster fill a one-column card, and fix three scale-blind tests `--card-poster-max-height` is a fixed height, so it stops scaling with the card: held to 220px, a 16:9 thumbnail is 391px wide, and any card wider than that centred it with empty panel on both sides. That is every video card at one column -- a phone, or any window under about 456px of content width. The cap is now `max(var(--card-poster-max-height), 56.25cqw)` with the poster band as the query container. 56.25cqw is nine sixteenths of the card: exactly the height of a 16:9 image that fills the width, and the same number states the rule for every other ratio -- a poster may be as tall as a 16:9 slice of this card and no taller. So a portrait book cover still reads as a band rather than a column, and now grows with the card instead of stopping at 220px. `max()` rather than `min()` so the floor wins on a narrow card. The gap pre-dated the interface scale, below about 414px, but the scale widened the range it shows in: the track minimum went from 200px to 220px, so one column now starts at 456px of content width instead of 414. Every existing poster case mounted a 233px card, which is why the wide card's own failure went unseen for the whole migration. Two cases added on a 451px card: a landscape poster reaches the edges, and a portrait cover stays a band. Three tests carried a hardcoded px expectation, which is a hidden assertion that the interface scale is 1. All three failed at 1.1, in names that said nothing about size -- and I did not catch them because I ran jest and the build for the scale change but not cypress, which AGENTS.md asks for on frontend work: - `cardPosterCap()` read `--card-poster-max-height` with parseFloat. The cap is rem now, so it returned 12.5 and failed a within(80, 240) bound -- taking five poster tests with it. It resolves through the root font-size and checks the unit. - `inNarrowColumn` was a fixed 340px, chosen to hold two 150px statistic tracks. At 165px tracks it became one column, so a test about the gap BETWEEN columns had no second column. It is now 340px times the scale, because "narrow" means narrow relative to the type. - The APIButton size test asserted 36px for `small`. It now measures against a real `sm` button, which is the claim it was making -- that `small` resolves to `sm` -- and holds at any scale. A `uiScale()` helper reads the token so no further test has to name a pixel count. Verified: ui-layout 248 passing, 0 failing; 1141 jest tests / 65 suites; clean build; browser-checked at 400/451/500/700/1200px of grid width, no side gap at any of them. The 12 remaining component failures are the pre-existing Semantic-era selector failures in Tags, Channels, Download and Inventory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:02:15 -06:00
/*
* A card as wide as the grid makes it when it drops to ONE column -- a phone, or any window
* under about 456px of content width. Every case below used the narrow card, which is why
* the wide card's own failure went unseen for the whole migration: a 16:9 poster held to a
* 220px height is 391px wide, so a 451px card centred it with 30px of empty panel on either
* side. The height cap was doing its job for a book cover and letterboxing a video sideways.
*/
const wideCard = (children) =>
<MemoryRouter><div style={{width: 451}}>{children}</div></MemoryRouter>;
ui: cards get legible titles, contained posters, and meta beside the title Four defects on /videos, /docs and /archives. Titles were invisible outside light. `.card-link` carried a literal `color: black` from before the themes existed -- about 1.1:1 on the dark, night and amber panels. It applies to every card title and to the channel/author/domain line beside it. The date was fine, since it takes `--muted` from the card body, which is what made this look like a card bug rather than a link bug. Titles now take `--text`: they are links, but they are the card's text, not a wall of blue. Posters were cropped, not mis-proportioned. The image carried a fixed 290x163 box; a card in the default grid is about 233px wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle 233px of a 290px image. The ratio was right in the layout tree and wrong on screen. Replaced with caps on both axes -- the card's width and `--card-poster-max-height: 200px` -- with `width`/`height` left `auto` so the pair behaves as "contain". Bounding the width alone was tried first and is not enough: a square thumbnail then stands as tall as the card is wide, and a portrait book cover taller still. The meta line was foot-anchored, so on /docs a PDF with no author had its date shoved up to 55px below the title, at the bottom of a card that was tall only because of its neighbour in the row. It now sits directly under the title. Archive cards read buttons-then-domain, because the buttons were children and the meta was what got pushed to the foot. Card gains an `actions` slot, rendered last and anchored to the foot, so a row lines its buttons up however many lines each title took. Gallery gains a poster row covering all five ratios and a row showing meta/actions against unequal titles. 1076 jest tests, 145 in ui-layout.cy.js, clean build. Every new guard was checked against a planted regression: dropping the height cap reddens the square and portrait cases and leaves 16:9 green; `width: 100%` reddens containment; restoring `color: black` reddens dark/night/amber and leaves light green; re-anchoring the meta and swapping the slot order redden both the jest order test and the cypress geometry tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 09:16:31 -06:00
/*
* The height cap, read from the stylesheet rather than repeated here, so the two cannot
* drift. Deleting the declaration makes this NaN and every comparison against it fails,
* which is the point -- and the bound below keeps "read whatever the CSS says" from being
* a test that any value at all satisfies.
*/
const cardPosterCap = () => {
ui: let a landscape poster fill a one-column card, and fix three scale-blind tests `--card-poster-max-height` is a fixed height, so it stops scaling with the card: held to 220px, a 16:9 thumbnail is 391px wide, and any card wider than that centred it with empty panel on both sides. That is every video card at one column -- a phone, or any window under about 456px of content width. The cap is now `max(var(--card-poster-max-height), 56.25cqw)` with the poster band as the query container. 56.25cqw is nine sixteenths of the card: exactly the height of a 16:9 image that fills the width, and the same number states the rule for every other ratio -- a poster may be as tall as a 16:9 slice of this card and no taller. So a portrait book cover still reads as a band rather than a column, and now grows with the card instead of stopping at 220px. `max()` rather than `min()` so the floor wins on a narrow card. The gap pre-dated the interface scale, below about 414px, but the scale widened the range it shows in: the track minimum went from 200px to 220px, so one column now starts at 456px of content width instead of 414. Every existing poster case mounted a 233px card, which is why the wide card's own failure went unseen for the whole migration. Two cases added on a 451px card: a landscape poster reaches the edges, and a portrait cover stays a band. Three tests carried a hardcoded px expectation, which is a hidden assertion that the interface scale is 1. All three failed at 1.1, in names that said nothing about size -- and I did not catch them because I ran jest and the build for the scale change but not cypress, which AGENTS.md asks for on frontend work: - `cardPosterCap()` read `--card-poster-max-height` with parseFloat. The cap is rem now, so it returned 12.5 and failed a within(80, 240) bound -- taking five poster tests with it. It resolves through the root font-size and checks the unit. - `inNarrowColumn` was a fixed 340px, chosen to hold two 150px statistic tracks. At 165px tracks it became one column, so a test about the gap BETWEEN columns had no second column. It is now 340px times the scale, because "narrow" means narrow relative to the type. - The APIButton size test asserted 36px for `small`. It now measures against a real `sm` button, which is the claim it was making -- that `small` resolves to `sm` -- and holds at any scale. A `uiScale()` helper reads the token so no further test has to name a pixel count. Verified: ui-layout 248 passing, 0 failing; 1141 jest tests / 65 suites; clean build; browser-checked at 400/451/500/700/1200px of grid width, no side gap at any of them. The 12 remaining component failures are the pre-existing Semantic-era selector failures in Tags, Channels, Download and Inventory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:02:15 -06:00
/*
* Resolved through the root font-size, because the cap is declared in rem so the
* interface scale reaches it. `parseFloat('12.5rem')` is 12.5, which sailed through as a
* number and then failed the bound below -- five tests here broke that way when the scale
* landed, and none of them mention the cap in their names.
*/
const root = getComputedStyle(document.documentElement);
const declared = root.getPropertyValue('--card-poster-max-height').trim();
expect(declared, 'the cap is declared in rem, so it scales with the interface')
.to.match(/^[\d.]+rem$/);
const value = parseFloat(declared) * parseFloat(root.fontSize);
ui: cards get legible titles, contained posters, and meta beside the title Four defects on /videos, /docs and /archives. Titles were invisible outside light. `.card-link` carried a literal `color: black` from before the themes existed -- about 1.1:1 on the dark, night and amber panels. It applies to every card title and to the channel/author/domain line beside it. The date was fine, since it takes `--muted` from the card body, which is what made this look like a card bug rather than a link bug. Titles now take `--text`: they are links, but they are the card's text, not a wall of blue. Posters were cropped, not mis-proportioned. The image carried a fixed 290x163 box; a card in the default grid is about 233px wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle 233px of a 290px image. The ratio was right in the layout tree and wrong on screen. Replaced with caps on both axes -- the card's width and `--card-poster-max-height: 200px` -- with `width`/`height` left `auto` so the pair behaves as "contain". Bounding the width alone was tried first and is not enough: a square thumbnail then stands as tall as the card is wide, and a portrait book cover taller still. The meta line was foot-anchored, so on /docs a PDF with no author had its date shoved up to 55px below the title, at the bottom of a card that was tall only because of its neighbour in the row. It now sits directly under the title. Archive cards read buttons-then-domain, because the buttons were children and the meta was what got pushed to the foot. Card gains an `actions` slot, rendered last and anchored to the foot, so a row lines its buttons up however many lines each title took. Gallery gains a poster row covering all five ratios and a row showing meta/actions against unequal titles. 1076 jest tests, 145 in ui-layout.cy.js, clean build. Every new guard was checked against a planted regression: dropping the height cap reddens the square and portrait cases and leaves 16:9 green; `width: 100%` reddens containment; restoring `color: black` reddens dark/night/amber and leaves light green; re-anchoring the meta and swapping the slot order redden both the jest order test and the cypress geometry tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 09:16:31 -06:00
expect(value, 'a poster cap is declared, and is small enough to be a cap')
ui: let a landscape poster fill a one-column card, and fix three scale-blind tests `--card-poster-max-height` is a fixed height, so it stops scaling with the card: held to 220px, a 16:9 thumbnail is 391px wide, and any card wider than that centred it with empty panel on both sides. That is every video card at one column -- a phone, or any window under about 456px of content width. The cap is now `max(var(--card-poster-max-height), 56.25cqw)` with the poster band as the query container. 56.25cqw is nine sixteenths of the card: exactly the height of a 16:9 image that fills the width, and the same number states the rule for every other ratio -- a poster may be as tall as a 16:9 slice of this card and no taller. So a portrait book cover still reads as a band rather than a column, and now grows with the card instead of stopping at 220px. `max()` rather than `min()` so the floor wins on a narrow card. The gap pre-dated the interface scale, below about 414px, but the scale widened the range it shows in: the track minimum went from 200px to 220px, so one column now starts at 456px of content width instead of 414. Every existing poster case mounted a 233px card, which is why the wide card's own failure went unseen for the whole migration. Two cases added on a 451px card: a landscape poster reaches the edges, and a portrait cover stays a band. Three tests carried a hardcoded px expectation, which is a hidden assertion that the interface scale is 1. All three failed at 1.1, in names that said nothing about size -- and I did not catch them because I ran jest and the build for the scale change but not cypress, which AGENTS.md asks for on frontend work: - `cardPosterCap()` read `--card-poster-max-height` with parseFloat. The cap is rem now, so it returned 12.5 and failed a within(80, 240) bound -- taking five poster tests with it. It resolves through the root font-size and checks the unit. - `inNarrowColumn` was a fixed 340px, chosen to hold two 150px statistic tracks. At 165px tracks it became one column, so a test about the gap BETWEEN columns had no second column. It is now 340px times the scale, because "narrow" means narrow relative to the type. - The APIButton size test asserted 36px for `small`. It now measures against a real `sm` button, which is the claim it was making -- that `small` resolves to `sm` -- and holds at any scale. A `uiScale()` helper reads the token so no further test has to name a pixel count. Verified: ui-layout 248 passing, 0 failing; 1141 jest tests / 65 suites; clean build; browser-checked at 400/451/500/700/1200px of grid width, no side gap at any of them. The 12 remaining component failures are the pre-existing Semantic-era selector failures in Tags, Channels, Download and Inventory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:02:15 -06:00
.to.be.within(80, 300);
ui: cards get legible titles, contained posters, and meta beside the title Four defects on /videos, /docs and /archives. Titles were invisible outside light. `.card-link` carried a literal `color: black` from before the themes existed -- about 1.1:1 on the dark, night and amber panels. It applies to every card title and to the channel/author/domain line beside it. The date was fine, since it takes `--muted` from the card body, which is what made this look like a card bug rather than a link bug. Titles now take `--text`: they are links, but they are the card's text, not a wall of blue. Posters were cropped, not mis-proportioned. The image carried a fixed 290x163 box; a card in the default grid is about 233px wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle 233px of a 290px image. The ratio was right in the layout tree and wrong on screen. Replaced with caps on both axes -- the card's width and `--card-poster-max-height: 200px` -- with `width`/`height` left `auto` so the pair behaves as "contain". Bounding the width alone was tried first and is not enough: a square thumbnail then stands as tall as the card is wide, and a portrait book cover taller still. The meta line was foot-anchored, so on /docs a PDF with no author had its date shoved up to 55px below the title, at the bottom of a card that was tall only because of its neighbour in the row. It now sits directly under the title. Archive cards read buttons-then-domain, because the buttons were children and the meta was what got pushed to the foot. Card gains an `actions` slot, rendered last and anchored to the foot, so a row lines its buttons up however many lines each title took. Gallery gains a poster row covering all five ratios and a row showing meta/actions against unequal titles. 1076 jest tests, 145 in ui-layout.cy.js, clean build. Every new guard was checked against a planted regression: dropping the height cap reddens the square and portrait cases and leaves 16:9 green; `width: 100%` reddens containment; restoring `color: black` reddens dark/night/amber and leaves light green; re-anchoring the meta and swapping the slot order redden both the jest order test and the cypress geometry tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 09:16:31 -06:00
return value;
};
describe('a card poster is bounded by the card, and keeps its ratio', () => {
/*
* The poster carried a fixed 290x163 box. A card in the default grid is about 233px
* wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle
* 233px of a 290px image: the ratio was right in the layout tree and wrong on screen.
* None of that is visible to jsdom, which lays nothing out.
*
* The cap that replaced it is on the WIDTH, so a square or portrait source grows as
* tall as it likes -- a 1:1 thumbnail became a 233px-tall band above a two-line title.
* Hence a height cap as well. Both caps have to preserve the ratio, which is the part
* worth testing: `max-width` and `max-height` together only "contain" an image while
* its own width and height stay `auto`.
*/
const cases = [
{name: 'a 16:9 video thumbnail', w: 1280, h: 720},
{name: 'a square thumbnail', w: 600, h: 600},
{name: 'a portrait book cover', w: 306, h: 396},
{name: 'a poster smaller than the card', w: 120, h: 90},
];
cases.forEach(({name, w, h}) => {
it(`fits ${name} inside the card without distorting it`, () => {
servePoster(w, h);
cy.mountUI(narrowCard(<CardPoster file={posterFile(w, h)}/>));
cy.get('.wrolpi-card-poster img')
// The intrinsic size has to have arrived, or every ratio below is 0/0.
.should(($img) => expect($img[0].naturalWidth, 'poster loaded').to.equal(w))
.should(($img) => {
const img = $img[0];
const box = img.getBoundingClientRect();
const card = img.closest('.wrolpi-card-poster').getBoundingClientRect();
expect(box.width, 'poster stays within the card').to.be.at.most(card.width + 0.5);
expect(box.height, 'poster is capped in height').to.be.at.most(cardPosterCap() + 0.5);
// Never upscaled: a small poster is left at its own size.
expect(box.width, 'poster is not stretched past its own size').to.be.at.most(w + 0.5);
expect(box.width / box.height, `${name} keeps its ratio`)
.to.be.closeTo(w / h, 0.01);
});
});
});
it('shrinks a tall poster by its width rather than squashing it', () => {
/*
* The failure mode a ratio check alone would miss: a height cap applied while the
* width is pinned crops or squashes instead of containing. A 600x600 source in a
* 233px card is width-bound at 233 if the cap is loose and height-bound if it is
* tight -- either way the OTHER axis must have moved with it.
*/
servePoster(600, 600);
cy.mountUI(narrowCard(<CardPoster file={posterFile(600, 600)}/>));
cy.get('.wrolpi-card-poster img')
.should(($img) => expect($img[0].naturalWidth).to.equal(600))
.should(($img) => {
const box = $img[0].getBoundingClientRect();
expect(box.height, 'the cap actually bit').to.be.at.most(cardPosterCap() + 0.5);
expect(box.width, 'and the width came down with it')
.to.be.closeTo(box.height, 0.5);
});
});
ui: let a landscape poster fill a one-column card, and fix three scale-blind tests `--card-poster-max-height` is a fixed height, so it stops scaling with the card: held to 220px, a 16:9 thumbnail is 391px wide, and any card wider than that centred it with empty panel on both sides. That is every video card at one column -- a phone, or any window under about 456px of content width. The cap is now `max(var(--card-poster-max-height), 56.25cqw)` with the poster band as the query container. 56.25cqw is nine sixteenths of the card: exactly the height of a 16:9 image that fills the width, and the same number states the rule for every other ratio -- a poster may be as tall as a 16:9 slice of this card and no taller. So a portrait book cover still reads as a band rather than a column, and now grows with the card instead of stopping at 220px. `max()` rather than `min()` so the floor wins on a narrow card. The gap pre-dated the interface scale, below about 414px, but the scale widened the range it shows in: the track minimum went from 200px to 220px, so one column now starts at 456px of content width instead of 414. Every existing poster case mounted a 233px card, which is why the wide card's own failure went unseen for the whole migration. Two cases added on a 451px card: a landscape poster reaches the edges, and a portrait cover stays a band. Three tests carried a hardcoded px expectation, which is a hidden assertion that the interface scale is 1. All three failed at 1.1, in names that said nothing about size -- and I did not catch them because I ran jest and the build for the scale change but not cypress, which AGENTS.md asks for on frontend work: - `cardPosterCap()` read `--card-poster-max-height` with parseFloat. The cap is rem now, so it returned 12.5 and failed a within(80, 240) bound -- taking five poster tests with it. It resolves through the root font-size and checks the unit. - `inNarrowColumn` was a fixed 340px, chosen to hold two 150px statistic tracks. At 165px tracks it became one column, so a test about the gap BETWEEN columns had no second column. It is now 340px times the scale, because "narrow" means narrow relative to the type. - The APIButton size test asserted 36px for `small`. It now measures against a real `sm` button, which is the claim it was making -- that `small` resolves to `sm` -- and holds at any scale. A `uiScale()` helper reads the token so no further test has to name a pixel count. Verified: ui-layout 248 passing, 0 failing; 1141 jest tests / 65 suites; clean build; browser-checked at 400/451/500/700/1200px of grid width, no side gap at any of them. The 12 remaining component failures are the pre-existing Semantic-era selector failures in Tags, Channels, Download and Inventory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:02:15 -06:00
it('lets a landscape poster fill a one-column card instead of letterboxing it', () => {
/*
* The cap is a fixed height, so it stops scaling with the card: past 391px of card
* width a 16:9 poster can no longer reach the edges and `justify-content: center`
* splits the remainder into two margins. On a phone -- one column, card the full
* width of the screen -- that is every video thumbnail in the library.
*
* A source wider than the card is the case that matters. 1280px of intrinsic width
* is available, so nothing here is upscaling: the poster is simply allowed to use
* the width it has.
*/
servePoster(1280, 720);
cy.mountUI(wideCard(<CardPoster file={posterFile(1280, 720)}/>));
cy.get('.wrolpi-card-poster img')
.should(($img) => expect($img[0].naturalWidth, 'poster loaded').to.equal(1280))
.should(($img) => {
const img = $img[0];
const box = img.getBoundingClientRect();
const band = img.closest('.wrolpi-card-poster').getBoundingClientRect();
expect(band.width - box.width, 'no empty panel beside the poster')
.to.be.at.most(1);
expect(box.width / box.height, 'and it still keeps its ratio')
.to.be.closeTo(1280 / 720, 0.01);
});
});
it('still keeps a portrait cover to a band on a one-column card', () => {
/*
* The other half, and the reason the cap exists at all: freed of it entirely, a
* 306x396 book cover in a 451px card would stand 451px tall above a two-line title,
* so the media dwarfs the thing it belongs to.
*
* The bound is stated as a fraction of the CARD rather than a pixel count, because
* that is the actual rule -- the poster may be as tall as a 16:9 slice of this card
* and no taller. A portrait cover therefore grows with the card, which it should,
* while never ceasing to be a band.
*/
servePoster(306, 396);
cy.mountUI(wideCard(<CardPoster file={posterFile(306, 396)}/>));
cy.get('.wrolpi-card-poster img')
.should(($img) => expect($img[0].naturalWidth, 'poster loaded').to.equal(306))
.should(($img) => {
const img = $img[0];
const box = img.getBoundingClientRect();
const band = img.closest('.wrolpi-card-poster').getBoundingClientRect();
expect(box.height / band.width, 'the cover stays a band, not a column')
.to.be.at.most(0.58);
expect(box.width / box.height, 'and keeps its ratio')
.to.be.closeTo(306 / 396, 0.01);
});
});
ui: cards get legible titles, contained posters, and meta beside the title Four defects on /videos, /docs and /archives. Titles were invisible outside light. `.card-link` carried a literal `color: black` from before the themes existed -- about 1.1:1 on the dark, night and amber panels. It applies to every card title and to the channel/author/domain line beside it. The date was fine, since it takes `--muted` from the card body, which is what made this look like a card bug rather than a link bug. Titles now take `--text`: they are links, but they are the card's text, not a wall of blue. Posters were cropped, not mis-proportioned. The image carried a fixed 290x163 box; a card in the default grid is about 233px wide and Mantine's Card sets `overflow: hidden`, so the browser painted the middle 233px of a 290px image. The ratio was right in the layout tree and wrong on screen. Replaced with caps on both axes -- the card's width and `--card-poster-max-height: 200px` -- with `width`/`height` left `auto` so the pair behaves as "contain". Bounding the width alone was tried first and is not enough: a square thumbnail then stands as tall as the card is wide, and a portrait book cover taller still. The meta line was foot-anchored, so on /docs a PDF with no author had its date shoved up to 55px below the title, at the bottom of a card that was tall only because of its neighbour in the row. It now sits directly under the title. Archive cards read buttons-then-domain, because the buttons were children and the meta was what got pushed to the foot. Card gains an `actions` slot, rendered last and anchored to the foot, so a row lines its buttons up however many lines each title took. Gallery gains a poster row covering all five ratios and a row showing meta/actions against unequal titles. 1076 jest tests, 145 in ui-layout.cy.js, clean build. Every new guard was checked against a planted regression: dropping the height cap reddens the square and portrait cases and leaves 16:9 green; `width: 100%` reddens containment; restoring `color: black` reddens dark/night/amber and leaves light green; re-anchoring the meta and swapping the slot order redden both the jest order test and the cypress geometry tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 09:16:31 -06:00
});
describe('a card reads as titles, not as a wall of links', () => {
/*
* A card's title and its author/channel/domain line are links, and they carried a
* literal `color: black` from before the themes existed. On the dark, night and amber
* panels that is about 1.1:1 -- the titles were there, and invisible. The date beside
* them was fine, because it takes `--muted` from the card body, which is what made the
* bug look like a card-title bug rather than a link bug.
*
* jsdom cannot see this: `.card-link` now resolves a custom property, and jsdom drops
* `color: var(--text)` as an invalid declaration.
*/
themeNames.forEach((theme) => {
it(`keeps a card title legible in ${theme}`, () => {
cy.mountUI(<MemoryRouter>
<Card title={<a href='/videos/1' className='no-link-underscore card-link'>
How To Sharpen An Axe
</a>} meta='Wranglerstar'/>
</MemoryRouter>, {theme});
cy.get('.card-link').should(($link) => {
const panel = toRgb(getComputedStyle(document.documentElement)
.getPropertyValue('--panel'));
const title = toRgb(getComputedStyle($link[0]).color);
expect(contrast(title, panel), `card title on the panel in ${theme}`)
.to.be.greaterThan(4.5);
});
});
});
});
describe('a card keeps its meta with the title and its actions at the foot', () => {
/*
* A grid stretches every card to the tallest in its row. The meta line used to carry
* `margin-top: auto`, so on /docs a PDF with no author had its date shoved 55px below
* the title it belongs to, at the bottom of a card that was tall only because of its
* neighbour. Actions are the thing that wants the foot -- a row of cards should line
* its buttons up however many lines each title took.
*
* Real layout, because `margin-top: auto` in a flex column is resolved by the layout
* engine and jsdom has none. The DOM ORDER half of this is in ui.test.js.
*/
const row = <div style={{display: 'flex', alignItems: 'stretch', width: 520}}>
{[
'A title long enough to wrap onto three separate lines inside a narrow card',
'Short',
].map((title, index) => <div key={index} style={{width: 240, display: 'flex'}}>
<Card title={title} meta='example.com · 2025-01-30'
actions={<Button>Details</Button>}/>
</div>)}
</div>;
it('leaves no gap between the title and the meta line', () => {
cy.mountUI(row);
cy.get('.wrolpi-card-meta').should(($metas) => {
expect($metas.length).to.equal(2);
const gaps = [...$metas].map((meta) => {
const title = meta.previousElementSibling;
return meta.getBoundingClientRect().top - title.getBoundingClientRect().bottom;
});
// The card body's own 4px gap, and nothing else.
gaps.forEach((gap, index) => expect(gap, `card ${index} title-to-meta`).to.be.at.most(6));
// Both cards really were stretched to the same height, or nothing was pushed.
const heights = [...Cypress.$('.mantine-Card-root')]
.map(card => Math.round(card.getBoundingClientRect().height));
expect(new Set(heights).size, 'the row stretched both cards equally').to.equal(1);
});
});
it('lines the actions up at the foot however tall the title got', () => {
cy.mountUI(row);
cy.get('.wrolpi-card-actions').should(($actions) => {
expect($actions.length).to.equal(2);
const [tall, short] = [...$actions];
// The premise: the two titles really are different heights.
const titleHeights = [...Cypress.$('.mantine-Card-root')].map(card =>
Math.round(card.lastElementChild.firstElementChild.getBoundingClientRect().height));
expect(new Set(titleHeights).size, 'the two titles differ in height').to.equal(2);
expect(tall.getBoundingClientRect().bottom, 'both action rows sit on the same line')
.to.be.closeTo(short.getBoundingClientRect().bottom, 1);
});
});
});
describe('a button and an icon button are the same height', () => {
/*
* Mantine gives ActionIcon a size scale of its own that is nothing like Button's --
* `sm` is 22px against a button's 36px -- and defaults it to `md` where Button defaults
* to `sm`. So the Details/Open pair on an archive card came out 36px beside 28px, and
* every other toolbar that mixes the two was ragged in the same way.
*
* Mantine already ships the aligned scale as `--ai-size-input-*`, for an ActionIcon
* sitting beside an Input; those five values are identical to `--button-height-*`. The
* fix points one at the other, so this holds for a size we have never used as well as
* the ones we have.
*
* Heights, so it belongs here: jsdom returns zero for both and the comparison would
* pass on any pair of numbers at all.
*/
const sizes = [undefined, 'xs', 'sm', 'md', 'lg', 'xl'];
sizes.forEach((size) => {
it(`matches at size ${size || '(default)'}`, () => {
cy.mountUI(<div style={{display: 'flex', gap: '0.5em', alignItems: 'flex-start'}}>
<Button size={size} icon='file alternate'>Details</Button>
<IconButton size={size} icon='external' label='Open original URL'/>
</div>);
cy.get('button').should(($buttons) => {
expect($buttons.length).to.equal(2);
const [button, iconButton] = [...$buttons].map(el => el.getBoundingClientRect());
// A zero-height pair would satisfy the equality below without meaning anything.
expect(button.height, 'the button has a height at all').to.be.greaterThan(10);
expect(iconButton.height, `icon button at size ${size || '(default)'}`)
.to.be.closeTo(button.height, 0.5);
// Square, which is the whole point of an icon button.
expect(iconButton.width, 'the icon button stays square')
.to.be.closeTo(iconButton.height, 0.5);
});
});
});
it('grows the icon button rather than shrinking the button', () => {
/*
* Both could be made equal by cutting the labelled button down to 28px, which would
* be the wrong fix -- a 28px target is below the 44px-ish guidance already stretched
* by having buttons this small, and every OTHER button on the page would still be 36.
* Pinned so a future "make them match" cannot resolve the other way.
*/
cy.mountUI(<IconButton icon='external' label='Open original URL'/>);
cy.get('button').should(($el) =>
expect($el[0].getBoundingClientRect().height, 'default icon button height')
.to.be.at.least(34));
});
});
ui: act on review -- corner chrome, a swallowed className, and the poster frame Three real defects from the PR review, each reproduced before it was fixed. The tag mark and a video's duration were pinned to the poster BAND, which is the full width of the card, rather than to the painted image. Once the height cap landed the two stopped being the same box: measured, the mark sat 39px clear of a book cover, 56px clear of a small poster and 60px clear of a vertical video, and the duration 55px clear. It went unnoticed because on a 16:9 poster the image fills the band and the two pin to the same place -- so the tests cover the height-bound ratios, and assert the letterbox gap is really there before measuring into it. CardPoster now centres a frame that shrink-wraps the image, and the frame is what corner chrome is positioned against. VideoCard passes its duration through a new `overlay` prop rather than wrapping CardPoster in a box of its own. The mark also went back INSIDE the link. Splitting it out made the tagged corner a dead spot on an otherwise clickable poster. CardLink and ExternalCardLink wrote `className='...' {...props}`, so a caller's className replaced the pair instead of adding to it. Every archive title passes `card-title-ellipsis`, so every archive title lost `card-link` -- the one card type this PR migrates for layout was the one missing the title treatment. Both compose now. On the fourth comment, the breadth of the ActionIcon remap: it is deliberate and the numbers are small. 59 IconButton call sites, 52 of them at the default size, 7 at `xs` (one in Flasher, three in the inventory schema editor). The one library control that stands beside an input rather than a button is SearchBox's clear, and the remap is exactly what that scale is for -- it now matches its field to the pixel, where before it was 28px against a 36px input. Guarded by a test that fails at 42 vs 36 if the default is reverted. 1078 jest, 158 in ui-layout.cy.js, clean build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 11:35:49 -06:00
describe('corner chrome sits on the poster, not on the band around it', () => {
/*
* The tag mark and the video duration are pinned to a corner of "the poster". Once the
* poster gained a height cap, the painted image stopped filling the band it sits in: a
* portrait cover is 155px wide inside a 233px card, and a vertical video narrower still.
* The mark then floats in empty letterbox space nowhere near the image's corner.
*
* Geometry against a real painted image, so it belongs here. It has to be checked on a
* ratio that is HEIGHT-bound -- on a 16:9 poster the image fills the band and a mark
* pinned to either one lands in the same place, which is why this went unnoticed.
*/
const tagged = (width, height) => ({...posterFile(width, height), tags: [{name: 'ham radio'}]});
[
{name: 'a portrait book cover', w: 306, h: 396},
{name: 'a vertical video', w: 720, h: 1280},
{name: 'a poster smaller than the card', w: 120, h: 90},
].forEach(({name, w, h}) => {
it(`pins the tag to the corner of ${name}`, () => {
servePoster(w, h);
cy.mountUI(narrowCard(<CardPoster file={tagged(w, h)}/>));
cy.get('.wrolpi-card-poster img')
.should(($img) => expect($img[0].naturalWidth, 'poster loaded').to.equal(w))
.should(($img) => {
const image = $img[0].getBoundingClientRect();
const band = $img[0].closest('.wrolpi-card-poster').getBoundingClientRect();
// The premise: this ratio really does leave letterbox space to get lost in.
expect(band.width - image.width, `${name} is narrower than its band`)
.to.be.greaterThan(20);
const mark = Cypress.$('.wrolpi-card-tag')[0].getBoundingClientRect();
expect(mark.left, 'tag tracks the image, not the band')
.to.be.closeTo(image.left, 2);
expect(mark.top, 'tag sits at the top of the image').to.be.closeTo(image.top, 2);
});
});
});
it('keeps the tag inside the poster link, so clicking it still navigates', () => {
// The mark used to render inside the Link beside the image and was part of the
// poster's hit target; a sibling placed before the link is a dead spot on the corner.
servePoster(306, 396);
cy.mountUI(narrowCard(<CardPoster to='/videos/1' file={tagged(306, 396)}/>));
cy.get('.wrolpi-card-tag').should(($tag) =>
expect($tag[0].closest('a'), 'the tag is inside the link').to.not.be.null);
});
});
describe('a video card pins its duration to the poster', () => {
/*
* The same defect as the tag mark, on the other corner and reached by a different
* route: the duration was pinned to a wrapper around CardPoster rather than to the
* poster itself. Mounted through the real VideoCard, because the wrapper was the
* subject and a hand-built poster would not have one.
*/
it('keeps the duration on a vertical video, not out in the band', () => {
servePoster(720, 1280);
// mountWithRouter, not mountUI: VideoCard reads the sort order from the query
// context, which the spartan mount deliberately does not provide.
cy.mountWithRouter(<div style={{width: 233}}><VideoCard file={{
id: 1, tags: [], length: 95, primary_path: 'videos/short.mp4',
title: 'A vertical video', mimetype: 'video/mp4',
poster_path: 'videos/poster-720x1280.svg',
video: {stem: 'short', channel: null},
}}/></div>);
cy.get('.wrolpi-card-poster img')
.should(($img) => expect($img[0].naturalWidth, 'poster loaded').to.equal(720))
.should(($img) => {
const image = $img[0].getBoundingClientRect();
const band = $img[0].closest('.wrolpi-card-poster').getBoundingClientRect();
expect(band.width - image.width, 'the poster is narrower than its band')
.to.be.greaterThan(20);
const badge = Cypress.$('.duration-overlay')[0].getBoundingClientRect();
expect(badge.right, 'the duration tracks the image, not the band')
.to.be.closeTo(image.right, 6);
});
});
});
describe('the search clear button matches the field it clears', () => {
/*
* Aligning IconButton with Button changed every icon button in the app, and this is the
* one in the library that stands beside an input rather than beside a button. It is
* also the case the remap was built for: `--ai-size-input-*` exists precisely so an
* ActionIcon can match an Input, so if this pair is ragged the remap picked the wrong
* scale.
*/
it('is exactly as tall as the search field', () => {
cy.mountUI(<SearchBox placeholder='Search' clearable value='axe' onChange={() => {}}/>);
cy.get('.wrolpi-searchbox-clear').should(($clear) => {
const input = Cypress.$('input')[0].getBoundingClientRect();
const clear = $clear[0].getBoundingClientRect();
expect(input.height, 'the field has a height at all').to.be.greaterThan(10);
expect(clear.height, 'clear button vs search field').to.be.closeTo(input.height, 0.5);
});
});
});
ui: centre the pagination strip It sat hard against the left edge of its container despite three call sites wrapping it in `<center>` or `text-align: center`. Mantine builds a Pagination as a BLOCK root -- full width, so those wrappers had nothing to centre -- holding a flex Group that carries the controls and lays them out at `flex-start`. So `justify-content` on the root does nothing at all; it has to reach the Group. Setting `--group-justify` on the root does not work either, which cost a detour: Group defaults that prop and writes the variable INLINE on its own element, where an inherited value cannot reach it. The property itself is fair game, since Mantine only ever reads the variable from a hashed class, so `.wrolpi-pagination .mantine-Group-root { justify-content: center }` at (0,2,0) is what lands. The three wrappers are now plain divs keeping their margin. `<center>` is a deprecated element that was doing nothing here. Two tests: the gap either side is equal -- measured, not read off `justify-content` -- with an assertion that the container really is wider than the strip, since otherwise the equality holds trivially at 0 and 0. And an inverse: at 240px nothing hangs off the LEFT edge. That one is the risk centring introduces -- overflow in a flex-start row spills right, where it can be scrolled to, but centred it spills both ways and the first page becomes unreachable. It passed before this change and must keep passing after. Verified red first (0px left against 230px right), and the wrong-element fix -- centring the root rather than the Group -- reddens it again. 1080 jest, 160 in ui-layout.cy.js, clean build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 13:00:56 -06:00
describe('pagination sits in the middle of its container', () => {
/*
* Three call sites wrap the pager in `<center>` or `text-align: center` and it still sat
* hard against the left edge. Both of those centre INLINE content, and Mantine's
* Pagination root is a flex container that fills its parent's width -- so the buttons
* were laid out at `flex-start` inside a box that was already the full width, and no
* amount of centring outside it could move them.
*
* Measured as the gap on each side rather than by reading `justify-content`, so the
* claim is about where the control actually lands.
*/
it('leaves the same gap either side', () => {
cy.mountUI(<div style={{width: 600}}>
<Pagination activePage={3} totalPages={12} onPageChange={() => {}}/>
</div>);
cy.get('.wrolpi-pagination').should(($pager) => {
const container = $pager[0].getBoundingClientRect();
const buttons = [...$pager[0].querySelectorAll('button')]
.map(button => button.getBoundingClientRect());
expect(buttons.length, 'the pager rendered its controls').to.be.greaterThan(3);
const left = Math.min(...buttons.map(b => b.left)) - container.left;
const right = container.right - Math.max(...buttons.map(b => b.right));
// The premise: the container really is wider than the strip, so there is slack
// to distribute. Without this the equality holds trivially at 0 and 0.
expect(left + right, 'the container is wider than the strip').to.be.greaterThan(40);
expect(left, 'gap left vs gap right').to.be.closeTo(right, 1);
});
});
it('does not push its first page off the left edge when space is tight', () => {
/*
* The risk centring introduces. Overflow in a `flex-start` row spills to the right,
* where it can at least be scrolled to; centred, it spills BOTH ways and the first
* page number is unreachable. 240px is narrower than any real layout gives it.
*/
cy.mountUI(<div style={{width: 240}}>
<Pagination activePage={6} totalPages={99} onPageChange={() => {}} showFirstAndLast/>
</div>);
cy.get('.wrolpi-pagination').should(($pager) => {
const container = $pager[0].getBoundingClientRect();
const buttons = [...$pager[0].querySelectorAll('button')]
.map(button => button.getBoundingClientRect());
expect(Math.min(...buttons.map(b => b.left)), 'nothing hangs off the left')
.to.be.at.least(container.left - 0.5);
});
});
});
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
describe('the navigation bar is legible on every color a user can pick', () => {
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
/*
* The bar's background is the one surface the USER chooses, by hue name, and each theme
* resolves those twelve names to twelve of its own colors. Forty-eight backgrounds; the
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
* links and status icons have to read on all of them. They did not -- every one was
* drawn in `--btn-text`, near-black in three of the four themes, against backgrounds like
* night's `--brown` (#451212). That glyph was 1.33:1 against the bar behind it.
*
* navColors.test.js measures the mapping against the palette parsed out of tokens.css,
* which is the cheap and exhaustive half. What it cannot see is whether the value the
* mapping returns reaches the pixels: whether the tokens resolve through the cascade,
* whether the style lands on the bar, and what an icon inside it actually inherits. So
* this measures the painted result and holds it against the number the component claims.
*
* `NavBarSample` is the gallery's bar rather than <NavBar/> itself, which needs the
* settings, status and worker contexts and a dozen polling hooks. Both build their style
* with the same `navBarStyle(useNavColors(color))` call, and navColors.test.js has a
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
* source guard holding NavBar to that.
*/
const barsFor = (theme) => {
cy.mountUI(<div>
{navColorNames.map(color => <NavBarSample key={color} color={color}/>)}
</div>, {theme});
};
themeNames.forEach((theme) => {
it(`paints a resolved background for all twelve colors in ${theme}`, () => {
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
barsFor(theme);
navColorNames.forEach((color) => {
cy.get(`[data-nav-sample="${color}"] .wrolpi-navbar`).should(($nav) => {
const background = getComputedStyle($nav[0]).backgroundColor;
// An unresolved token paints nothing at all, and a transparent bar over
// the page would read as "the color just looks wrong" rather than as a
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
// broken style.
expect(background, `${theme}/${color} bar background`)
.to.not.equal('rgba(0, 0, 0, 0)');
});
});
});
it(`clears 3:1 on every color in ${theme}`, () => {
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
/*
* 3:1 is the WCAG floor for graphical objects, which is what these icons are.
* Twelve of the forty-eight combinations were below it before measurement.
* Ten are still under 4.5:1 and cannot be lifted by any foreground -- a
* monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a
* hue carries no text of that same hue. That residue is the palette's, and it
* is printed beside each sample in the gallery so it can be decided on.
*/
barsFor(theme);
navColorNames.forEach((color) => {
cy.contrastRatio(`[data-nav-sample="${color}"] .wrolpi-navbar-link`)
.then((ratio) => {
expect(ratio, `${theme}/${color} link contrast`).to.be.greaterThan(3);
});
});
});
2026-08-02 14:12:39 -06:00
it(`gives EVERY icon in the corner the same foreground as its links in ${theme}`, () => {
/*
* The actual complaint was about the icons, not the words -- and about two of
* them specifically, the search glyph and the hamburger, which came out blue on
* every bar in every theme while the rest of the bar was correct.
*
* They inherit nothing. An anchor takes `a {color: var(--blue)}` from
* tokens.css, which outranks the bar's inherited value; a Mantine ActionIcon
* paints `--ai-color`, its own themed blue, and Mantine writes that variable
* INLINE so no stylesheet variable can reach it. Three routes to a color, of
2026-08-02 14:12:39 -06:00
* which one worked.
*
* `querySelectorAll`, and the count asserted, because the version of this test
* that shipped in the first pass read `querySelector('...svg')` -- one element,
* the first, which was a plain inheriting Icon. It claimed every icon and
* measured the only one that was never broken.
*/
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
barsFor(theme);
navColorNames.forEach((color) => {
cy.get(`[data-nav-sample="${color}"]`).should(($sample) => {
const link = $sample[0].querySelector('.wrolpi-navbar-link');
2026-08-02 14:12:39 -06:00
const expected = getComputedStyle(link).color;
const icons = [...$sample[0].querySelectorAll('.wrolpi-navbar-right svg')];
// Two bare Icons, one inside an anchor, one inside an ActionIcon. If
// this drops, the loop below is covering less than it says.
expect(icons.length, `${theme}/${color} icons found`).to.equal(4);
icons.forEach((icon, index) => {
expect(getComputedStyle(icon).color, `${theme}/${color} icon ${index}`)
.to.equal(expected);
});
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
});
});
});
it(`paints the ratio it reports in ${theme}`, () => {
/*
* Ties the number to the pixels. Without this the gallery could print a
* comfortable figure beside a bar drawn in something else entirely, and both
* halves would look right on their own.
*/
barsFor(theme);
navColorNames.forEach((color) => {
cy.get(`[data-nav-sample-ratio="${color}"]`).invoke('text').then((text) => {
const reported = parseFloat(text);
expect(reported, `${theme}/${color} reported a ratio`).to.be.greaterThan(1);
cy.contrastRatio(`[data-nav-sample="${color}"] .wrolpi-navbar-link`)
.then((painted) => {
expect(painted, `${theme}/${color} painted vs reported`)
.to.be.closeTo(reported, 0.05);
});
});
});
});
});
it('does not simply use --btn-text everywhere, which is what it replaced', () => {
/*
* The inverse. Every case above would pass on the old fixed foreground in the two
* themes where `--btn-text` happens to be the right end of the palette, so without
* this the suite could go green on a revert. Night is where the difference is
review: measure what can be measured, and say what is not Acting on the review of #621. No bugs were found; these are the four suggestions and two nits. The real one: measurement accepted only hex. `relativeLuminance` returned 0 for anything else, which is black's luminance and indistinguishable from it -- so a token written `rgb(92 79 168)` measured as pure black, the "best" foreground was chosen against a colour the theme does not contain, and the wrong hex was then frozen into an inline style where CSS could no longer correct it. Silent, and worse than not measuring. `parseColor` now reads `rgb()`/`rgba()` in both the comma and space forms, percentages, and `#rgba`/`#rrggbbaa`; `isMeasurable` lets a caller tell "unreadable" from "black"; and navColorsFrom falls back to the tokens when the background or every candidate is unreadable. Unreadable candidates are filtered rather than the whole measurement abandoned, so one oddly written token does not cost the other two. This matters because the header claimed custom YAML themes get correct foregrounds for free, and a hand-written palette is exactly where a non-hex value will first appear. The Cypress inverse hardcoded night's `--btn-text` as `#0a0000`. The unit tests parse tokens.css precisely so a palette edit cannot leave a stale claim behind, and that literal was the one place the rule was broken. It reads the token from the theme now, asserts it resolved, and additionally pins that red still takes `--btn-text` while brown no longer does. Documented rather than changed: the warning indicators still pick their colour from the `conflictingColors` name list. It is the same defect as the one fixed here and measurably worse -- `--danger` and `--warning` are 1.0-1.8:1 against the bar in every theme, light and dark included, because a red icon on a red bar is a red icon on a red bar. The fix is not a better colour: severity has to stay distinguishable from the bar's text as well as from itself, and a monochrome theme has no third brightness, so it has to stop being a hue. That is a redesign, and the note now sits beside the residue in navColors.ts rather than only in a PR description. The gallery draws the indicators as the bar draws them when nothing is wrong; it does not stage a fake overheating Pi to exhibit a fault nobody has agreed how to fix. Also documented: re-measurement is triggered by `data-theme`, so a future custom-theme editor patching custom properties in place would leave the bar on the values it last measured. There is no event for "a custom property was assigned" to observe instead, so the note says what such an editor must do. Nits: "Eleven" in a comment where the assertion locks ten (and a stale 2.91:1 beside it, now 3.27:1), and a missing space in `const wrolpiIcon =<img`. Six new unit cases, planted: dropping the fallback reddens two. 1121 jest / 62 suites, 196 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:57:17 -06:00
* largest: `--brown` takes `--white` and `--red` keeps `--btn-text`, so the bar's
* foreground is demonstrably not one value.
*
* `--btn-text` is READ from the theme rather than written out as a hex. The unit
* tests parse tokens.css precisely so a palette edit cannot leave a stale claim
* behind, and a literal here would be the one place that rule was broken -- it would
* either go stale or quietly stop testing anything if night's token moved.
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
*/
cy.mountUI(<div>
<NavBarSample color='brown'/>
<NavBarSample color='red'/>
</div>, {theme: 'night'});
cy.get('[data-nav-sample="brown"] .wrolpi-navbar-link').then(($brown) => {
cy.get('[data-nav-sample="red"] .wrolpi-navbar-link').then(($red) => {
const brown = getComputedStyle($brown[0]).color;
const red = getComputedStyle($red[0]).color;
review: measure what can be measured, and say what is not Acting on the review of #621. No bugs were found; these are the four suggestions and two nits. The real one: measurement accepted only hex. `relativeLuminance` returned 0 for anything else, which is black's luminance and indistinguishable from it -- so a token written `rgb(92 79 168)` measured as pure black, the "best" foreground was chosen against a colour the theme does not contain, and the wrong hex was then frozen into an inline style where CSS could no longer correct it. Silent, and worse than not measuring. `parseColor` now reads `rgb()`/`rgba()` in both the comma and space forms, percentages, and `#rgba`/`#rrggbbaa`; `isMeasurable` lets a caller tell "unreadable" from "black"; and navColorsFrom falls back to the tokens when the background or every candidate is unreadable. Unreadable candidates are filtered rather than the whole measurement abandoned, so one oddly written token does not cost the other two. This matters because the header claimed custom YAML themes get correct foregrounds for free, and a hand-written palette is exactly where a non-hex value will first appear. The Cypress inverse hardcoded night's `--btn-text` as `#0a0000`. The unit tests parse tokens.css precisely so a palette edit cannot leave a stale claim behind, and that literal was the one place the rule was broken. It reads the token from the theme now, asserts it resolved, and additionally pins that red still takes `--btn-text` while brown no longer does. Documented rather than changed: the warning indicators still pick their colour from the `conflictingColors` name list. It is the same defect as the one fixed here and measurably worse -- `--danger` and `--warning` are 1.0-1.8:1 against the bar in every theme, light and dark included, because a red icon on a red bar is a red icon on a red bar. The fix is not a better colour: severity has to stay distinguishable from the bar's text as well as from itself, and a monochrome theme has no third brightness, so it has to stop being a hue. That is a redesign, and the note now sits beside the residue in navColors.ts rather than only in a PR description. The gallery draws the indicators as the bar draws them when nothing is wrong; it does not stage a fake overheating Pi to exhibit a fault nobody has agreed how to fix. Also documented: re-measurement is triggered by `data-theme`, so a future custom-theme editor patching custom properties in place would leave the bar on the values it last measured. There is no event for "a custom property was assigned" to observe instead, so the note says what such an editor must do. Nits: "Eleven" in a comment where the assertion locks ten (and a stale 2.91:1 beside it, now 3.27:1), and a missing space in `const wrolpiIcon =<img`. Six new unit cases, planted: dropping the fallback reddens two. 1121 jest / 62 suites, 196 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:57:17 -06:00
const btnText = getComputedStyle(document.documentElement)
.getPropertyValue('--btn-text');
// The premise: the token resolved. `toRgb` throws on an unresolved value
// rather than letting the comparison below pass by comparing nothing.
expect(toRgb(btnText), 'night --btn-text resolved').to.match(/^rgb/);
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
expect(brown, 'brown and red bars take different foregrounds')
.to.not.equal(red);
// And the one that changed is the one that was unreadable.
expect(toRgb(brown), 'brown no longer takes --btn-text')
review: measure what can be measured, and say what is not Acting on the review of #621. No bugs were found; these are the four suggestions and two nits. The real one: measurement accepted only hex. `relativeLuminance` returned 0 for anything else, which is black's luminance and indistinguishable from it -- so a token written `rgb(92 79 168)` measured as pure black, the "best" foreground was chosen against a colour the theme does not contain, and the wrong hex was then frozen into an inline style where CSS could no longer correct it. Silent, and worse than not measuring. `parseColor` now reads `rgb()`/`rgba()` in both the comma and space forms, percentages, and `#rgba`/`#rrggbbaa`; `isMeasurable` lets a caller tell "unreadable" from "black"; and navColorsFrom falls back to the tokens when the background or every candidate is unreadable. Unreadable candidates are filtered rather than the whole measurement abandoned, so one oddly written token does not cost the other two. This matters because the header claimed custom YAML themes get correct foregrounds for free, and a hand-written palette is exactly where a non-hex value will first appear. The Cypress inverse hardcoded night's `--btn-text` as `#0a0000`. The unit tests parse tokens.css precisely so a palette edit cannot leave a stale claim behind, and that literal was the one place the rule was broken. It reads the token from the theme now, asserts it resolved, and additionally pins that red still takes `--btn-text` while brown no longer does. Documented rather than changed: the warning indicators still pick their colour from the `conflictingColors` name list. It is the same defect as the one fixed here and measurably worse -- `--danger` and `--warning` are 1.0-1.8:1 against the bar in every theme, light and dark included, because a red icon on a red bar is a red icon on a red bar. The fix is not a better colour: severity has to stay distinguishable from the bar's text as well as from itself, and a monochrome theme has no third brightness, so it has to stop being a hue. That is a redesign, and the note now sits beside the residue in navColors.ts rather than only in a PR description. The gallery draws the indicators as the bar draws them when nothing is wrong; it does not stage a fake overheating Pi to exhibit a fault nobody has agreed how to fix. Also documented: re-measurement is triggered by `data-theme`, so a future custom-theme editor patching custom properties in place would leave the bar on the values it last measured. There is no event for "a custom property was assigned" to observe instead, so the note says what such an editor must do. Nits: "Eleven" in a comment where the assertion locks ten (and a stale 2.91:1 beside it, now 3.27:1), and a missing space in `const wrolpiIcon =<img`. Six new unit cases, planted: dropping the fallback reddens two. 1121 jest / 62 suites, 196 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:57:17 -06:00
.to.not.equal(toRgb(btnText));
// While red, which was always legible, still does.
expect(toRgb(red), 'red still takes --btn-text').to.equal(toRgb(btnText));
ui: the navbar measures its foreground instead of assuming one The bar's background is the one surface a user picks -- twelve colour names, which each theme resolves to twelve of its own colours. Forty-eight backgrounds, and the links and status icons were drawn on all of them in a single token, `--btn-text`, which is near-black in three of the four themes. Night's `--brown` is #451212. A near-black glyph on it is 1.33:1. Nine of night's twelve colours and seven of amber's sat below 4.5:1, and twelve of the forty-eight below 3:1 -- icons the same colour as the bar behind them. So the foreground is measured against the background the theme actually resolved, choosing between that theme's own `--btn-text`, `--black` and `--white`. Its own, not literal ones: a white pixel in night mode undoes the dark adaptation the theme exists to protect, so night's "white" is #ff8a8a. Measuring at runtime rather than shipping an `--on-red` token per colour also means the custom YAML themes still ahead get this for free. Nothing is below 3:1 any more and the worst case is 3.27:1, up from 1.33:1. No combination is worse than it was. Ten of the forty-eight are still under 4.5:1 and no foreground will lift them: a monochrome theme resolves all twelve names onto one ramp, and a mid-tone of a hue cannot carry text of that same hue. That shortfall is in the palette, so /theme-sample now draws all twelve bars with the measured ratio printed beside each one, calling out the ten -- it is a decision to make while looking at them. The WCAG primitives move to themes/contrast so theme code can measure a colour without importing Common.js, which pulls in half the component library. Common.js forwards `contrastRatio` with a delegating function rather than a bare re-export: six specs mock it with `{...jest.requireActual('./Common')}`, the spread invokes every getter, and those spreads run re-entrantly while the module is still evaluating -- a re-export getter fires before its import binding exists and takes the whole suite down. Tested: navColors.test.js measures all forty-eight against the palette parsed out of tokens.css, and holds Nav.js to the call by source since neither bar is reachable from a test that could measure it. ui-layout.cy.js measures the painted result in a real browser in all four themes and holds it against the number the component reports. Reverting to the fixed foreground reddens four jest cases and three cypress ones. 1115 jest / 62 suites, 177 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:07:19 -06:00
});
});
});
});
ui: the navbar corner was nudged rather than laid out, and it showed Three faults in the bar, all reproduced by measurement before being fixed. The indicators sat low. The slot carried `marginTop: 0.8em`, a nudge left over from Semantic's menu; the corner centres its children, and a top margin is part of the margin box being centred, so it applied as a ~6px downward shift. It read as an error on the hotspot and the theme picker but not on share or search, which is why it survived: an IconButton is a square ActionIcon that centres its glyph exactly, while a bare-icon anchor sits high inside a line box that reserves descender space for text that is not there. The nudge cancelled that out on one shape and was pure error on the other. Both are laid out now -- flex, centred, no nudge -- and the anchors get `display: flex` so they hug their glyph instead of a text line. Help and Admin highlighted only a box around their text while Videos and Statistics highlighted the full height. Same class, same rules, different parent: the bar stretches its children, but the corner is a nested flex container that centres its own, so a link inside it was sized to its content. The hover background is painted on the link box, so that box IS the affordance. The bar broke onto a second line at certain widths. Two measurement errors that only overlap in a narrow band, which is why it appeared while resizing rather than always. useOverflowNav measured the WRAPPER's offsetWidth and subtracted only the home link and the corner, missing the bar's own `padding: 0 0.25em` -- about 8px it believed it had. And the hidden "More" placeholder it measured was a plain button with no dropdown caret, about 21px narrower than the button that eventually rendered. The placeholder is now the same component as the real trigger, so the two cannot drift again. Tested in ui-layout.cy.js against the real <DesktopNav/>, which takes its colours, home link and indicators as props and so needs none of NavBar's polling hooks. Indicator centres are measured against the bar's centre rather than each other, because three things can be equally and consistently wrong and were. The wrap case sweeps 1180px down to 640px in 6px steps -- a spot check steps over a band that narrow. All three failed first: share 3.4px high, Help 24.8px against a 54.4px bar, and two rows at 1156px. Confirmed on the running app: every indicator at 0.0px from the bar's centre, Help and Admin at the full 54.4px, and no wrap anywhere from 1500px to 780px. 1115 jest / 62 suites, 182 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:25:04 -06:00
describe('the navigation bar corner', () => {
/*
* The real <DesktopNav/>, which takes its colors, home link and indicators as props and
ui: the navbar corner was nudged rather than laid out, and it showed Three faults in the bar, all reproduced by measurement before being fixed. The indicators sat low. The slot carried `marginTop: 0.8em`, a nudge left over from Semantic's menu; the corner centres its children, and a top margin is part of the margin box being centred, so it applied as a ~6px downward shift. It read as an error on the hotspot and the theme picker but not on share or search, which is why it survived: an IconButton is a square ActionIcon that centres its glyph exactly, while a bare-icon anchor sits high inside a line box that reserves descender space for text that is not there. The nudge cancelled that out on one shape and was pure error on the other. Both are laid out now -- flex, centred, no nudge -- and the anchors get `display: flex` so they hug their glyph instead of a text line. Help and Admin highlighted only a box around their text while Videos and Statistics highlighted the full height. Same class, same rules, different parent: the bar stretches its children, but the corner is a nested flex container that centres its own, so a link inside it was sized to its content. The hover background is painted on the link box, so that box IS the affordance. The bar broke onto a second line at certain widths. Two measurement errors that only overlap in a narrow band, which is why it appeared while resizing rather than always. useOverflowNav measured the WRAPPER's offsetWidth and subtracted only the home link and the corner, missing the bar's own `padding: 0 0.25em` -- about 8px it believed it had. And the hidden "More" placeholder it measured was a plain button with no dropdown caret, about 21px narrower than the button that eventually rendered. The placeholder is now the same component as the real trigger, so the two cannot drift again. Tested in ui-layout.cy.js against the real <DesktopNav/>, which takes its colours, home link and indicators as props and so needs none of NavBar's polling hooks. Indicator centres are measured against the bar's centre rather than each other, because three things can be equally and consistently wrong and were. The wrap case sweeps 1180px down to 640px in 6px steps -- a spot check steps over a band that narrow. All three failed first: share 3.4px high, Help 24.8px against a 54.4px bar, and two rows at 1156px. Confirmed on the running app: every indicator at 0.0px from the bar's centre, Help and Admin at the full 54.4px, and no wrap anywhere from 1500px to 780px. 1115 jest / 62 suites, 182 in ui-layout.cy.js, clean npm run build.
2026-08-02 14:25:04 -06:00
* so needs none of the polling hooks <NavBar/> wires up. The indicators are the shapes
* the app actually puts there, in the real NavIconWrapper: a bare-icon anchor (share), an
* unwrapped anchor (search), and two IconButtons (hotspot, theme picker). Those three
* shapes take their geometry by three different routes, which is the whole problem.
*/
const indicators = <>
<NavIconWrapper>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a href='#' data-testid='share'><Icon name='share' size='large'/></a>
</NavIconWrapper>
<NavIconWrapper>
<IconButton data-testid='hotspot' label='Hotspot' variant='subtle' icon={() =>
<IconStack corner={<Icon name='x' size={12}/>} label='Hotspot'>
<Icon name='wifi' size='large'/>
</IconStack>}/>
</NavIconWrapper>
<NavIconWrapper>
<IconButton data-testid='theme' icon='sun' label='Theme' variant='subtle'/>
</NavIconWrapper>
</>;
const mountBar = (width, theme = 'light') => cy.mountUI(
<MemoryRouter><div style={{width}}>
<DesktopNav
navColors={{background: '#5c4fa8', color: '#ffffff', ratio: 6.69}}
homeLink={<a className='wrolpi-navbar-link' href='#'><i>WROLPi</i></a>}
icons={indicators}
/>
</div></MemoryRouter>,
{theme},
);
const centreOf = (rect) => rect.top + rect.height / 2;
it('centres every indicator on the bar, whatever shape it is', () => {
/*
* The bug this replaces was a 0.8em top margin on the slot, which the corner centres
* along with its content and so half-applied as a ~6px downward shift. It looked
* correct on the anchors and wrong on the two IconButtons, because an anchor's glyph
* already sits high inside a line box that reserves descender space.
*
* Measured against the bar's own centre rather than against each other: three things
* can be equally and consistently wrong, and were.
*/
mountBar(1400);
cy.get('.wrolpi-navbar').should(($nav) => {
const bar = centreOf($nav[0].getBoundingClientRect());
['share', 'hotspot', 'theme'].forEach((name) => {
const glyph = $nav[0].querySelector(`[data-testid="${name}"] svg`);
expect(glyph, `${name} has a glyph`).to.not.be.null;
expect(centreOf(glyph.getBoundingClientRect()), `${name} vertical centre`)
.to.be.closeTo(bar, 1.5);
});
});
});
it('gives the right-hand links the same hit area as the left-hand ones', () => {
/*
* Help and Admin highlighted only a box around their text, while Videos and
* Statistics highlighted the full height of the bar. The corner is a nested flex
* container that centres its children, so a link inside it is sized to its content
* while a link that is a direct child of the bar is stretched by `align-items:
* stretch`. Same class, same rules, different parent.
*
* The hover background is painted on the link box, so this IS the hover affordance.
*/
mountBar(1400);
cy.get('.wrolpi-navbar').should(($nav) => {
const bar = $nav[0].getBoundingClientRect().height;
const links = [...$nav[0].querySelectorAll('.wrolpi-navbar-link')];
const corner = [...$nav[0]
.querySelectorAll('.wrolpi-navbar-right .wrolpi-navbar-link')];
// Help and Admin. If the corner has no links this passes on an empty list.
expect(corner.length, 'links in the corner').to.be.at.least(2);
expect(links.length, 'links in total').to.be.greaterThan(corner.length);
corner.forEach((link) => {
expect(link.getBoundingClientRect().height, `${link.textContent} hit area`)
.to.be.closeTo(bar, 1);
});
});
});
it('is a real constraint: the left-hand links already filled the bar', () => {
// Without this the case above could pass by the bar having collapsed to the height
// of its text, which would be a different bug wearing the same number.
mountBar(1400);
cy.get('.wrolpi-navbar').should(($nav) => {
const bar = $nav[0].getBoundingClientRect();
const first = $nav[0].querySelector('.wrolpi-navbar-link');
expect(bar.height, 'the bar is taller than a line of text').to.be.greaterThan(40);
expect(first.getBoundingClientRect().height, 'a left-hand link fills it')
.to.be.closeTo(bar.height, 1);
});
});
});
describe('the navigation bar never breaks onto a second line', () => {
/*
* The bar wraps as a failsafe (`flex-wrap: wrap`) and useOverflowNav is supposed to make
* that unreachable by moving links into "More" before they overflow. At certain widths
* it did not, and the bar took two rows.
*
* The arithmetic was off by the bar's own horizontal padding: `recalculate` measured the
* WRAPPER div's offsetWidth and subtracted only the home link and the corner, so it
* believed it had ~8px more room than the row actually has. Any width where the last
* link overhangs by less than that got shown and wrapped -- a narrow band, which is why
* it appeared only "at certain widths" while resizing.
*
* Swept rather than spot-checked, because a band that narrow is precisely what a
* spot-check steps over.
*/
/*
* Hoisted, not written inline into `icons={...}`. The icon-name audit in ui.test.js
* reads every string literal inside such an expression as an icon name, so an inline
* `label='Theme' variant='subtle'` fails that test with two names nobody wrote.
*/
const themeIcon = <NavIconWrapper>
<IconButton icon='sun' label='Theme' variant='subtle'/>
</NavIconWrapper>;
const mountAt = (width) => cy.mountUI(
<MemoryRouter><div style={{width}}>
<DesktopNav
navColors={{background: '#5c4fa8', color: '#ffffff', ratio: 6.69}}
homeLink={<a className='wrolpi-navbar-link' href='#'><i>WROLPi</i></a>}
icons={themeIcon}
/>
</div></MemoryRouter>,
);
// Wide enough that every link fits, so this is the height of exactly one row.
let singleRow;
before(() => {
mountAt(1600);
cy.get('.wrolpi-navbar').then(($nav) => {
singleRow = $nav[0].getBoundingClientRect().height;
expect(singleRow, 'a single row has a height to compare against')
.to.be.greaterThan(30);
});
});
/*
* 6px steps across the range where links start moving into More. Fine enough to land
* inside an 8px band wherever it falls.
*/
const widths = [];
for (let width = 1180; width >= 640; width -= 6) widths.push(width);
it('stays one row at every width from 1180 down to 640', () => {
widths.forEach((width) => {
mountAt(width);
cy.get('.wrolpi-navbar').should(($nav) => {
expect($nav[0].getBoundingClientRect().height, `bar height at ${width}px`)
.to.be.at.most(singleRow + 2);
});
});
});
it('keeps every visible link inside the bar rather than clipping it', () => {
// The failure mode a naive "just use nowrap" fix would introduce: no second row,
// but Admin hanging off the right edge where nothing can reach it.
[1180, 1000, 860, 720, 640].forEach((width) => {
mountAt(width);
cy.get('.wrolpi-navbar').should(($nav) => {
const bar = $nav[0].getBoundingClientRect();
[...$nav[0].querySelectorAll('.wrolpi-navbar-link')].forEach((link) => {
expect(link.getBoundingClientRect().right, `${link.textContent} at ${width}px`)
.to.be.at.most(bar.right + 0.5);
});
});
});
});
});
ui: the corner triggers, the More button, and the search modal Four faults, each measured in the running app before and after. The search glyph carried Semantic's `item` class, which has had no rules at all since Semantic was removed: no pointer cursor, no hover, and an 18.6px hit area against a 54.4px bar. It is the same kind of thing as Help and Admin and now takes the same class. The share glyph did compute `cursor: pointer` -- it is an `<a href>` -- but its target was the 24px box the icon occupies, so the pointer appeared only if you found it exactly. Corner anchors now stretch and pad like a link. The More button rendered with NO class at all: a bare grey UA button while the rest of the bar took the user's colour. Menu.Target clones its child and hands it a className of its own, and the trigger spread those cloned props after its own `className` attribute, so the clone replaced ours. It is merged now. This was mine, from extracting NavDropdownTrigger last commit -- and it also made the previous commit's "measured and drawn are the same component" claim only half true, because the hidden placeholder is not cloned and so kept its class. The bar still wrapped, for a reason the padding fix could not reach: the corner does not keep a constant width. The Cmd-K hint renders only once useKeyboardDetected has seen a keypress, so it appears at an arbitrary later moment and widens the corner by ~30px; the load, memory, temperature and drive warnings come and go with the machine's state. None of that resizes the container, which was the only thing observed -- so nothing recalculated. That is the other half of "at certain widths": the same viewport wrapped or not depending on whether the user had touched a key. The corner and the home link are observed too now. The search modal showed an input and the first line of the first group. The suggestion list is absolutely positioned, which is right everywhere else -- a list that reflows the page while you type is unusable -- but in a modal it fails twice: an absolute list adds no height, so the panel sized itself to the search box alone at 114px, and the panel's own `overflow: auto` then clipped the list at that edge. In the modal the list sits in flow; the inverse is asserted so the rule cannot leak to the pages where overlaying is correct. Two of the new tests were wrong first and reverting the fix left them green: they asserted hand-written markup carrying the classes I expected the components to have, rather than the real SearchIconButton and ShareButton. They use the real components now. Every fix was then planted against: 5 red for the More class, 2 for the search class, 2 for the corner hit area, 1 for the observer, 2 for the modal. 1115 jest / 62 suites, 196 in ui-layout.cy.js, clean npm run build. Confirmed live: share and search both pointer at 54.4px, More white on the bar colour with a transparent face, and the modal's list in flow and unclipped.
2026-08-02 14:45:49 -06:00
describe('the navbar overflow menu keeps the bar\'s styling', () => {
/*
* Mantine's Menu.Target clones its child and hands it a className of its own. The
* trigger spread those cloned props AFTER its own `className` attribute, so the cloned
* value replaced ours and the real More button rendered with NO class at all -- a bare
* UA button, grey on dark and white on light, while every other item in the bar took the
* user's navbar color.
ui: the corner triggers, the More button, and the search modal Four faults, each measured in the running app before and after. The search glyph carried Semantic's `item` class, which has had no rules at all since Semantic was removed: no pointer cursor, no hover, and an 18.6px hit area against a 54.4px bar. It is the same kind of thing as Help and Admin and now takes the same class. The share glyph did compute `cursor: pointer` -- it is an `<a href>` -- but its target was the 24px box the icon occupies, so the pointer appeared only if you found it exactly. Corner anchors now stretch and pad like a link. The More button rendered with NO class at all: a bare grey UA button while the rest of the bar took the user's colour. Menu.Target clones its child and hands it a className of its own, and the trigger spread those cloned props after its own `className` attribute, so the clone replaced ours. It is merged now. This was mine, from extracting NavDropdownTrigger last commit -- and it also made the previous commit's "measured and drawn are the same component" claim only half true, because the hidden placeholder is not cloned and so kept its class. The bar still wrapped, for a reason the padding fix could not reach: the corner does not keep a constant width. The Cmd-K hint renders only once useKeyboardDetected has seen a keypress, so it appears at an arbitrary later moment and widens the corner by ~30px; the load, memory, temperature and drive warnings come and go with the machine's state. None of that resizes the container, which was the only thing observed -- so nothing recalculated. That is the other half of "at certain widths": the same viewport wrapped or not depending on whether the user had touched a key. The corner and the home link are observed too now. The search modal showed an input and the first line of the first group. The suggestion list is absolutely positioned, which is right everywhere else -- a list that reflows the page while you type is unusable -- but in a modal it fails twice: an absolute list adds no height, so the panel sized itself to the search box alone at 114px, and the panel's own `overflow: auto` then clipped the list at that edge. In the modal the list sits in flow; the inverse is asserted so the rule cannot leak to the pages where overlaying is correct. Two of the new tests were wrong first and reverting the fix left them green: they asserted hand-written markup carrying the classes I expected the components to have, rather than the real SearchIconButton and ShareButton. They use the real components now. Every fix was then planted against: 5 red for the More class, 2 for the search class, 2 for the corner hit area, 1 for the observer, 2 for the modal. 1115 jest / 62 suites, 196 in ui-layout.cy.js, clean npm run build. Confirmed live: share and search both pointer at 54.4px, More white on the bar colour with a transparent face, and the modal's list in flow and unclipped.
2026-08-02 14:45:49 -06:00
*
* The hidden placeholder DesktopNav measures is NOT cloned by Menu.Target, so it kept its
* class and stayed the width the styled button would have been. That is why the width
* sweep passed while the visible button was wrong: the two were the same component and
* still not the same thing.
*/
const themeIcon = <NavIconWrapper>
<IconButton icon='sun' label='Theme' variant='subtle'/>
</NavIconWrapper>;
// Narrow enough that links have to move into More.
const mountNarrow = (theme) => cy.mountUI(
<MemoryRouter><div style={{width: 700}}>
<DesktopNav
navColors={{background: '#5c4fa8', color: '#ffffff', ratio: 6.69}}
homeLink={<a className='wrolpi-navbar-link' href='#'><i>WROLPi</i></a>}
icons={themeIcon}
/>
</div></MemoryRouter>,
{theme},
);
const moreButton = () => cy.contains('.wrolpi-navbar button', 'More');
themeNames.forEach((theme) => {
it(`draws More in the bar's own color in ${theme}`, () => {
ui: the corner triggers, the More button, and the search modal Four faults, each measured in the running app before and after. The search glyph carried Semantic's `item` class, which has had no rules at all since Semantic was removed: no pointer cursor, no hover, and an 18.6px hit area against a 54.4px bar. It is the same kind of thing as Help and Admin and now takes the same class. The share glyph did compute `cursor: pointer` -- it is an `<a href>` -- but its target was the 24px box the icon occupies, so the pointer appeared only if you found it exactly. Corner anchors now stretch and pad like a link. The More button rendered with NO class at all: a bare grey UA button while the rest of the bar took the user's colour. Menu.Target clones its child and hands it a className of its own, and the trigger spread those cloned props after its own `className` attribute, so the clone replaced ours. It is merged now. This was mine, from extracting NavDropdownTrigger last commit -- and it also made the previous commit's "measured and drawn are the same component" claim only half true, because the hidden placeholder is not cloned and so kept its class. The bar still wrapped, for a reason the padding fix could not reach: the corner does not keep a constant width. The Cmd-K hint renders only once useKeyboardDetected has seen a keypress, so it appears at an arbitrary later moment and widens the corner by ~30px; the load, memory, temperature and drive warnings come and go with the machine's state. None of that resizes the container, which was the only thing observed -- so nothing recalculated. That is the other half of "at certain widths": the same viewport wrapped or not depending on whether the user had touched a key. The corner and the home link are observed too now. The search modal showed an input and the first line of the first group. The suggestion list is absolutely positioned, which is right everywhere else -- a list that reflows the page while you type is unusable -- but in a modal it fails twice: an absolute list adds no height, so the panel sized itself to the search box alone at 114px, and the panel's own `overflow: auto` then clipped the list at that edge. In the modal the list sits in flow; the inverse is asserted so the rule cannot leak to the pages where overlaying is correct. Two of the new tests were wrong first and reverting the fix left them green: they asserted hand-written markup carrying the classes I expected the components to have, rather than the real SearchIconButton and ShareButton. They use the real components now. Every fix was then planted against: 5 red for the More class, 2 for the search class, 2 for the corner hit area, 1 for the observer, 2 for the modal. 1115 jest / 62 suites, 196 in ui-layout.cy.js, clean npm run build. Confirmed live: share and search both pointer at 54.4px, More white on the bar colour with a transparent face, and the modal's list in flow and unclipped.
2026-08-02 14:45:49 -06:00
mountNarrow(theme);
cy.get('.wrolpi-navbar').then(($nav) => {
const expected = getComputedStyle($nav[0]).color;
moreButton().should(($more) => {
const style = getComputedStyle($more[0]);
expect($more[0].className, 'More carries the bar classes')
.to.contain('wrolpi-navbar-link');
expect(style.color, `More text color in ${theme}`).to.equal(expected);
ui: the corner triggers, the More button, and the search modal Four faults, each measured in the running app before and after. The search glyph carried Semantic's `item` class, which has had no rules at all since Semantic was removed: no pointer cursor, no hover, and an 18.6px hit area against a 54.4px bar. It is the same kind of thing as Help and Admin and now takes the same class. The share glyph did compute `cursor: pointer` -- it is an `<a href>` -- but its target was the 24px box the icon occupies, so the pointer appeared only if you found it exactly. Corner anchors now stretch and pad like a link. The More button rendered with NO class at all: a bare grey UA button while the rest of the bar took the user's colour. Menu.Target clones its child and hands it a className of its own, and the trigger spread those cloned props after its own `className` attribute, so the clone replaced ours. It is merged now. This was mine, from extracting NavDropdownTrigger last commit -- and it also made the previous commit's "measured and drawn are the same component" claim only half true, because the hidden placeholder is not cloned and so kept its class. The bar still wrapped, for a reason the padding fix could not reach: the corner does not keep a constant width. The Cmd-K hint renders only once useKeyboardDetected has seen a keypress, so it appears at an arbitrary later moment and widens the corner by ~30px; the load, memory, temperature and drive warnings come and go with the machine's state. None of that resizes the container, which was the only thing observed -- so nothing recalculated. That is the other half of "at certain widths": the same viewport wrapped or not depending on whether the user had touched a key. The corner and the home link are observed too now. The search modal showed an input and the first line of the first group. The suggestion list is absolutely positioned, which is right everywhere else -- a list that reflows the page while you type is unusable -- but in a modal it fails twice: an absolute list adds no height, so the panel sized itself to the search box alone at 114px, and the panel's own `overflow: auto` then clipped the list at that edge. In the modal the list sits in flow; the inverse is asserted so the rule cannot leak to the pages where overlaying is correct. Two of the new tests were wrong first and reverting the fix left them green: they asserted hand-written markup carrying the classes I expected the components to have, rather than the real SearchIconButton and ShareButton. They use the real components now. Every fix was then planted against: 5 red for the More class, 2 for the search class, 2 for the corner hit area, 1 for the observer, 2 for the modal. 1115 jest / 62 suites, 196 in ui-layout.cy.js, clean npm run build. Confirmed live: share and search both pointer at 54.4px, More white on the bar colour with a transparent face, and the modal's list in flow and unclipped.
2026-08-02 14:45:49 -06:00
// A UA button paints a grey face; the bar's items are transparent.
expect(style.backgroundColor, `More background in ${theme}`)
.to.equal('rgba(0, 0, 0, 0)');
});
});
});
});
it('gives More the same hit area and caret as the placeholder it was measured as', () => {
// The measurement contract. If the drawn button is narrower or shorter than the
// space reserved for it, the row overflows and the bar wraps.
mountNarrow('light');
/*
* Both measurements inside the retried assertion. Reading the bar's height in a
* plain `.then()` first captures whatever it was at that instant -- including the
* transient wrapped state while the corner is still settling -- and then retries the
* comparison against that stale number forever.
*/
cy.get('.wrolpi-navbar').should(($nav) => {
const bar = $nav[0].getBoundingClientRect().height;
const more = [...$nav[0].querySelectorAll('button')]
.find(button => button.textContent.includes('More'));
expect(more, 'the bar has a More button at this width').to.not.be.undefined;
expect(more.querySelector('svg'), 'More has its dropdown caret').to.not.be.null;
expect(more.getBoundingClientRect().height, 'More fills the bar')
.to.be.closeTo(bar, 1);
expect(getComputedStyle(more).cursor, 'More is clickable').to.equal('pointer');
});
});
});
describe('the icon-only triggers in the navbar corner are reachable', () => {
/*
* The search glyph carried Semantic's `item` class, which has had no rules at all since
* Semantic was removed: no pointer cursor, no hover highlight, and a hit area of the
* 18px glyph rather than the height of the bar. The share glyph did compute
* `cursor: pointer` -- it is an `<a href>` -- but its target was the 24px box the icon
* occupies, so the pointer showed only if you found it exactly.
*
* Both are icon-only triggers sitting beside Help and Admin, and should behave as those
* do. Measured against a real link in the same bar rather than against a number.
*/
/*
* The REAL ShareButton, and the real SearchIconButton that DesktopNav renders for
* itself. The first version of this suite used hand-written anchors carrying the
* classes I expected the components to have, so reverting SearchIconButton to Semantic's
* `item` left it green -- it was measuring my markup, not the app's.
*/
const corner = <NavIconWrapper><ShareButton/></NavIconWrapper>;
const triggers = {
share: '.wrolpi-navbar-icon a',
search: '.wrolpi-navbar [aria-label="Search"]',
};
beforeEach(() => cy.mountUI(
<MemoryRouter><div style={{width: 1400}}>
<DesktopNav
navColors={{background: '#5c4fa8', color: '#ffffff', ratio: 6.69}}
homeLink={<a className='wrolpi-navbar-link' href='#'><i>WROLPi</i></a>}
icons={corner}
/>
</div></MemoryRouter>,
));
Object.entries(triggers).forEach(([name, selector]) => {
it(`gives ${name} a pointer and the bar's full height`, () => {
cy.get('.wrolpi-navbar').should(($nav) => {
const bar = $nav[0].getBoundingClientRect().height;
const trigger = $nav[0].querySelector(selector.replace('.wrolpi-navbar ', ''));
expect(trigger, `${name} is in the bar`).to.not.be.null;
expect(getComputedStyle(trigger).cursor, `${name} cursor`).to.equal('pointer');
expect(trigger.getBoundingClientRect().height, `${name} hit area`)
.to.be.closeTo(bar, 1);
});
});
it(`highlights ${name} on hover, as a link does`, () => {
/*
* The highlight is what tells a user the glyph is a control at all, and it is
* the half of the complaint that a cursor check does not cover.
*
* `:hover` cannot be forced -- no event applies it, and getComputedStyle will
* never report it -- so the real stylesheets are searched for a hover rule this
* element matches that paints a background. Resolved against the live CSSOM
* rather than a file, so it fails if the rule is edited, dropped, or written
* with a selector that misses.
*/
cy.get(selector).should(($el) => {
const element = $el[0];
const painted = [...document.styleSheets].flatMap((sheet) => {
try {
return [...sheet.cssRules];
} catch (e) {
return []; // A cross-origin sheet; none of ours are.
}
}).filter(rule => rule.selectorText
&& rule.selectorText.includes(':hover')
&& rule.style.backgroundColor
&& rule.selectorText.split(',').some((selector) => {
const resting = selector.replace(/:hover/g, '').trim();
try {
return resting && element.matches(resting);
} catch (e) {
return false;
}
}));
expect(painted.map(rule => rule.selectorText), `${name} hover rule`)
.to.not.be.empty;
});
});
});
});
describe('the navbar recalculates when the corner changes, not only the window', () => {
/*
* The corner is not a fixed width. The ⌘K hint beside the search glyph renders only
* once `useKeyboardDetected` has seen a keypress, so it appears at an arbitrary later
* moment; the load, memory, temperature and drive warnings appear and vanish as the
* machine's state changes. Each one changes the room the links have, and none of them
* resizes the container.
*
* With only the container observed nothing recalculated, and the bar wrapped -- which is
* why the same viewport wrapped or not depending on whether the user had touched a key,
* and why the width sweep could pass while the real bar was broken. The sweep measures
* a bar whose corner never changes after mount; this one changes it.
*/
const GrowingCorner = () => {
// Stands in for the ⌘K hint and for a warning icon arriving: a corner that is one
// width when the bar is measured and a wider one a moment later.
const [grown, setGrown] = React.useState(false);
React.useEffect(() => {
const timer = setTimeout(() => setGrown(true), 150);
return () => clearTimeout(timer);
}, []);
return <NavIconWrapper>
<span data-testid='corner-filler'
style={{display: 'inline-block', width: grown ? 180 : 20}}/>
</NavIconWrapper>;
};
const mountGrowing = (width) => cy.mountUI(
<MemoryRouter><div style={{width}}>
<DesktopNav
navColors={{background: '#5c4fa8', color: '#ffffff', ratio: 6.69}}
homeLink={<a className='wrolpi-navbar-link' href='#'><i>WROLPi</i></a>}
icons={<GrowingCorner/>}
/>
</div></MemoryRouter>,
);
it('gives up links when the corner grows after the bar was measured', () => {
mountGrowing(900);
// The corner has finished growing...
cy.get('[data-testid="corner-filler"]').should(($filler) => {
expect($filler[0].getBoundingClientRect().width, 'the corner grew').to.equal(180);
});
// ...and the bar is still one row, which it can only be if it recalculated.
cy.get('.wrolpi-navbar').should(($nav) => {
const rows = new Set([...$nav[0].querySelectorAll('.wrolpi-navbar-link')]
.map(link => Math.round(link.getBoundingClientRect().top)));
expect([...rows], 'every link shares one row').to.have.length(1);
});
});
it('takes the links back when the corner shrinks again', () => {
/*
* The inverse, and the reason to recalculate rather than simply reserve the widest
* corner the bar might ever have: a warning icon that clears must give its space
* back, or the bar keeps a permanently shortened set of links until the next resize.
*/
mountGrowing(900);
cy.get('[data-testid="corner-filler"]').should(($filler) => {
expect($filler[0].getBoundingClientRect().width).to.equal(180);
});
cy.get('.wrolpi-navbar').then(($nav) => {
const shrunken = $nav[0].querySelectorAll('.wrolpi-navbar-link').length;
// Shrink the corner back, as a cleared warning would.
cy.get('[data-testid="corner-filler"]').then(($filler) => {
$filler[0].style.width = '20px';
});
cy.get('.wrolpi-navbar').should(($after) => {
expect($after[0].querySelectorAll('.wrolpi-navbar-link').length,
'links come back when the corner clears').to.be.greaterThan(shrunken);
});
});
});
});
describe('the global search modal shows its results', () => {
/*
* The suggestion list overlays the page everywhere else, and should: a list that reflows
* the page underneath while you type is unusable. Inside the search modal that same rule
* failed twice over. An absolutely positioned list contributes no height, so the modal
* panel sized itself to the search box alone -- 114px -- and the panel's own
* `overflow: auto` then clipped the list at that edge. What the user got was a search
* box and the first line of the first group, with the page showing through below.
*
* The real SearchBox, in a panel with the modal's overflow, so the class that carries the
* fix comes from the component rather than from markup written here.
*/
const results = {
channels: {
name: 'Channels',
results: Array.from({length: 8}, (unused, index) => ({
title: `Channel ${index + 1}`, description: 'A channel of videos',
})),
},
domains: {
name: 'Domains',
results: Array.from({length: 8}, (unused, index) => ({
title: `example${index + 1}.com`, description: 'An archived domain',
})),
},
};
// The modal panel: Mantine caps its height and scrolls it, which is what did the clipping.
const panel = (children) => <div className='fake-modal-content'
style={{maxHeight: 504, overflow: 'auto', width: 440}}>
{children}
</div>;
// The list is a combobox: it opens on typing, as it does for a real user.
const openSuggestions = () => cy.get('.wrolpi-searchbox input').type('n');
it('lays the suggestions out inside the panel rather than over the page', () => {
cy.mountUI(panel(<div className='wrolpi-search-modal'>
<SearchBox value='chan' results={results} onResultSelect={() => {}}/>
</div>));
openSuggestions();
cy.get('.wrolpi-searchbox-results').should(($results) => {
expect(getComputedStyle($results[0]).position, 'the list is in flow')
.to.equal('static');
});
});
it('grows the panel to fit them, so nothing is clipped', () => {
cy.mountUI(panel(<div className='wrolpi-search-modal'>
<SearchBox value='chan' results={results} onResultSelect={() => {}}/>
</div>));
openSuggestions();
cy.get('.fake-modal-content').should(($panel) => {
const box = $panel[0].getBoundingClientRect();
const list = $panel[0].querySelector('.wrolpi-searchbox-results')
.getBoundingClientRect();
expect(list.height, 'the list has results to show').to.be.greaterThan(100);
// The whole list is inside the panel, not spilling past its clipped edge.
expect(list.bottom, 'the list ends inside the panel')
.to.be.at.most(box.bottom + 0.5);
// And the panel actually grew for it, rather than the list having been squashed.
expect(box.height, 'the panel grew to hold the list')
.to.be.greaterThan(list.height);
});
});
it('is a real constraint: outside the modal the list still overlays', () => {
/*
* The inverse. If the rule leaked to every searchbox, the file browser and the
* videos page would push their content down on every keystroke -- a worse bug than
* the one being fixed, and one this suite would otherwise not notice.
*/
cy.mountUI(panel(
<SearchBox value='chan' results={results} onResultSelect={() => {}}/>
));
openSuggestions();
cy.get('.wrolpi-searchbox-results').should(($results) => {
expect(getComputedStyle($results[0]).position, 'still an overlay elsewhere')
.to.equal('absolute');
});
});
});
fix: toasts were covering the navigation bar's controls Six keyboard-shortcuts e2e tests started failing on CI: clicking the search glyph was refused because a `mantine-Notification-title` was on top of it. The toast container is fixed at `top: var(--mantine-spacing-md)` -- 16px -- while the bar occupies the first 54px of the page. Every toast has therefore been landing on the bar's right-hand corner: the search glyph, the hamburger, Help and Admin. For as long as the toast is up those controls cannot be clicked, and an error toast is precisely the moment a user reaches for Admin. It surfaced now because the previous commit gave the search glyph a proper hit area. At 18px it sat in the gap beneath the toast; grown to the height of the bar, it moved into the overlap. The toast has been covering that corner all along -- there was nothing there to hit. So this is not a test that needs loosening: CI found a real defect that predates the change that exposed it. Toasts now start below the bar. `--navbar-height` is shared between the bar's min-height and the offset so the two cannot drift, and the rule matches `[data-position^='top']` so a future move to bottom-right does not silently inherit a top offset. Mantine's own positioning uses `:where()`, which has zero specificity, so a single class wins. Tested by `elementFromPoint` rather than by comparing rectangles: that is the question Cypress's actionability check asks and the one a mouse asks. A geometry test would miss a toast that overlaps but sits behind, and a z-index test would miss one that is in front but elsewhere on screen. Three cases -- the search control, every control in the corner, and the offset itself, which is stated separately because the first two would also pass on a toast that merely happened to be narrow enough to miss at one viewport. Removing the offset reddens all three. Confirmed on the running app with a real error toast up: toast top 70px, bar bottom 54px, all six corner controls topmost at their own centres. The e2e spec passes locally, 12 of 12. 1124 jest / 62 suites, 199 in ui-layout.cy.js, clean npm run build.
2026-08-02 15:55:26 -06:00
describe('a toast does not cover the navigation bar', () => {
/*
* Toasts are fixed at `top: var(--mantine-spacing-md)` -- 16px -- while the bar occupies
* the first 54px of the page, so every toast landed over the bar's right-hand corner:
* the search glyph, the hamburger, Help and Admin. For as long as it was up those
* controls could not be clicked, and an error toast is exactly the moment a user reaches
* for Admin.
*
* It surfaced as six e2e failures the day the search glyph was given a proper hit area:
* at 18px it sat in the gap beneath the toast, and growing it to the height of the bar
* moved it into the overlap. The toast had been covering that corner all along; there
* was simply nothing there to hit.
*
* Measured as `elementFromPoint`, which is the same question Cypress's actionability
* check asks and the one a mouse asks -- a geometry-only comparison would miss a toast
* that overlaps but sits behind, and a z-index comparison would miss one that is in
* front but elsewhere on the screen.
*/
const themeIcon = <NavIconWrapper>
<IconButton icon='sun' label='Theme' variant='subtle'/>
</NavIconWrapper>;
const mountBarWithToast = () => {
cy.mountUI(<MemoryRouter>
<Notifications position='top-right'/>
<DesktopNav
navColors={{background: '#5c4fa8', color: '#ffffff', ratio: 6.69}}
homeLink={<a className='wrolpi-navbar-link' href='#'><i>WROLPi</i></a>}
icons={themeIcon}
/>
</MemoryRouter>);
cy.then(() => {
clearToasts();
// The shape CI produces: an error toast, which is the kind that lingers.
toast({type: 'error', title: 'Unexpected error', description: 'Something failed.'});
});
cy.get('.mantine-Notification-root').should('exist');
};
it('leaves the search control clickable while a toast is up', () => {
mountBarWithToast();
cy.get('.wrolpi-navbar [aria-label="Search"]').should(($search) => {
const box = $search[0].getBoundingClientRect();
const topmost = document.elementFromPoint(
box.left + box.width / 2, box.top + box.height / 2);
expect(topmost, 'something is at the search glyph').to.not.be.null;
expect($search[0].contains(topmost) || topmost === $search[0],
`search is the topmost element, not ${topmost && topmost.className}`).to.be.true;
});
});
it('leaves every control in the corner clickable', () => {
// Help and Admin are the ones that matter most: an error toast is when a user goes
// looking for the admin pages, and it was sitting on top of the link.
mountBarWithToast();
cy.get('.wrolpi-navbar-right').should(($corner) => {
const controls = [...$corner[0].querySelectorAll('a, button')];
expect(controls.length, 'there are controls to check').to.be.at.least(3);
const covered = controls.filter((control) => {
const box = control.getBoundingClientRect();
const topmost = document.elementFromPoint(
box.left + box.width / 2, box.top + box.height / 2);
return !(control.contains(topmost) || topmost === control);
}).map(control => control.textContent.trim()
|| control.getAttribute('aria-label') || '(unlabelled)');
expect(covered).to.deep.equal([]);
});
});
it('starts the toast below the bar rather than beside it', () => {
/*
* The mechanism, stated separately from the effect. The two cases above would also
* pass if the toast merely happened to be narrow enough to miss the controls at this
* viewport, which is how the bar came to be covered at some widths and not others.
*/
mountBarWithToast();
cy.get('.mantine-Notifications-root').should(($root) => {
const toastTop = $root[0].getBoundingClientRect().top;
const barBottom = Cypress.$('.wrolpi-navbar')[0].getBoundingClientRect().bottom;
expect(barBottom, 'the bar has height to clear').to.be.greaterThan(40);
expect(toastTop, 'the toast starts below the bar').to.be.at.least(barBottom);
});
});
});
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
describe('a disabled button keeps its own color', () => {
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
/*
* Mantine repaints a disabled button flat grey -- background, text and border all
* replaced with `--mantine-color-disabled`. Semantic kept the color and dropped the
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
* whole control to `opacity: 0.45`, so a disabled Delete was still visibly the red one.
*
* The file browser is where this bites. Its footer is eight buttons, six of which are
* disabled until something is selected, so the toolbar a user meets on arriving at /files
* is an undifferentiated grey row -- Delete, Rename, Move, Ignore and Tag all identical.
* Color is how those are told apart at a glance, and disabling them threw it away.
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
*
* Opacity is the better signal anyway: it says "not available" without also saying "no
* longer the delete button".
*
* Mantine leaves `--button-bg` intact on a disabled button -- it overrides the painted
* `background` rather than the variable -- so the color the call site asked for is still
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
* there to be read back.
*/
const pairs = [
{color: 'red', label: 'Delete'},
{color: 'yellow', label: 'Rename'},
{color: 'teal', label: 'Move'},
{color: 'violet', label: 'Tag'},
{color: 'grey', label: 'Ignore'},
];
const mountPairs = (theme) => cy.mountUI(<div>
{pairs.map(({color, label}) => <span key={color}>
<Button color={color} data-testid={`on-${color}`}>{label}</Button>
<Button color={color} disabled data-testid={`off-${color}`}>{label}</Button>
</span>)}
</div>, {theme});
themeNames.forEach((theme) => {
it(`keeps every color recognisable while disabled in ${theme}`, () => {
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
mountPairs(theme);
cy.get('[data-testid^="off-"]').should(($disabled) => {
expect($disabled, 'a disabled button per color').to.have.length(pairs.length);
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
pairs.forEach(({color}) => {
const on = Cypress.$(`[data-testid="on-${color}"]`)[0];
const off = Cypress.$(`[data-testid="off-${color}"]`)[0];
expect(getComputedStyle(off).backgroundColor, `${theme}/${color} fill`)
.to.equal(getComputedStyle(on).backgroundColor);
});
});
});
it(`still marks them as unavailable in ${theme}`, () => {
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
/*
* Keeping the color must not cost the affordance: a disabled button that looks
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
* identical to an enabled one is a worse bug than a grey one.
*
* Against `--disabled-opacity` rather than a band. A band tolerates an
* accidentally different fade, or an opacity leaking in from somewhere else, and
* still reports success -- and the fade is an authored value, so it can be read.
*/
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
mountPairs(theme);
cy.get('[data-testid="off-red"]').should(($off) => {
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
const authored = parseFloat(getComputedStyle(document.documentElement)
.getPropertyValue('--disabled-opacity'));
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
const disabled = parseFloat(getComputedStyle($off[0]).opacity);
const enabled = parseFloat(
getComputedStyle(Cypress.$('[data-testid="on-red"]')[0]).opacity);
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
expect(authored, 'the token resolved').to.be.within(0.1, 0.9);
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
expect(enabled, `${theme} enabled is solid`).to.equal(1);
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
expect(disabled, `${theme} disabled matches the token`).to.equal(authored);
});
});
});
themeNames.forEach((theme) => {
it(`tells two disabled buttons of different colors apart in ${theme}`, () => {
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
/*
* The claim stated as the user meets it, and the inverse of the bug: five grey
* blobs were five EQUAL greys. Comparing each against its enabled twin above
* would still pass if every pair were grey, so this compares them to each other.
*
* Every theme, not just light. Night and amber are where it is both most
* valuable and most fragile: one hue means the five differ only in brightness,
* so if any theme is going to collapse them back together it is those two.
*/
mountPairs(theme);
cy.get('[data-testid^="off-"]').should(($disabled) => {
const fills = [...$disabled]
.map(button => getComputedStyle(button).backgroundColor);
expect(new Set(fills).size,
`${theme}: five colors, distinct fills: ${fills.join(' ')}`)
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
.to.equal(pairs.length);
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
});
});
});
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
it('does not fade a button that is merely busy', () => {
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
/*
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
* Mantine renders a loading button as `disabled={disabled || loading}`, so every busy
* control in the app is `:disabled` -- an APIButton mid-request, refresh, the
* flasher's connect. Mantine's own grey repaint excludes `[data-loading]` for
* exactly this reason, and the first version of this rule did not, so "working..."
* faded to 0.45 and read as unavailable rather than active.
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
*/
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
cy.mountUI(<div>
<Button color='blue' loading data-testid='busy'>Saving</Button>
<Button color='blue' disabled data-testid='off'>Save</Button>
<IconButton icon='trash' label='Deleting' color='red' variant='filled' loading
data-testid='busy-icon'/>
</div>);
cy.get('[data-testid="busy"]').should(($busy) => {
expect(parseFloat(getComputedStyle($busy[0]).opacity), 'a busy button is solid')
.to.equal(1);
// Paired with the disabled one, so this cannot pass by nothing fading at all.
expect(parseFloat(getComputedStyle(Cypress.$('[data-testid="off"]')[0]).opacity),
'while a disabled one beside it still fades').to.be.lessThan(1);
expect(parseFloat(getComputedStyle(Cypress.$('[data-testid="busy-icon"]')[0]).opacity),
'and the same for an icon button').to.equal(1);
});
});
it('keeps night\'s dashed danger treatment when disabled', () => {
/*
* Night has no second hue, so danger is a dashed border on a transparent fill rather
* than a red one. The general disabled rule repaints from `--button-bg` -- the
* filled red Mantine leaves in the variable -- and at equal specificity it won on
* source order, turning the file browser's disabled Delete into a solid red chip in
* the one theme where that is not what danger means.
*/
cy.mountUI(<div>
<Button role='danger' disabled data-testid='danger-off'>Delete</Button>
</div>, {theme: 'night'});
cy.get('[data-testid="danger-off"]').should(($button) => {
const style = getComputedStyle($button[0]);
expect(style.backgroundColor, 'no fill').to.equal('rgba(0, 0, 0, 0)');
expect(style.borderStyle, 'still dashed').to.equal('dashed');
expect(toRgb(style.borderTopColor), 'in the danger color')
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
.to.equal(toRgb(style.getPropertyValue('--danger') || '#ff5757'));
expect(parseFloat(style.opacity), 'and still faded').to.be.lessThan(1);
});
});
it('is a real constraint: light DOES fill a disabled danger button', () => {
// Without this the case above would also pass on a rule that stripped the fill from
// every disabled danger button in every theme, which would break the other three.
cy.mountUI(<div>
<Button role='danger' disabled data-testid='danger-off'>Delete</Button>
</div>, {theme: 'light'});
cy.get('[data-testid="danger-off"]').should(($button) => {
expect(getComputedStyle($button[0]).backgroundColor, 'light danger is filled')
.to.not.equal('rgba(0, 0, 0, 0)');
});
});
it('restores text and border on variants that carry no fill', () => {
/*
* `default` and `outline` buttons say what they are with their text and border, not
* their background, so a background-only check would pass on them while they were
* still painted Mantine's disabled grey.
*/
cy.mountUI(<div>
<Button variant='outline' color='red' data-testid='outline-on'>Delete</Button>
<Button variant='outline' color='red' disabled data-testid='outline-off'>Delete</Button>
</div>);
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
review: a busy button is not a disabled one, and night's danger is not red Acting on the review of #624. Two bugs, both real, both confirmed in the browser against the live stylesheet before fixing. Mantine renders a loading button as `disabled={disabled || loading}`, so every busy control in the app is `:disabled` -- an APIButton mid-request, the refresh button, the flasher's connect. Mantine's own grey repaint is careful to exclude `[data-loading]` for exactly that reason; the new rule was not, so "working..." faded to 0.45 and read as unavailable rather than active. Measured: a loading button came back at opacity 0.45. Both roots now mirror Mantine's exclusion. Night encodes danger as a dashed border on a transparent fill, because it has no second hue to spend. The general disabled rule repaints from `--button-bg` -- the filled red Mantine leaves in the variable -- and at (0,2,1) it tied with `html[data-theme="night"] .wrolpi-button-danger` and won on source order. Measured: background rgb(255,87,87), border solid transparent. So the file browser's Delete, which is role='danger' and disabled until a selection exists, became a solid red chip in the one theme where that is not what danger means. Restated at (0,3,1) so it no longer depends on where it sits in the file. The specificity note in the comment was also wrong, and wrong in a way that would mislead the next person: Mantine's disabled paint is `:where(:disabled:not([data-loading]), ...)`, and `:where()` contributes nothing, so it scores (0,1,0). The `html` prefix is not needed to beat that -- it is needed to stay level with the app's own `html ...` overrides, and the night danger collision is the demonstration. The fade is now `--disabled-opacity`, read by the tests instead of restated, and asserted for equality rather than against a band -- a band tolerates an accidental different fade or an opacity leaking in from elsewhere and still reports success. Five new cases from the review: loading versus disabled (paired, so it cannot pass by nothing fading at all), night's dashed danger with a light-theme inverse proving the fill is not stripped everywhere, cross-colour distinctness in all four themes rather than only light -- night and amber are where one hue makes collapse most likely -- and an outline pair checking text and border, which are the only things a fill-less variant has to lose. Each planted: dropping the loading exclusion reddens one, dropping the night restatement reddens one. 1128 jest / 63 suites, 216 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:53:18 -06:00
cy.get('[data-testid="outline-off"]').should(($off) => {
const on = getComputedStyle(Cypress.$('[data-testid="outline-on"]')[0]);
const off = getComputedStyle($off[0]);
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
expect(off.color, 'text color survives').to.equal(on.color);
expect(off.borderTopColor, 'border color survives').to.equal(on.borderTopColor);
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
});
});
it('does the same for icon-only buttons', () => {
// The file browser's row actions are IconButtons, and they disable the same way.
cy.mountUI(<div>
{/* Filled, so there is a color to lose. IconButton defaults to Mantine's
ui: a disabled button keeps its own colour The file browser's footer is eight buttons, six of them disabled until something is selected, so the toolbar a user meets on arriving at /files was an undifferentiated grey row: Delete, Rename, Move, Ignore and Tag rendered as five identical pixels. Colour is how those are told apart at a glance. Mantine repaints a disabled button flat grey -- background, text and border all replaced with `--mantine-color-disabled`. Semantic kept the colour and dropped the whole control to `opacity: 0.45`; measured on the QA Pi, a disabled Delete is still red at 0.45, Rename still yellow, Tag still violet. That is the better signal: it says "not available" without also saying "no longer the delete button". Mantine leaves the variables alone and overrides only the painted properties, so the colour the call site asked for is still sitting in `--button-bg` and can simply be reinstated. Applies to every disabled Button and ActionIcon, not only the file browser's -- it is one convention, and having two would be worse than either. A pre-existing test earned its keep here: the IconStack corner disc was pinned to `--mantine-color-disabled` so it would follow a disabled button's grey, and it reddened the moment the button stopped being grey. That override is gone; `--button-bg` is now correct in both states, so the general rule covers them. Ten new cases. Fill equality is checked against each button's own enabled twin in all four themes, and separately across the five colours at once -- comparing each against its twin would still pass if every pair were grey, which is the actual bug. Opacity is asserted from both sides, because keeping the colour must not cost the affordance. Removing the rule reddens eleven. 1128 jest / 63 suites, 209 in ui-layout.cy.js, clean npm run build.
2026-08-02 16:38:41 -06:00
`default` variant, which is a white face, and comparing white with white
would prove nothing. */}
<IconButton icon='trash' label='Delete' color='red' variant='filled'
data-testid='icon-on'/>
<IconButton icon='trash' label='Delete' color='red' variant='filled' disabled
data-testid='icon-off'/>
</div>);
cy.get('[data-testid="icon-off"]').should(($off) => {
const on = Cypress.$('[data-testid="icon-on"]')[0];
expect(getComputedStyle($off[0]).backgroundColor, 'icon button keeps its fill')
.to.equal(getComputedStyle(on).backgroundColor);
expect(parseFloat(getComputedStyle($off[0]).opacity), 'and is faded')
.to.be.lessThan(0.7);
});
});
});
ui: three button-layout defects, each with a different cause Reported together as "button groups", but they turned out to be three unrelated things. The file browser's footer buttons touched while the Channel Edit page's had gaps. Channel Edit lays its buttons out with Mantine's `Group`, which is a flex row with a gap; the footer is hand-rolled and was a plain block, so its inline-block buttons sat flush -- JSX drops whitespace-only lines, so there was not even a space character between them. The footer is now the flex row every other button group already is, wrapping because it carries eight controls. The Settings config table's Import and Save buttons had off-centre icons while Restore in the same row looked right. Restore is an IconButton -- an ActionIcon, which centres a lone glyph by construction. Import and Save are icon-only Buttons, and an icon on a Button goes into Mantine's `leftSection`, which carries a `margin-inline-end` to hold it off the label. With no label that margin is pure offset: measured at 8px left of centre. An icon with no label is now rendered as the button's content instead, so it centres. `Children.toArray` decides that, because it drops nulls and the file browser passes `{label('Delete')}` -- null whenever the bar is too narrow for words, which is exactly where the offset showed most. The search field's clear button sat inside the field rather than attached to it: the control is a bordered box with `padding: 0 8px`, leaving the button 9px short of the edge and 2px short of the height. Semantic welded it to the field -- measured on the QA Pi at zero gap and full height -- so it now stretches and negative margins cancel the padding and the flex gap. Negative margins rather than dropping the control's padding, because that padding is what holds the search icon and the text off the border; only this one child should escape it. The `html` prefix on that rule is load-bearing: Mantine sets ActionIcon's height from `--ai-size` on its own single class, and at equal specificity the winner is whichever stylesheet loaded last. Fourteen new cases. One correction worth recording: the height assertion first compared against the control's border box and failed on correct behaviour -- the button fills the CONTENT box, and the 1px above and below it is the field's own border, which it should sit inside rather than paint over. Each fix planted separately; the icon change reddens three, the footer one, the clear button one. Every case is paired with an inverse -- a labelled button must keep its icon on the left, and the field must still be padded around its other children. 1128 jest / 63 suites, 226 in ui-layout.cy.js, clean npm run build. Confirmed live: footer gaps 8px on one row, config glyphs at 0.0px from centre, clear button 1px from the field edge at the field's full inner height.
2026-08-02 17:13:28 -06:00
describe('a button with an icon and no label centres the icon', () => {
/*
* Mantine's `leftSection` carries a `margin-inline-end` to hold the icon off the label.
* With no label that margin is pure offset, and the glyph sits about 8px left of the
* button's centre.
*
* The Settings config table is where it showed: Import and Save are icon-only Buttons and
* looked visibly off, while Restore in the same row looked right -- Restore is an
* IconButton, which centres a lone glyph by construction. Measured on the running app at
* -8px before the fix.
*/
it('puts the glyph in the middle when there is nothing else in the button', () => {
cy.mountUI(<Button icon='upload' aria-label='Import' data-testid='icon-only'/>);
cy.get('[data-testid="icon-only"]').should(($button) => {
const box = $button[0].getBoundingClientRect();
const glyph = $button[0].querySelector('svg').getBoundingClientRect();
const offset = (glyph.left + glyph.width / 2) - (box.left + box.width / 2);
expect(box.width, 'the button has width to be off-centre in')
.to.be.greaterThan(glyph.width + 8);
expect(offset, 'glyph centre vs button centre').to.be.closeTo(0, 1);
});
});
it('treats a null label as no label, which is how the file browser renders', () => {
/*
* The footer passes `{label('Delete')}`, and that is null whenever the bar is too
* narrow for words -- so those buttons are icon-only at exactly the widths where the
* offset is most visible. `React.Children.toArray` drops nulls; a plain truthiness
* check on `children` would not.
*/
cy.mountUI(<Button icon='trash' aria-label='Delete' data-testid='null-label'>
{null}
</Button>);
cy.get('[data-testid="null-label"]').should(($button) => {
const box = $button[0].getBoundingClientRect();
const glyph = $button[0].querySelector('svg').getBoundingClientRect();
expect((glyph.left + glyph.width / 2) - (box.left + box.width / 2),
'glyph centre vs button centre').to.be.closeTo(0, 1);
});
});
it('is a real constraint: a labelled button keeps its icon on the left', () => {
// The inverse. Centring the glyph must not apply when there IS a label, or every
// labelled button in the app loses its leading icon's position.
cy.mountUI(<Button icon='trash' data-testid='labelled'>Delete</Button>);
cy.get('[data-testid="labelled"]').should(($button) => {
const box = $button[0].getBoundingClientRect();
const glyph = $button[0].querySelector('svg').getBoundingClientRect();
expect((glyph.left + glyph.width / 2) - (box.left + box.width / 2),
'the icon leads the label').to.be.lessThan(-4);
expect($button[0].textContent, 'and the label is still there').to.contain('Delete');
});
});
review: one inset, and two tests that could not fail Acting on the review of #625. No bugs; four suggestions and three nits, of which two were already handled and one needed no code. The weld used three separate 8px literals -- the control's padding, its flex gap, and the clear button's negative margins -- which had to stay in lockstep or the button would drift past the border or back inside it. They are one `--searchbox-inset` now. Cancelling the gap on the clear button's LEFT was a real side effect: when a field is both `loading` and `clearable`, which SearchResultsInput allows, the DOM order is input, spinner, clear, and the spinner ended up welded to the divider. Only the right-hand padding is cancelled now; the 8px before the button stays, and a case covers the pair. `min-height` was still coming from `--ai-size`, so the rule only half-owned the height it claimed to set -- true today by 0.15px, the field being 36.15 against a 36 minimum. Unset now. Two nits needed no code and are recorded as findings rather than changes. The clear button's corners are already square: the theme zeroes every `--mantine-radius-*`, so there are no wedges to show against the field, and a case now depends on that explicitly. And a label-less button with BOTH `icon` and `iconAfter` would stay mis-centred, but no call site writes one, so the limit is documented instead of designed around. Blank children now count as no label. `toArray` drops null and booleans but keeps `''` and whitespace, which would have left the glyph off-centre; no call site does it today and the predicate should not depend on that. Two corrections to my own work, both caught by planting: The fragment case. I wrote that `toArray` flattens fragments away to nothing and tested `<></>` as unlabelled. It does not -- it returns the fragment as one child, so `<></>` is indistinguishable from real content. The test now records what actually happens, with `<>Delete</>` as the shape that occurs in practice. The min-height assertion compared `--ai-size` -- which reads back as `calc(2.25rem * var(--mantine-scale))` -- against a computed `36px`. Two strings that can never match, so it passed with the rule removed. It compares resolved lengths now, paired with an ordinary IconButton that DOES carry the minimum, so its absence is attributable to this rule rather than to a Mantine default. An earlier attempt fabricated a shorter field by overriding the input's font size; that was deleted, because a test that invents a layout the app never renders is not evidence about this app. 1128 jest / 63 suites, 231 in ui-layout.cy.js, clean npm run build. Confirmed live: inset 8px, clear button 1px from the field edge, 8px from the input, at the field's full inner height with no minimum of its own.
2026-08-02 17:28:46 -06:00
it('treats blank and empty children as no label', () => {
/*
* `Children.toArray` drops null, undefined and booleans but KEEPS an empty or
* whitespace-only string, so a length check alone would call these labelled and leave
* the glyph off-centre.
*/
cy.mountUI(<div>
<Button icon='upload' aria-label='Empty' data-testid='empty'>{''}</Button>
<Button icon='upload' aria-label='Blank' data-testid='blank'>{' '}</Button>
</div>);
cy.get('[data-testid="blank"]').should(() => {
['empty', 'blank'].forEach((id) => {
const button = Cypress.$(`[data-testid="${id}"]`)[0];
const box = button.getBoundingClientRect();
const glyph = button.querySelector('svg').getBoundingClientRect();
expect((glyph.left + glyph.width / 2) - (box.left + box.width / 2),
`${id} glyph centre`).to.be.closeTo(0, 1);
});
});
});
it('treats any element child as a label, including an empty fragment', () => {
/*
* Recording what actually happens rather than what would be tidy. `toArray` does not
* look inside a fragment -- it returns the fragment itself as one child -- so `<></>`
* is indistinguishable from real content and the icon stays in `leftSection`.
*
* Detecting it would mean recursing into fragment props, and no call site writes an
* empty fragment as a button's children. `<>Delete</>` is the shape that does occur,
* and it lands on the same path for the right reason.
*/
cy.mountUI(<div>
<Button icon='trash' data-testid='fragment'><></></Button>
<Button icon='trash' data-testid='wrapped'><>Delete</></Button>
</div>);
cy.get('[data-testid="wrapped"]').should(() => {
['fragment', 'wrapped'].forEach((id) => {
const button = Cypress.$(`[data-testid="${id}"]`)[0];
const box = button.getBoundingClientRect();
const glyph = button.querySelector('svg').getBoundingClientRect();
expect((glyph.left + glyph.width / 2) - (box.left + box.width / 2),
`${id} keeps the icon leading`).to.be.lessThan(-3);
});
});
});
ui: three button-layout defects, each with a different cause Reported together as "button groups", but they turned out to be three unrelated things. The file browser's footer buttons touched while the Channel Edit page's had gaps. Channel Edit lays its buttons out with Mantine's `Group`, which is a flex row with a gap; the footer is hand-rolled and was a plain block, so its inline-block buttons sat flush -- JSX drops whitespace-only lines, so there was not even a space character between them. The footer is now the flex row every other button group already is, wrapping because it carries eight controls. The Settings config table's Import and Save buttons had off-centre icons while Restore in the same row looked right. Restore is an IconButton -- an ActionIcon, which centres a lone glyph by construction. Import and Save are icon-only Buttons, and an icon on a Button goes into Mantine's `leftSection`, which carries a `margin-inline-end` to hold it off the label. With no label that margin is pure offset: measured at 8px left of centre. An icon with no label is now rendered as the button's content instead, so it centres. `Children.toArray` decides that, because it drops nulls and the file browser passes `{label('Delete')}` -- null whenever the bar is too narrow for words, which is exactly where the offset showed most. The search field's clear button sat inside the field rather than attached to it: the control is a bordered box with `padding: 0 8px`, leaving the button 9px short of the edge and 2px short of the height. Semantic welded it to the field -- measured on the QA Pi at zero gap and full height -- so it now stretches and negative margins cancel the padding and the flex gap. Negative margins rather than dropping the control's padding, because that padding is what holds the search icon and the text off the border; only this one child should escape it. The `html` prefix on that rule is load-bearing: Mantine sets ActionIcon's height from `--ai-size` on its own single class, and at equal specificity the winner is whichever stylesheet loaded last. Fourteen new cases. One correction worth recording: the height assertion first compared against the control's border box and failed on correct behaviour -- the button fills the CONTENT box, and the 1px above and below it is the field's own border, which it should sit inside rather than paint over. Each fix planted separately; the icon change reddens three, the footer one, the clear button one. Every case is paired with an inverse -- a labelled button must keep its icon on the left, and the field must still be padded around its other children. 1128 jest / 63 suites, 226 in ui-layout.cy.js, clean npm run build. Confirmed live: footer gaps 8px on one row, config glyphs at 0.0px from centre, clear button 1px from the field edge at the field's full inner height.
2026-08-02 17:13:28 -06:00
it('centres a trailing-only icon too', () => {
// `rightSection` has the mirror-image margin.
cy.mountUI(<Button iconAfter='upload' aria-label='Send' data-testid='after-only'/>);
cy.get('[data-testid="after-only"]').should(($button) => {
const box = $button[0].getBoundingClientRect();
const glyph = $button[0].querySelector('svg').getBoundingClientRect();
expect((glyph.left + glyph.width / 2) - (box.left + box.width / 2))
.to.be.closeTo(0, 1);
});
});
});
describe('the file browser footer is a row of buttons, not a slab', () => {
/*
* The footer was a plain block, so its buttons -- inline-block elements with no whitespace
* between them, since JSX drops whitespace-only lines -- sat flush against each other in
* one unbroken bar. Every other group of buttons in the app is a Mantine `Group`, which
* is a flex row with a gap; this one is hand-rolled and never got one.
*
* The class carries the layout, so the class is what is mounted. FileBrowser itself
* needs the file API, drag selection and a router, none of which decides the spacing.
*/
it('leaves a gap between adjacent buttons', () => {
cy.mountUI(<div className='sticky-footer'>
<Button color='red' data-testid='a'>Delete</Button>
<Button color='yellow' data-testid='b'>Rename</Button>
<Button color='teal' data-testid='c'>Move</Button>
</div>);
cy.get('.sticky-footer').should(($footer) => {
const boxes = ['a', 'b', 'c']
.map(id => $footer[0].querySelector(`[data-testid="${id}"]`).getBoundingClientRect());
expect(boxes[1].left - boxes[0].right, 'gap between the first two')
.to.be.greaterThan(2);
expect(boxes[2].left - boxes[1].right, 'gap between the next two')
.to.be.greaterThan(2);
});
});
it('keeps them on one line and vertically aligned', () => {
// A flex row is only right if it behaves like one: the buttons share a baseline and
// do not stack while there is room for them.
cy.mountUI(<div className='sticky-footer'>
<Button data-testid='a'>Delete</Button>
<Button data-testid='b'>Rename</Button>
</div>);
cy.get('.sticky-footer').should(($footer) => {
const a = $footer[0].querySelector('[data-testid="a"]').getBoundingClientRect();
const b = $footer[0].querySelector('[data-testid="b"]').getBoundingClientRect();
expect(a.top, 'same row').to.be.closeTo(b.top, 1);
});
});
});
describe('the search field\'s clear button is attached to it', () => {
/*
* The control is a bordered box with `padding: 0 8px`, so the clear button sat 9px short
* of the right edge and 2px short of the full height -- a glyph dropped inside the input
* rather than a control of its own.
*
* Semantic rendered it as an action button welded to the field. Measured on the QA Pi,
* which still runs Semantic: zero gap from the input, zero to the outer edge, and the
* full height of the field.
*/
const mountField = () => cy.mountUI(<div style={{width: 420}}>
<SearchBox value='wind turbine' clearable onChange={() => {}}/>
</div>);
it('meets the right-hand edge of the field', () => {
mountField();
cy.get('.wrolpi-searchbox-clear').should(($clear) => {
const control = Cypress.$('.wrolpi-searchbox-control')[0].getBoundingClientRect();
const clear = $clear[0].getBoundingClientRect();
expect(control.right - clear.right, 'gap to the field edge').to.be.closeTo(0, 1.5);
});
});
it('fills the height of the field', () => {
/*
* Half the reason it read as "inside": a 36px control floating in a 38px box.
*
* Measured against the control's CONTENT box, not its border box. The field's own
* 1px border is the only thing left above and below the button, and the button
* should sit inside it rather than paint over it -- `clientHeight` is that box, and
* comparing against `getBoundingClientRect().height` would be demanding the button
* cover the field's border, which is a different and wrong design.
*/
mountField();
cy.get('.wrolpi-searchbox-clear').should(($clear) => {
const control = Cypress.$('.wrolpi-searchbox-control')[0];
const border = parseFloat(getComputedStyle(control).borderTopWidth);
expect(border, 'the field has a border to sit inside').to.be.greaterThan(0);
expect($clear[0].getBoundingClientRect().height, 'clear button height')
.to.be.closeTo(control.clientHeight, 1);
});
});
it('is divided from the text rather than merged into it', () => {
// Attached is not the same as indistinguishable: without a rule between them the
// glyph reads as part of the input again, just further right.
mountField();
cy.get('.wrolpi-searchbox-clear').should(($clear) => {
const style = getComputedStyle($clear[0]);
expect(parseFloat(style.borderLeftWidth), 'a divider on its left')
.to.be.greaterThan(0);
expect(style.borderLeftStyle).to.not.equal('none');
});
});
review: one inset, and two tests that could not fail Acting on the review of #625. No bugs; four suggestions and three nits, of which two were already handled and one needed no code. The weld used three separate 8px literals -- the control's padding, its flex gap, and the clear button's negative margins -- which had to stay in lockstep or the button would drift past the border or back inside it. They are one `--searchbox-inset` now. Cancelling the gap on the clear button's LEFT was a real side effect: when a field is both `loading` and `clearable`, which SearchResultsInput allows, the DOM order is input, spinner, clear, and the spinner ended up welded to the divider. Only the right-hand padding is cancelled now; the 8px before the button stays, and a case covers the pair. `min-height` was still coming from `--ai-size`, so the rule only half-owned the height it claimed to set -- true today by 0.15px, the field being 36.15 against a 36 minimum. Unset now. Two nits needed no code and are recorded as findings rather than changes. The clear button's corners are already square: the theme zeroes every `--mantine-radius-*`, so there are no wedges to show against the field, and a case now depends on that explicitly. And a label-less button with BOTH `icon` and `iconAfter` would stay mis-centred, but no call site writes one, so the limit is documented instead of designed around. Blank children now count as no label. `toArray` drops null and booleans but keeps `''` and whitespace, which would have left the glyph off-centre; no call site does it today and the predicate should not depend on that. Two corrections to my own work, both caught by planting: The fragment case. I wrote that `toArray` flattens fragments away to nothing and tested `<></>` as unlabelled. It does not -- it returns the fragment as one child, so `<></>` is indistinguishable from real content. The test now records what actually happens, with `<>Delete</>` as the shape that occurs in practice. The min-height assertion compared `--ai-size` -- which reads back as `calc(2.25rem * var(--mantine-scale))` -- against a computed `36px`. Two strings that can never match, so it passed with the rule removed. It compares resolved lengths now, paired with an ordinary IconButton that DOES carry the minimum, so its absence is attributable to this rule rather than to a Mantine default. An earlier attempt fabricated a shorter field by overriding the input's font size; that was deleted, because a test that invents a layout the app never renders is not evidence about this app. 1128 jest / 63 suites, 231 in ui-layout.cy.js, clean npm run build. Confirmed live: inset 8px, clear button 1px from the field edge, 8px from the input, at the field's full inner height with no minimum of its own.
2026-08-02 17:28:46 -06:00
it('keeps the loading spinner off the clear button', () => {
/*
* `SearchResultsInput` can pass `loading` and `clearable` together, and the DOM order
* is input, spinner, clear. An earlier version of the weld cancelled the flex gap on
* the clear button's LEFT as well as the padding on its right, which welded the
* spinner to the divider -- the spinner is not part of this control.
*/
cy.mountUI(<div style={{width: 420}}>
<SearchBox value='wind turbine' clearable loading onChange={() => {}}/>
</div>);
cy.get('.wrolpi-searchbox-loading').should(($spinner) => {
const clear = Cypress.$('.wrolpi-searchbox-clear')[0].getBoundingClientRect();
expect(clear.left - $spinner[0].getBoundingClientRect().right,
'gap between the spinner and the divider').to.be.greaterThan(2);
});
});
it('owns the height in both directions, not just downwards', () => {
/*
* `align-self: stretch` cannot shrink a box below its own `min-height`, and Mantine
* sets that from `--ai-size` alongside `height`. Overriding `height` alone owns the
* sizing in one direction only -- it happens to look right because the field is
* 36.15px against a 36px minimum, a margin of 0.15px.
*
* The property rather than the geometry, deliberately. Making the field genuinely
* shorter than 36px means overriding the input's own font size and padding, which no
* part of the app does, and a test that fabricates a layout to prove a rule is not
* evidence about this app. This asserts what the rule is for: the minimum is no
* longer `--ai-size`. Removing `min-height: unset` fails it.
*/
cy.mountUI(<div style={{width: 420}}>
<SearchBox value='wind turbine' clearable onChange={() => {}}/>
{/* An ActionIcon outside the field, to show where the minimum comes from. */}
<IconButton icon='trash' label='Delete' data-testid='plain'/>
</div>);
cy.get('.wrolpi-searchbox-clear').should(($clear) => {
/*
* Resolved lengths, not the raw variable: `--ai-size` reads back as
* `calc(2.25rem * var(--mantine-scale))` while `min-height` computes to `36px`, so
* comparing the two strings can never match and asserts nothing. The first
* version of this did exactly that and stayed green with the rule removed.
*/
const minimum = (element) => parseFloat(getComputedStyle(element).minHeight) || 0;
// The inverse and the premise together: an ordinary IconButton DOES carry the
// minimum, so its absence here is this rule's doing and not Mantine's default.
expect(minimum(Cypress.$('[data-testid="plain"]')[0]),
'an ordinary icon button has a minimum height').to.be.greaterThan(0);
expect(minimum($clear[0]), 'the welded one does not').to.equal(0);
});
});
it('has square corners, so nothing shows through at the field edge', () => {
// A rounded ActionIcon stretched flush to a square field leaves panel-colored wedges
review: one inset, and two tests that could not fail Acting on the review of #625. No bugs; four suggestions and three nits, of which two were already handled and one needed no code. The weld used three separate 8px literals -- the control's padding, its flex gap, and the clear button's negative margins -- which had to stay in lockstep or the button would drift past the border or back inside it. They are one `--searchbox-inset` now. Cancelling the gap on the clear button's LEFT was a real side effect: when a field is both `loading` and `clearable`, which SearchResultsInput allows, the DOM order is input, spinner, clear, and the spinner ended up welded to the divider. Only the right-hand padding is cancelled now; the 8px before the button stays, and a case covers the pair. `min-height` was still coming from `--ai-size`, so the rule only half-owned the height it claimed to set -- true today by 0.15px, the field being 36.15 against a 36 minimum. Unset now. Two nits needed no code and are recorded as findings rather than changes. The clear button's corners are already square: the theme zeroes every `--mantine-radius-*`, so there are no wedges to show against the field, and a case now depends on that explicitly. And a label-less button with BOTH `icon` and `iconAfter` would stay mis-centred, but no call site writes one, so the limit is documented instead of designed around. Blank children now count as no label. `toArray` drops null and booleans but keeps `''` and whitespace, which would have left the glyph off-centre; no call site does it today and the predicate should not depend on that. Two corrections to my own work, both caught by planting: The fragment case. I wrote that `toArray` flattens fragments away to nothing and tested `<></>` as unlabelled. It does not -- it returns the fragment as one child, so `<></>` is indistinguishable from real content. The test now records what actually happens, with `<>Delete</>` as the shape that occurs in practice. The min-height assertion compared `--ai-size` -- which reads back as `calc(2.25rem * var(--mantine-scale))` -- against a computed `36px`. Two strings that can never match, so it passed with the rule removed. It compares resolved lengths now, paired with an ordinary IconButton that DOES carry the minimum, so its absence is attributable to this rule rather than to a Mantine default. An earlier attempt fabricated a shorter field by overriding the input's font size; that was deleted, because a test that invents a layout the app never renders is not evidence about this app. 1128 jest / 63 suites, 231 in ui-layout.cy.js, clean npm run build. Confirmed live: inset 8px, clear button 1px from the field edge, 8px from the input, at the field's full inner height with no minimum of its own.
2026-08-02 17:28:46 -06:00
// at the corners. Nothing sets this here: the theme zeroes every radius, and this
// records that the weld depends on it.
mountField();
cy.get('.wrolpi-searchbox-clear').should(($clear) => {
expect(getComputedStyle($clear[0]).borderRadius, 'no rounded corners')
.to.equal('0px');
});
});
ui: three button-layout defects, each with a different cause Reported together as "button groups", but they turned out to be three unrelated things. The file browser's footer buttons touched while the Channel Edit page's had gaps. Channel Edit lays its buttons out with Mantine's `Group`, which is a flex row with a gap; the footer is hand-rolled and was a plain block, so its inline-block buttons sat flush -- JSX drops whitespace-only lines, so there was not even a space character between them. The footer is now the flex row every other button group already is, wrapping because it carries eight controls. The Settings config table's Import and Save buttons had off-centre icons while Restore in the same row looked right. Restore is an IconButton -- an ActionIcon, which centres a lone glyph by construction. Import and Save are icon-only Buttons, and an icon on a Button goes into Mantine's `leftSection`, which carries a `margin-inline-end` to hold it off the label. With no label that margin is pure offset: measured at 8px left of centre. An icon with no label is now rendered as the button's content instead, so it centres. `Children.toArray` decides that, because it drops nulls and the file browser passes `{label('Delete')}` -- null whenever the bar is too narrow for words, which is exactly where the offset showed most. The search field's clear button sat inside the field rather than attached to it: the control is a bordered box with `padding: 0 8px`, leaving the button 9px short of the edge and 2px short of the height. Semantic welded it to the field -- measured on the QA Pi at zero gap and full height -- so it now stretches and negative margins cancel the padding and the flex gap. Negative margins rather than dropping the control's padding, because that padding is what holds the search icon and the text off the border; only this one child should escape it. The `html` prefix on that rule is load-bearing: Mantine sets ActionIcon's height from `--ai-size` on its own single class, and at equal specificity the winner is whichever stylesheet loaded last. Fourteen new cases. One correction worth recording: the height assertion first compared against the control's border box and failed on correct behaviour -- the button fills the CONTENT box, and the 1px above and below it is the field's own border, which it should sit inside rather than paint over. Each fix planted separately; the icon change reddens three, the footer one, the clear button one. Every case is paired with an inverse -- a labelled button must keep its icon on the left, and the field must still be padded around its other children. 1128 jest / 63 suites, 226 in ui-layout.cy.js, clean npm run build. Confirmed live: footer gaps 8px on one row, config glyphs at 0.0px from centre, clear button 1px from the field edge at the field's full inner height.
2026-08-02 17:13:28 -06:00
it('is a real constraint: the field itself is still padded', () => {
/*
* The negative margins are aimed at one child. If the control's padding had simply
* been removed instead, the search icon and the text would sit against the border
* too -- so this checks the thing that must NOT have moved.
*/
mountField();
cy.get('.wrolpi-searchbox-icon').should(($icon) => {
const control = Cypress.$('.wrolpi-searchbox-control')[0].getBoundingClientRect();
expect($icon[0].getBoundingClientRect().left - control.left, 'icon is inset')
.to.be.greaterThan(4);
});
});
});
ui: the map pin buttons were three sizes for three reasons Reported as "all different sizes", and the pin row's three actions measured 46x30, 30x30 and 54x36. Three causes. APIButton dropped `size`. `useAPIButton` declared `size = 'medium'` as a parameter and then never put it into the props it hands to Button, so every APIButton in the app rendered at Mantine's default regardless of what its call site asked for -- seventeen call sites pass one, from `xs` on the map pins to `big` and `huge` on Settings. The delete pin was 36px tall beside two 30px siblings because of it. Passing the parameter default through would have fixed the bug by breaking everything else -- every APIButton naming no size would have grown from `sm` to `md` -- so the default is undefined now and Button's own default stands. Eight buttons on three other pages do grow as a result, which is their call sites finally being honoured: VideoPlayer's `large`, one of Channels' `big`, and Settings' two `big` and two `huge`. An icon-only Button was not square. A Button is as wide as its content plus its horizontal padding; an ActionIcon is square by construction; and the pin row mixes the two, because AddToPlaylistButton renders an IconButton when it has no label. Their heights already agreed -- ActionIcon's scale was remapped onto Button's some commits ago -- and this is the other axis of the same alignment, keyed off Mantine's own `--button-height` so the two stay in step through every size. They were also misaligned and touching, which is a third thing: bare inline-block siblings align on text BASELINES, and a Button's baseline is not an ActionIcon's, so the middle control sat 4.3px above the other two. A Group, as every other row of buttons in the app uses. Written test-first at Roland's request. Seven cypress cases went red on the sizes -- widths 46 against 30, 54 against 36, 62 against 42, 70 against 50, and "xs is shorter than lg: expected 36 to be below 32" for the dropped size -- with both inverses green throughout: a labelled button stays as wide as its label, and an APIButton naming no size keeps the height it had. The alignment claim is measured in ui-layout.cy.js, including the premise that bare siblings really are misaligned, since three controls of identical height not lining up is not believable otherwise. The call sites are held by a source guard, because MapPins fetches from the API and builds its rows through SortableTable. That guard earned itself twice over. Written for the pin rows, it found the map-files subscribe cell putting a preview button beside a subscribe button with the same defect. Then a first attempt at a general "any cell with two controls" rule had to be abandoned: a cell whose buttons are the arms of a ternary renders only one and needs no Group, and excluding ternaries to allow for that also excluded the subscribe cell, whose `role={isSubscribed ? ... : ...}` says nothing about how many controls it holds. Named cells with a stated scope beat a general rule that quietly stops covering things. Two slips of mine in that file, both caught by running it: `expect(value, message)` is chai and throws in jest, and `onSave(pin.id, ...)` was not unique to the cell it named -- the edit row's TextInput calls it from onKeyDown in a different cell, so the check passed against the wrong one. 1132 jest / 64 suites, 243 in ui-layout.cy.js, clean npm run build. Confirmed live: three 30x30 controls, vertical spread 0, 10px gaps.
2026-08-02 17:44:25 -06:00
describe('icon-only action buttons in a row are one size', () => {
/*
* The map's pin table gives every row three actions: edit, add-to-playlist and delete,
* all asking for `size='xs'`. They rendered 46x30, 30x30 and 54x36 -- three different
* sizes, for three different reasons.
*
* Two of those are structural. `AddToPlaylistButton` renders an IconButton when it has no
* label, and an ActionIcon is square by construction, while a Button is as wide as its
* content plus its horizontal padding. Their heights already agree, because ActionIcon's
* size scale was remapped onto Button's; width was never aligned.
*
* The third is a plain bug: `useAPIButton` never put `size` into the props it hands to
* Button, so every APIButton in the app rendered at Mantine's default regardless of what
* its call site asked for. Seventeen call sites pass a size, from `xs` here to `huge` on
* Settings.
*/
const sizes = ['xs', 'sm', 'md', 'lg'];
sizes.forEach((size) => {
it(`gives an icon-only Button and an IconButton the same box at ${size}`, () => {
cy.mountUI(<div>
<Button size={size} icon='edit' aria-label='Edit' data-testid='plain'/>
<IconButton size={size} icon='list' label='Add' data-testid='action'/>
</div>);
cy.get('[data-testid="action"]').should(($action) => {
const button = Cypress.$('[data-testid="plain"]')[0].getBoundingClientRect();
const icon = $action[0].getBoundingClientRect();
expect(button.height, `${size} heights`).to.be.closeTo(icon.height, 1);
expect(button.width, `${size} widths`).to.be.closeTo(icon.width, 1);
});
});
});
it('makes an icon-only button square, not merely equal to its neighbour', () => {
// Stated separately: two buttons could agree with each other and both be wrong. A
// lone glyph in a control belongs in a square one.
cy.mountUI(<Button size='xs' icon='edit' aria-label='Edit' data-testid='plain'/>);
cy.get('[data-testid="plain"]').should(($button) => {
const box = $button[0].getBoundingClientRect();
expect(box.width, 'square').to.be.closeTo(box.height, 1);
});
});
it('is a real constraint: a labelled button is still as wide as its label', () => {
// The inverse. Squaring must apply only to the icon-only case, or every labelled
// button in the app collapses to a square and clips its text.
cy.mountUI(<Button size='xs' icon='edit' data-testid='labelled'>Edit this pin</Button>);
cy.get('[data-testid="labelled"]').should(($button) => {
const box = $button[0].getBoundingClientRect();
expect(box.width, 'wider than it is tall').to.be.greaterThan(box.height * 2);
});
});
});
describe('APIButton honours the size its call site asks for', () => {
/*
* `useAPIButton` assembled the props it hands to Button and left `size` out, so it was
* dropped at every call site -- seventeen of them, from the map pins' `xs` to Settings'
* `huge`. The map's delete pin came out 36px tall beside two 30px siblings.
*/
it('renders a small APIButton smaller than a large one', () => {
cy.mountUI(<div>
<APIButton size='xs' icon='trash' onClick={() => {}} data-testid='small'/>
<APIButton size='lg' icon='trash' onClick={() => {}} data-testid='large'/>
</div>);
cy.get('[data-testid="large"]').should(($large) => {
const small = Cypress.$('[data-testid="small"]')[0].getBoundingClientRect();
expect(small.height, 'xs is shorter than lg')
.to.be.lessThan($large[0].getBoundingClientRect().height - 4);
});
});
it('matches a plain Button given the same size', () => {
// The claim that matters at the call site: an APIButton and a Button asking for the
// same size are the same control.
cy.mountUI(<div>
<APIButton size='xs' icon='trash' onClick={() => {}} data-testid='api'/>
<Button size='xs' icon='trash' aria-label='Delete' data-testid='plain'/>
</div>);
cy.get('[data-testid="api"]').should(($api) => {
const plain = Cypress.$('[data-testid="plain"]')[0].getBoundingClientRect();
const api = $api[0].getBoundingClientRect();
expect(api.height, 'heights').to.be.closeTo(plain.height, 1);
expect(api.width, 'widths').to.be.closeTo(plain.width, 1);
});
});
review: name the icon-only controls, and make two guards mean what they say Acting on the review of #626. No bugs; one suggestion and three nits. The map's icon-only controls had no accessible name. IconButton requires a label by construction and AddToPlaylistButton supplies one, but the plain Button and APIButton used for edit, delete and the catalog preview reached assistive tech as unnamed buttons -- and my own Cypress fixtures carefully passed `aria-label` on the same pattern while production did not, which is its own kind of tell. All four are named now, and named with the row's subject rather than the verb alone: "Delete Water tank", not "Delete", because a table of pins otherwise offers a screen reader a column of identical buttons. A source guard holds that: it scans for controls that carry an icon and no label text, and reports any without an `aria-label`. Paired with a premise that it found some, since a scanner matching nothing reads exactly like a clean file. The Group guard asserted only that `<Group` appeared somewhere in the cell, which would pass on an empty Group left beside the bare siblings it was meant to wrap. It now checks that every control in the cell is inside the Group -- and the first version of THAT was wrong too: it sliced from `<Group` to the end of the cell rather than to `</Group>`, so controls after the closing tag still counted as inside, and the empty-Group plant stayed green. Slicing between the tags makes it fail. Coverage the review asked for: the Semantic size names the call sites actually use (`small`, `big`, `huge`) rather than only the Mantine ones, since the translation step was untested on the exact spellings that were broken; icon-only buttons stay square while loading, when the glyph is replaced by a spinner sized from the button's height; and `iconAfter`-only squares as well as `icon`-only. On the size passthrough, which was flagged as the highest-risk change outside the map: the buttons that grow are Settings' Shutdown and Reboot (`huge`, to 60px), Settings' Upgrade and Save and Channels' Save (`big`, to 50px), and VideoPlayer's Refresh (`large`, to 50px). All six read as deliberate emphasis -- the two biggest are the two destructive ones -- so they are left honoured rather than re-broken at the call site. `size='small'` resolves to `sm`, which is what the accidental default already was, so the detail pages do not move. 1134 jest / 64 suites, 246 in ui-layout.cy.js, clean npm run build.
2026-08-02 17:57:27 -06:00
it('honours the Semantic size names the call sites actually use', () => {
/*
* The seventeen call sites that were being ignored do not say `xs` and `lg` -- they say
* `small`, `big`, `large` and `huge`, which `resolveSize` translates. Testing only the
* Mantine names would leave the translation step untested on the exact spellings that
* were broken. `small` maps to `sm`, which is what the accidental default already was,
* which is why most detail pages do not move.
*/
cy.mountUI(<div>
<APIButton size='small' icon='trash' onClick={() => {}} data-testid='small'/>
<APIButton size='big' icon='trash' onClick={() => {}} data-testid='big'/>
<APIButton size='huge' icon='trash' onClick={() => {}} data-testid='huge'/>
ui: let a landscape poster fill a one-column card, and fix three scale-blind tests `--card-poster-max-height` is a fixed height, so it stops scaling with the card: held to 220px, a 16:9 thumbnail is 391px wide, and any card wider than that centred it with empty panel on both sides. That is every video card at one column -- a phone, or any window under about 456px of content width. The cap is now `max(var(--card-poster-max-height), 56.25cqw)` with the poster band as the query container. 56.25cqw is nine sixteenths of the card: exactly the height of a 16:9 image that fills the width, and the same number states the rule for every other ratio -- a poster may be as tall as a 16:9 slice of this card and no taller. So a portrait book cover still reads as a band rather than a column, and now grows with the card instead of stopping at 220px. `max()` rather than `min()` so the floor wins on a narrow card. The gap pre-dated the interface scale, below about 414px, but the scale widened the range it shows in: the track minimum went from 200px to 220px, so one column now starts at 456px of content width instead of 414. Every existing poster case mounted a 233px card, which is why the wide card's own failure went unseen for the whole migration. Two cases added on a 451px card: a landscape poster reaches the edges, and a portrait cover stays a band. Three tests carried a hardcoded px expectation, which is a hidden assertion that the interface scale is 1. All three failed at 1.1, in names that said nothing about size -- and I did not catch them because I ran jest and the build for the scale change but not cypress, which AGENTS.md asks for on frontend work: - `cardPosterCap()` read `--card-poster-max-height` with parseFloat. The cap is rem now, so it returned 12.5 and failed a within(80, 240) bound -- taking five poster tests with it. It resolves through the root font-size and checks the unit. - `inNarrowColumn` was a fixed 340px, chosen to hold two 150px statistic tracks. At 165px tracks it became one column, so a test about the gap BETWEEN columns had no second column. It is now 340px times the scale, because "narrow" means narrow relative to the type. - The APIButton size test asserted 36px for `small`. It now measures against a real `sm` button, which is the claim it was making -- that `small` resolves to `sm` -- and holds at any scale. A `uiScale()` helper reads the token so no further test has to name a pixel count. Verified: ui-layout 248 passing, 0 failing; 1141 jest tests / 65 suites; clean build; browser-checked at 400/451/500/700/1200px of grid width, no side gap at any of them. The 12 remaining component failures are the pre-existing Semantic-era selector failures in Tags, Channels, Download and Inventory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:02:15 -06:00
{/* The reference: what `small` is claimed to translate INTO. */}
<APIButton size='sm' icon='trash' onClick={() => {}} data-testid='reference-sm'/>
review: name the icon-only controls, and make two guards mean what they say Acting on the review of #626. No bugs; one suggestion and three nits. The map's icon-only controls had no accessible name. IconButton requires a label by construction and AddToPlaylistButton supplies one, but the plain Button and APIButton used for edit, delete and the catalog preview reached assistive tech as unnamed buttons -- and my own Cypress fixtures carefully passed `aria-label` on the same pattern while production did not, which is its own kind of tell. All four are named now, and named with the row's subject rather than the verb alone: "Delete Water tank", not "Delete", because a table of pins otherwise offers a screen reader a column of identical buttons. A source guard holds that: it scans for controls that carry an icon and no label text, and reports any without an `aria-label`. Paired with a premise that it found some, since a scanner matching nothing reads exactly like a clean file. The Group guard asserted only that `<Group` appeared somewhere in the cell, which would pass on an empty Group left beside the bare siblings it was meant to wrap. It now checks that every control in the cell is inside the Group -- and the first version of THAT was wrong too: it sliced from `<Group` to the end of the cell rather than to `</Group>`, so controls after the closing tag still counted as inside, and the empty-Group plant stayed green. Slicing between the tags makes it fail. Coverage the review asked for: the Semantic size names the call sites actually use (`small`, `big`, `huge`) rather than only the Mantine ones, since the translation step was untested on the exact spellings that were broken; icon-only buttons stay square while loading, when the glyph is replaced by a spinner sized from the button's height; and `iconAfter`-only squares as well as `icon`-only. On the size passthrough, which was flagged as the highest-risk change outside the map: the buttons that grow are Settings' Shutdown and Reboot (`huge`, to 60px), Settings' Upgrade and Save and Channels' Save (`big`, to 50px), and VideoPlayer's Refresh (`large`, to 50px). All six read as deliberate emphasis -- the two biggest are the two destructive ones -- so they are left honoured rather than re-broken at the call site. `size='small'` resolves to `sm`, which is what the accidental default already was, so the detail pages do not move. 1134 jest / 64 suites, 246 in ui-layout.cy.js, clean npm run build.
2026-08-02 17:57:27 -06:00
</div>);
cy.get('[data-testid="huge"]').should(($huge) => {
const height = (id) =>
Cypress.$(`[data-testid="${id}"]`)[0].getBoundingClientRect().height;
ui: let a landscape poster fill a one-column card, and fix three scale-blind tests `--card-poster-max-height` is a fixed height, so it stops scaling with the card: held to 220px, a 16:9 thumbnail is 391px wide, and any card wider than that centred it with empty panel on both sides. That is every video card at one column -- a phone, or any window under about 456px of content width. The cap is now `max(var(--card-poster-max-height), 56.25cqw)` with the poster band as the query container. 56.25cqw is nine sixteenths of the card: exactly the height of a 16:9 image that fills the width, and the same number states the rule for every other ratio -- a poster may be as tall as a 16:9 slice of this card and no taller. So a portrait book cover still reads as a band rather than a column, and now grows with the card instead of stopping at 220px. `max()` rather than `min()` so the floor wins on a narrow card. The gap pre-dated the interface scale, below about 414px, but the scale widened the range it shows in: the track minimum went from 200px to 220px, so one column now starts at 456px of content width instead of 414. Every existing poster case mounted a 233px card, which is why the wide card's own failure went unseen for the whole migration. Two cases added on a 451px card: a landscape poster reaches the edges, and a portrait cover stays a band. Three tests carried a hardcoded px expectation, which is a hidden assertion that the interface scale is 1. All three failed at 1.1, in names that said nothing about size -- and I did not catch them because I ran jest and the build for the scale change but not cypress, which AGENTS.md asks for on frontend work: - `cardPosterCap()` read `--card-poster-max-height` with parseFloat. The cap is rem now, so it returned 12.5 and failed a within(80, 240) bound -- taking five poster tests with it. It resolves through the root font-size and checks the unit. - `inNarrowColumn` was a fixed 340px, chosen to hold two 150px statistic tracks. At 165px tracks it became one column, so a test about the gap BETWEEN columns had no second column. It is now 340px times the scale, because "narrow" means narrow relative to the type. - The APIButton size test asserted 36px for `small`. It now measures against a real `sm` button, which is the claim it was making -- that `small` resolves to `sm` -- and holds at any scale. A `uiScale()` helper reads the token so no further test has to name a pixel count. Verified: ui-layout 248 passing, 0 failing; 1141 jest tests / 65 suites; clean build; browser-checked at 400/451/500/700/1200px of grid width, no side gap at any of them. The 12 remaining component failures are the pre-existing Semantic-era selector failures in Tags, Channels, Download and Inventory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:02:15 -06:00
/*
* Measured against a real `sm` button rather than against 36px. The literal was a
* hidden assertion that the interface scale is 1, and it broke at 1.1 -- while the
* claim it is making, that `small` resolves to `sm`, was never about a pixel count.
*/
expect(height('small'), "small resolves to Mantine's sm")
.to.be.closeTo(height('reference-sm'), 0.5);
review: name the icon-only controls, and make two guards mean what they say Acting on the review of #626. No bugs; one suggestion and three nits. The map's icon-only controls had no accessible name. IconButton requires a label by construction and AddToPlaylistButton supplies one, but the plain Button and APIButton used for edit, delete and the catalog preview reached assistive tech as unnamed buttons -- and my own Cypress fixtures carefully passed `aria-label` on the same pattern while production did not, which is its own kind of tell. All four are named now, and named with the row's subject rather than the verb alone: "Delete Water tank", not "Delete", because a table of pins otherwise offers a screen reader a column of identical buttons. A source guard holds that: it scans for controls that carry an icon and no label text, and reports any without an `aria-label`. Paired with a premise that it found some, since a scanner matching nothing reads exactly like a clean file. The Group guard asserted only that `<Group` appeared somewhere in the cell, which would pass on an empty Group left beside the bare siblings it was meant to wrap. It now checks that every control in the cell is inside the Group -- and the first version of THAT was wrong too: it sliced from `<Group` to the end of the cell rather than to `</Group>`, so controls after the closing tag still counted as inside, and the empty-Group plant stayed green. Slicing between the tags makes it fail. Coverage the review asked for: the Semantic size names the call sites actually use (`small`, `big`, `huge`) rather than only the Mantine ones, since the translation step was untested on the exact spellings that were broken; icon-only buttons stay square while loading, when the glyph is replaced by a spinner sized from the button's height; and `iconAfter`-only squares as well as `icon`-only. On the size passthrough, which was flagged as the highest-risk change outside the map: the buttons that grow are Settings' Shutdown and Reboot (`huge`, to 60px), Settings' Upgrade and Save and Channels' Save (`big`, to 50px), and VideoPlayer's Refresh (`large`, to 50px). All six read as deliberate emphasis -- the two biggest are the two destructive ones -- so they are left honoured rather than re-broken at the call site. `size='small'` resolves to `sm`, which is what the accidental default already was, so the detail pages do not move. 1134 jest / 64 suites, 246 in ui-layout.cy.js, clean npm run build.
2026-08-02 17:57:27 -06:00
expect(height('big'), 'big is taller than small').to.be.greaterThan(height('small'));
expect($huge[0].getBoundingClientRect().height, 'huge is taller than big')
.to.be.greaterThan(height('big'));
});
});
it('stays square while it is loading', () => {
/*
* A loading button swaps its glyph for a spinner sized from the button's height, and
* the square rule fixes the width to that height -- so a spinner that did not fit
* would either be clipped or stretch the box. Both Button and APIButton, since
* APIButton is what actually spends time loading.
*/
cy.mountUI(<div>
<Button size='xs' icon='trash' aria-label='Delete' loading data-testid='busy'/>
<APIButton size='xs' icon='trash' loading onClick={() => {}} data-testid='busy-api'/>
</div>);
cy.get('[data-testid="busy-api"]').should(() => {
['busy', 'busy-api'].forEach((id) => {
const box = Cypress.$(`[data-testid="${id}"]`)[0].getBoundingClientRect();
expect(box.height, `${id} has a height`).to.be.greaterThan(20);
expect(box.width, `${id} is still square`).to.be.closeTo(box.height, 1);
});
});
});
it('squares an iconAfter-only button too', () => {
// The square rule keys off the same `data-icon-only` marker as the centring, and
// `iconAfter` alone is one of the cases that sets it.
cy.mountUI(<Button size='xs' iconAfter='upload' aria-label='Send' data-testid='after'/>);
cy.get('[data-testid="after"]').should(($button) => {
const box = $button[0].getBoundingClientRect();
expect(box.width, 'square').to.be.closeTo(box.height, 1);
});
});
ui: the map pin buttons were three sizes for three reasons Reported as "all different sizes", and the pin row's three actions measured 46x30, 30x30 and 54x36. Three causes. APIButton dropped `size`. `useAPIButton` declared `size = 'medium'` as a parameter and then never put it into the props it hands to Button, so every APIButton in the app rendered at Mantine's default regardless of what its call site asked for -- seventeen call sites pass one, from `xs` on the map pins to `big` and `huge` on Settings. The delete pin was 36px tall beside two 30px siblings because of it. Passing the parameter default through would have fixed the bug by breaking everything else -- every APIButton naming no size would have grown from `sm` to `md` -- so the default is undefined now and Button's own default stands. Eight buttons on three other pages do grow as a result, which is their call sites finally being honoured: VideoPlayer's `large`, one of Channels' `big`, and Settings' two `big` and two `huge`. An icon-only Button was not square. A Button is as wide as its content plus its horizontal padding; an ActionIcon is square by construction; and the pin row mixes the two, because AddToPlaylistButton renders an IconButton when it has no label. Their heights already agreed -- ActionIcon's scale was remapped onto Button's some commits ago -- and this is the other axis of the same alignment, keyed off Mantine's own `--button-height` so the two stay in step through every size. They were also misaligned and touching, which is a third thing: bare inline-block siblings align on text BASELINES, and a Button's baseline is not an ActionIcon's, so the middle control sat 4.3px above the other two. A Group, as every other row of buttons in the app uses. Written test-first at Roland's request. Seven cypress cases went red on the sizes -- widths 46 against 30, 54 against 36, 62 against 42, 70 against 50, and "xs is shorter than lg: expected 36 to be below 32" for the dropped size -- with both inverses green throughout: a labelled button stays as wide as its label, and an APIButton naming no size keeps the height it had. The alignment claim is measured in ui-layout.cy.js, including the premise that bare siblings really are misaligned, since three controls of identical height not lining up is not believable otherwise. The call sites are held by a source guard, because MapPins fetches from the API and builds its rows through SortableTable. That guard earned itself twice over. Written for the pin rows, it found the map-files subscribe cell putting a preview button beside a subscribe button with the same defect. Then a first attempt at a general "any cell with two controls" rule had to be abandoned: a cell whose buttons are the arms of a ternary renders only one and needs no Group, and excluding ternaries to allow for that also excluded the subscribe cell, whose `role={isSubscribed ? ... : ...}` says nothing about how many controls it holds. Named cells with a stated scope beat a general rule that quietly stops covering things. Two slips of mine in that file, both caught by running it: `expect(value, message)` is chai and throws in jest, and `onSave(pin.id, ...)` was not unique to the cell it named -- the edit row's TextInput calls it from onKeyDown in a different cell, so the check passed against the wrong one. 1132 jest / 64 suites, 243 in ui-layout.cy.js, clean npm run build. Confirmed live: three 30x30 controls, vertical spread 0, 10px gaps.
2026-08-02 17:44:25 -06:00
it('is a real constraint: an APIButton with no size keeps the default it had', () => {
/*
* `useAPIButton` declared `size = 'medium'` as a parameter default while never using
* it. Passing that through would have fixed the bug by breaking everything else --
* every APIButton that names no size would have grown from Mantine's `sm` to `md`.
*/
cy.mountUI(<div>
<APIButton icon='trash' onClick={() => {}} data-testid='default'/>
<Button icon='trash' aria-label='Delete' data-testid='plain'/>
</div>);
cy.get('[data-testid="default"]').should(($api) => {
const plain = Cypress.$('[data-testid="plain"]')[0].getBoundingClientRect();
expect($api[0].getBoundingClientRect().height, 'unchanged default')
.to.be.closeTo(plain.height, 1);
});
});
});
describe('a row of icon controls sits level and spaced', () => {
/*
* The map's pin actions are three icon controls in one table cell: edit (Button),
* add-to-playlist (IconButton) and delete (APIButton). They were laid out as bare
* siblings, so they were inline-block boxes aligned on their BASELINES -- and a Button's
* baseline is not an ActionIcon's, so the middle one sat 4.3px higher than the other two.
* They also touched, because JSX leaves no whitespace between elements.
*
* Both are what `Group` is for, which is how every other row of buttons in the app is
* built. Measured on the running app at tops 258.6 / 254.2 / 258.6 before the fix.
*/
const controls = <>
<Button size='xs' icon='edit' aria-label='Edit' data-testid='edit'/>
<IconButton size='xs' icon='list' label='Add to Playlist' data-testid='add'/>
<APIButton size='xs' icon='trash' onClick={() => {}} data-testid='delete'/>
</>;
const tops = (root) => ['edit', 'add', 'delete']
.map(id => root.querySelector(`[data-testid="${id}"]`).getBoundingClientRect().top);
it('is misaligned without a Group, which is why one is needed', () => {
/*
* The premise for the case below, and the thing a reader will not believe otherwise:
* three controls of identical height still do not line up when they are laid out
* inline, because they are aligned on text baselines they do not share.
*/
cy.mountUI(<div data-testid='bare'>{controls}</div>);
cy.get('[data-testid="bare"]').should(($bare) => {
const spread = Math.max(...tops($bare[0])) - Math.min(...tops($bare[0]));
expect(spread, 'bare siblings do not line up').to.be.greaterThan(1);
});
});
it('lines them up when wrapped in a Group', () => {
cy.mountUI(<Group gap='xs' data-testid='grouped'>{controls}</Group>);
cy.get('[data-testid="grouped"]').should(($group) => {
const spread = Math.max(...tops($group[0])) - Math.min(...tops($group[0]));
expect(spread, 'all three share a top edge').to.be.lessThan(1);
});
});
it('leaves a gap between them', () => {
cy.mountUI(<Group gap='xs' data-testid='grouped'>{controls}</Group>);
cy.get('[data-testid="grouped"]').should(($group) => {
const boxes = ['edit', 'add', 'delete']
.map(id => $group[0].querySelector(`[data-testid="${id}"]`).getBoundingClientRect());
expect(boxes[1].left - boxes[0].right, 'first gap').to.be.greaterThan(2);
expect(boxes[2].left - boxes[1].right, 'second gap').to.be.greaterThan(2);
});
});
});