From ab580195501ea85864021801ebd6e104ccaca36b Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 1 Aug 2026 16:05:29 -0600 Subject: [PATCH] =?UTF-8?q?test:=20act=20on=20review=20=E2=80=94=20the=20s?= =?UTF-8?q?keleton=20guard=20was=20reading=20the=20wrong=20layer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- app/src/components/FileBrowser.js | 7 ++- app/src/components/ui/ui-layout.cy.js | 67 ++++++++++++++++++++------- app/src/components/ui/ui.css | 32 +++++++++++-- app/src/components/ui/ui.test.js | 37 ++++++++++++--- 4 files changed, 113 insertions(+), 30 deletions(-) diff --git a/app/src/components/FileBrowser.js b/app/src/components/FileBrowser.js index 84a61c38..705ac6b2 100644 --- a/app/src/components/FileBrowser.js +++ b/app/src/components/FileBrowser.js @@ -437,10 +437,9 @@ export function FileBrowser() { disabled={wrolModeEnabled} style={{paddingLeft: '1em', paddingRight: showLabels ? '1em' : '0.8em'}} > - {/* On a filled button, so the corner disc must be the button's fill and not - the page background, which would read as a hole punched in the button. */} - } label='New folder' - style={{'--icon-stack-bg': 'var(--blue)'}}> + {/* The corner disc follows the button's fill on its own -- including when WROL + mode disables it and Mantine repaints it grey. See ui.css. */} + } label='New folder'> {showLabels ? <> New Folder : null} diff --git a/app/src/components/ui/ui-layout.cy.js b/app/src/components/ui/ui-layout.cy.js index 431864e6..bb8471e1 100644 --- a/app/src/components/ui/ui-layout.cy.js +++ b/app/src/components/ui/ui-layout.cy.js @@ -621,12 +621,19 @@ describe('a toast is readable in every theme', () => { }); /* - * The colour a box actually shows: its own background, or the first pseudo-element that - * paints one. Mantine's Skeleton draws itself entirely from ::before and ::after, so - * reading the root alone reports `rgba(0, 0, 0, 0)` and any test built on it is vacuous. + * The colour a box actually shows, looking through the layers in the order given. + * + * 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. */ -const paintedBackground = (el) => { - for (const pseudo of [null, '::before', '::after']) { +const paintedBackground = (el, order = [null, '::before', '::after']) => { + for (const pseudo of order) { const colour = getComputedStyle(el, pseudo).backgroundColor; if (colour && !/^rgba\(.*,\s*0(\.0+)?\)$/.test(colour) && colour !== 'transparent') { return colour; @@ -639,19 +646,18 @@ describe('a loading placeholder is visible on the surface it covers', () => { themeNames.forEach((theme) => { it(`separates the skeleton from the panel in ${theme}`, () => { /* - * A Skeleton is Mantine's, and Mantine draws it from --mantine-color-gray-1 or - * --mantine-color-dark-4. Those are remapped to our tokens in themes/mantine.ts, - * which is exactly what makes this worth checking: `dark-4` is `--border` and - * `gray-1` is `--bg`, and neither was chosen with a panel behind it in mind. If - * the bars come out the same colour as the panel there is no placeholder at all, - * only an empty box, and nothing in jsdom can see that. + * `--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 colour there + * is no placeholder at all, only an empty box, and jsdom cannot see that. */ cy.mountUI(, {theme}); cy.get('.mantine-Skeleton-root').first().should(($line) => { - const line = paintedBackground($line[0]); - const panel = paintedBackground($line[0].closest('.wrolpi-panel')); + // 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]); expect(line, 'the skeleton paints something').to.not.equal(null); + expect(panel, 'the panel paints something').to.not.equal(null); expect(line, 'the skeleton is not the panel it sits on').to.not.equal(panel); }); }); @@ -703,8 +709,10 @@ describe('an icon stack carries the surface it was placed on', () => { it(`matches a filled button in ${theme}`, () => { cy.mountUI( , @@ -719,6 +727,29 @@ describe('an icon stack carries the surface it was placed on', () => { }); }); + it('follows a filled button when it is disabled', () => { + /* + * The file browser's New Folder button is disabled in WROL mode, and Mantine swaps a + * disabled button's fill for --mantine-color-disabled. A disc pinned to `--blue` + * then becomes a blue chip on a grey surface -- the same defect as the original + * hole, inverted. The disc has to follow the button, not the button's enabled fill. + */ + cy.mountUI( + , + {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); + }); + }); + it('takes the surface from an ancestor, which is how the nav bar sets it', () => { /* * The nav bar's colour is a user setting written inline on the