mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 09:56:17 -05:00
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>
This commit is contained in:
parent
5491a82361
commit
f153d7c8d8
6 changed files with 174 additions and 43 deletions
|
|
@ -4,7 +4,7 @@ import {
|
|||
Message, Placeholder, Statistic, StatisticGroup, Status, TabBar, Table, tabClassName,
|
||||
TextInput,
|
||||
} from './index';
|
||||
import {contrastingColor, LoadStatistic} from '../Common';
|
||||
import {contrastingColor, HelpHeader, LoadStatistic} from '../Common';
|
||||
import {Notifications} from '@mantine/notifications';
|
||||
import {clearToasts, toast} from './toast';
|
||||
import {monochromeThemes, themeNames} from '../../themes/names';
|
||||
|
|
@ -398,8 +398,41 @@ describe('a heading keeps its trailing control on its own line', () => {
|
|||
* there, and containment alone (which the jest tests assert) does not prove two boxes
|
||||
* share a line.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
themeNames.forEach((theme) => {
|
||||
it(`sits the control beside the text in ${theme}`, () => {
|
||||
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}`, () => {
|
||||
cy.mountUI(
|
||||
<Header as='h3' after={<Button role='cancel' size='xs'>Help</Button>}>
|
||||
Root CA Certificate
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue