Repository navigation
test(a11y): add hover and pointerAway to the accessibility harness - #7828
Conversation
Contracts for hover-shown content (tooltips) need to rest a mouse pointer on a subject and move it off again. The Chromium harness gains hover(), bounded like click(), and pointerAway(), which moves the pointer to the first viewport edge point off the subject and every related subject and refuses when there is none; jsdom reports both as unobservable. Two harness self-tests cover them, and a scoped pr-a11y step runs the harness self-tests whenever the harness changes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression46 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Changes requested: hover and pointerAway fit the harness's real-browser layer, but pointerAway() avoids only the semantic subject and related subjects, so for a binding whose pointerTarget covers one of its candidate points, such as the bottom-right corner, it leaves the pointer on the very target hover() used and no leave event fires. Adding pointerLocator to the watched set in internal/a11y-spec/src/harness/chromium.ts fixes this, and all eight harness self-tests still pass with it. Please also add a self-test where a related subject covers the first candidate point, because today both new tests still pass if pointerAway() ignores related subjects.
[Automated review]
| [viewport.width / 2, viewport.height - 2], | ||
| [viewport.width - 2, viewport.height / 2], | ||
| ] as const; | ||
| const watched = [locator, ...Object.values(options.related ?? {})]; |
There was a problem hiding this comment.
hover(subject) rests on the subject's pointer target (pointerLocator), but this watched set leaves it out. With a binding's pointerTarget anchored over the bottom-right corner, pointerAway() moves onto that target and no mouseleave fires (reproduced in Chromium). Suggested:
const watched = [locator, pointerLocator, ...Object.values(options.related ?? {})];| expect(await (await harness.related('offscreen')).isVisible()).toBe(true); | ||
| }); | ||
|
|
||
| test('hover rests the pointer on a subject and pointerAway moves it off every subject', async ({ |
There was a problem hiding this comment.
The first candidate corner is already clear on this page, so this test still passes when pointerAway() ignores related subjects. A case with the related subject anchored over the bottom-right corner (position:fixed;right:0;bottom:0) passes on this head and fails under that mutation.
hover() rests on the pointer target, which a binding can set apart from the semantic subject, so pointerAway() must not land on it. Add a self-test where a related subject covers the first candidate corner.
There was a problem hiding this comment.
Changes requested: this head fixes the pointer-target handling in pointerAway() and adds a related-subject test that fails when its check is removed, but no self-test yet fails if pointerAway() stops watching a binding's pointer target. Please add one self-test to internal/a11y-spec/src/harness/chromium.chromium.spec.ts whose harness passes a pointerTarget (for example a label around a checkbox) placed over the bottom-right viewport corner, and assert that the target logs both enter and leave after hover() and pointerAway(). Such a test passes on this head and fails when pointerLocator is removed from the watched set.
[Automated review]
| // pointer target can differ from its semantic subject. | ||
| const watched = [ | ||
| locator, | ||
| pointerLocator, |
There was a problem hiding this comment.
Nothing fails if this entry is removed: every pointerAway self-test builds its harness without a pointerTarget, so all nine harness self-tests still pass. A self-test whose pointerTarget (say, a label around a checkbox) covers the bottom-right corner, asserting target+ target- after hover() and pointerAway(), passes on this head and fails without this line.
There was a problem hiding this comment.
Approval recommended: hover and pointerAway fit the harness's real-browser layer, and this head adds the pointer-target self-test requested on the previous head, which fails if pointerAway() stops avoiding a binding's pointer target. The related-subject and refusal cases are covered the same way, and the new pr-a11y step ran all ten harness self-tests green in Chromium on this head. No further changes are needed.
[Automated review]
What this proves
The accessibility harness can now drive a mouse pointer the way a hover-summoned surface needs:
hover(subject)rests the pointer on a subject, andpointerAway()moves it off every subject. Contracts for content that hover shows — the Tooltip contract next — use them to prove a hint appears when the pointer rests on its trigger, stays while the pointer moves onto it, and goes when the pointer leaves.Test-only: no runtime, docs, record, or Changeset change.
Shape
internal/a11y-spec/src/harness.ts— two real-browser methods onHarness:hover(subject)andpointerAway().harness/chromium.ts—hoveruses the same bounded pointer reach asclick, so a subject a pointer can never rest on reports why instead of timing out the test.pointerAwaymoves the pointer to the first viewport corner or edge midpoint whose hit element is off the subject, its pointer target, and every related subject, and refuses with a legible error when every candidate is covered.harness/jsdom.ts— both report the real-browser layer as unobservable, likeclick.check.test.ts— the fake harness gains the two no-op methods.harness/chromium.chromium.spec.ts— four self-tests: hovering a subject then a related subject then moving away produces exactlyenter, leave, enter, leave;pointerAwayskips a corner a related subject covers, and a corner the subject's pointer target covers (each fails if that watch is removed);pointerAwayrefuses on a page a watched subject fully covers..github/workflows/ci.yml— "Run accessibility harness self-tests", scoped to harness changes, so a harness change carries its own browser evidence.Evidence
check.test.ts32/32;tsc(a11y-spec), eslint, Prettier, and the repository pre-push checks clean.Scope