Skip to content

test(a11y): give the browser suite the app's stylesheet, and guard hit targets - #716

Merged
EVWorth merged 1 commit into
mainfrom
test/hit-target-guard
Sep 18, 2026
Merged

EVWorth merged 1 commit into
mainfrom
test/hit-target-guard

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Closes #713.

The browser suite has never loaded the app's CSS

#713 concluded a pointer-target guard couldn't be built here, after three
attempts failed. The reason turned out to be one missing import:
test-setup.ts never loaded globals.css.

Probed directly:

before:  text-xs → 16px   h-9 → 0px    px-2 → 0px    stylesheets: 1
after:   text-xs → 12px   h-9 → 36px   px-2 → 8px    stylesheets: 2

Every one of the 340 browser tests has been rendering unstyled markup. That
is why my earlier sweep measured the title bar's buttons at 33px while they
were 20px in the app — it was measuring browser defaults. No assertion about
size, spacing or colour made in that suite could have meant anything.

All 341 pass with the stylesheet loaded, so nothing was depending on its
absence. jsdom ignores the import, so the unit suite is untouched.

Two more things the guard needed

The viewport was 414×896 — a phone, for a desktop app. It put the window
controls at x=430, off the right edge, where elementFromPoint can't reach
them; they measured as -1×-1. Now 1280×800.

The sweep reports how much it swept, and fails if that's too few. The first
version of this test lived in AppLayout's browser test, where every child is
mocked to a stub — it measured nothing, found nothing, and passed. That's the
failure mode this project keeps meeting, and the count assertion is the only
thing that catches it.

It can fail

Reverting #712's min-h-6:

Admin Tools is 49×21
Import Data is 49×21
Theme: Dark — click for Light is 30×19

Hit-testing rather than reading the box, because a control can be larger than
it looks — the splitters keep a 4px line and widen only the area around them,
and reading CSS offsets reports a widened area as passing even when a neighbour
paints over it.

What this opens up

With styles loaded and a real viewport, the browser suite can now assert things
it never could: computed colour, spacing, and geometry. The sweep here covers
the title bar; extending it to the full layout needs the unmocked-AppLayout
fixture #713 describes, which is still worth having.

🤖 Generated with Claude Code

…t targets

#713 said a pointer-target guard could not be built here, after three attempts
failed. The reason turned out to be one line: `test-setup.ts` never imported
`globals.css`, so every browser test has been rendering unstyled markup.

`text-xs` computed to 16px. `h-9` computed to zero. `px-2` to zero. That is why
the earlier sweep measured the title bar's buttons at 33px tall while they were
20px in the app — it was measuring browser defaults, and no assertion about
size, spacing or colour made in that suite could have meant anything.

Two further things had to be true before the guard was worth writing:

- The viewport was 414×896, a phone, for a desktop app. It put the window
  controls at x=430, off the right edge, where `elementFromPoint` cannot reach
  them — they measured as -1×-1. Now 1280×800.
- The sweep reports how many controls it swept and fails if that is too few. An
  earlier version of this test lived in AppLayout's browser test, where every
  child is mocked to a stub; it measured nothing, found nothing, and passed.
  That is the failure mode this project keeps meeting, and the count assertion
  is the only thing that catches it.

With those fixed, the guard works. Reverting the `min-h-6` from #712 now fails
it with the real numbers:

    Admin Tools is 49×21
    Import Data is 49×21
    Theme: Dark — click for Light is 30×19

Hit-testing rather than reading the box, because a control can be larger than
it looks — the splitters keep a 4px line and widen only the area around them,
and reading CSS offsets reports a widened area as passing even when a
neighbour paints over it.

All 341 browser tests still pass with the stylesheet loaded, so nothing was
depending on the absence of styles. jsdom ignores the import, so the unit suite
is untouched.

Closes #713.
@EVWorth
EVWorth merged commit 792751f into main Sep 18, 2026
12 checks passed
@EVWorth
EVWorth deleted the test/hit-target-guard branch September 18, 2026 00:17
EVWorth added a commit that referenced this pull request Sep 19, 2026
Expanding a long value showed the title, the character count, the search field
and the buttons — and no content. Reported against a 15,573-character
`SHOW CREATE TABLE`, and reproducible for any value: the content area was
56px tall, which is its own padding and nothing else.

The panel was `max-h-[80vh]`, which is a cap and not a height, so it sized to
its content. Its content area is `min-h-0 flex-1`, and inside that sits Monaco,
which is absolutely positioned and reports no intrinsic height. Every one of
those is individually reasonable and together they leave nothing holding the
box open.

`min-h-0` is the part worth understanding. A flex item's automatic minimum size
is its content, which is what normally stops a `flex-basis: 0` item collapsing;
`min-h-0` switches that off. It is the right thing to write when the parent has
a definite height and you want the child to scroll — which is what Monaco needs
— and it is fatal when the parent does not. The two other flex-column panels in
the app use `flex-1` without `min-h-0`, so their automatic minimum still holds
them open. This one had disabled its own safety net.

So the panel gets a definite `h-[80vh]`. The viewer is a place to read a value
rather than a message box, a consistent size suits it, and the failure mode
cannot recur.

This is #217 again, fixed once in #220 at a nested wrapper. That wrapper was
real and removing it was right, but it was not why the box was empty, and the
bug came back.

The test measures the box rather than Monaco, because Monaco loads
asynchronously and may never mount in a harness, while the box it would be
given is already decided by CSS. It only means anything because the browser
suite loads the app's stylesheet as of #716 — before that every element
measured zero and this test would have passed against nothing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P3][test] No regression guard for pointer target sizes

1 participant