Repository navigation
test(Tokenizer): the group-scroll spec waits for the story's play function - #12017
Conversation
…ed token Keyboard focus in a grouped Tokenizer's strip called scrollIntoView on the focused item. WebKit often dropped that request, and its own focus scroll, so the strip stayed at its start with the focused token wholly outside it (8 of 10 runs of the group-scroll browser spec). The strip now measures the item against its scroll padding (the fade width) and sets scrollLeft by the least distance that brings the item inside, the same result as before in Chromium. The unit case gives the strip and the token boxes and checks the scroll distance; it fails before this change.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 605b4f1 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Tokenizer · Storybook | 104.3 kB (0) · 20.3 kB CSS (0) | 2,640 (0) | ✓ · ✓ · ✓ |
Package size: no published package changed; no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.
Accessibility: 1 violation(s)
Accessibility Audit
Status: 1 accessibility violation(s) found — 1 serious.
Tokenizer - 1 issue(s)
- 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
- Rule:
color-contrast· Affects 2/31 stories · Learn more - WCAG: 1.4.3 (Level AA)
- Rule:
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Changes requested: the new reveal must keep a wide token's focused remove button in view, and the new unit case must stop failing the test run.
- In a left-to-right layout, Shift+Tab onto the remove button of a token wider than the strip's clear part now scrolls the token's left edge into view and leaves the focused button outside the strip, where
mainkept it visible (Tokenizer.tsx:985-986); when the token cannot fit, reveal the focused control instead, add a wide-token test, and limit the changeset's "fully in view" to tokens that fit. - The new unit case's
getComputedStylestub spreads aCSSStyleDeclaration, which dropswritingMode, so the strip's next measure throws and Vitest exits 1 although every test passes (Tokenizer.test.tsx:3260-3264); return aProxythat answers only the two scroll-padding keys, and unstub infinally. scrollClearOfFadesreimplements TabList'srevealStop(TabList.tsx:479-507), and the two already disagree on items wider than the clear part; move the reveal into one shared helper that both components call.
Approval also needs the real-WebKit result for the remove-button reveal at this head that the description promises, because the unit case checks only arithmetic against stubbed boxes.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim, changeset: in Safari the strip scrolls a focused token fully into view, clear of the fades. False for a token wider than the clear part, whose focused button ends outside the strip (Tokenizer.tsx:985-986). The Safari part is unverified, because the real-WebKit runs are pending.
- Claim: Safari keyboard users now see each focused token fully, as in Chromium. False for wide tokens, which now regress in Chromium too (base keeps the button at 186-202 px, head puts it at 339-355 px against a strip ending at 233 px).
- Claim: pointer users are unchanged. Verified: the
:focus-visibleguard is unchanged (Tokenizer.tsx:953-958). - Claim: no API change. Verified: only non-exported functions change.
- Claim: WebKit dropped the scroll in 8 of 10 runs. Not verifiable here, because WebKit could not run in this review.
- Claim: the strip measures the item against its box minus scroll padding and scrolls the least distance, replacing
scrollIntoView. Verified (Tokenizer.tsx:976-997). - Claim: it is the same under right-to-left. True for tokens that fit. False for wide tokens: right-to-left keeps the focused button visible, left-to-right does not.
- Claim: an item wider than the clear part keeps its left edge in view. Verified as written; it is the first finding.
- Claim: keyboard focus only. Verified.
- Claim: the scrollable-container spec and the group-scroll browser spec state the reveal. The browser spec asserts it (TokenizerGroupScroll.a11y.browser.spec.ts:257-302). The clause that states it is the Tokenizer component record's FR30; the custom-scrollbar clause cited does not.
- Claim: the unit case fails on
mainand passes here. Verified: "expected +0 to be 114" on the base. - Claim: the Tokenizer and InputGroup suites pass 318 of 318, and tsc and eslint are clean. All 318 tests pass and tsc and eslint report no errors, but the run exits 1 on an unhandled TypeError from the new case (the base exits 0).
- Claim: the real-WebKit 10-run comparison is to be added. Pending.
- Claim: five overlapping pull requests do not touch the strip's focus reveal. Verified: none of their patches touches it.
- Claim, commit message: Chromium gives the same result as before. False for wide tokens.
- File
.changeset/tokenizer-strip-reveal-webkit.md: "fully in view" overstates the result for wide tokens (first finding). - File
packages/core/src/Tokenizer/Tokenizer.tsx: the first and third findings; the new JSDoc's first sentence restates the function (non-blocking). - File
packages/core/src/Tokenizer/Tokenizer.test.tsx: the second finding.
…ction The InputGroup overflow story's play function scrolls the strip to its end and back to rest. The spec's mount waited for a visible token and fonts but not for play, so in WebKit those scrolls landed 30-100 ms into a case's Shift+Tab walk and reset the strip under a focused token. mount now waits for Storybook's story render to reach its completed phase, and fails if the play function errored. The product assertions are unchanged.
|
/approve-spec ff22fe1 |
There was a problem hiding this comment.
Changes requested: the reveal must keep a wide token's focused remove button in view, the browser spec's new wait must be able to finish, and the new unit case must stop failing the test run.
- In a left-to-right layout, Shift+Tab onto the remove button of a token wider than the strip's clear part scrolls the token's left edge into view and leaves the focused button outside the strip, where
mainkept it visible (Tokenizer.tsx:985-992); when the token cannot fit, reveal the focused control instead, add a wide-token test, and limit the release note's "fully in view" to tokens that fit. - The group-scroll browser spec's
mount()waits for the story render'scompletedorerroredphase, but this Storybook passes throughcompletedwithin one task on its way tofinished, so all six cases time out at 60 s in Chromium (TokenizerGroupScroll.a11y.browser.spec.ts:57-66); wait forfinished, as the sharedopenStoryhelper does, and detect a failed play function separately. - The new unit case's
getComputedStylestub spreads aCSSStyleDeclaration, which dropswritingMode, so the strip's next measure throws and Vitest exits 1 although every test passes (Tokenizer.test.tsx:3260-3264); return aProxythat answers only the two scroll-padding keys, and unstub infinally. scrollClearOfFadesreimplements TabList'srevealStop(TabList.tsx:478-509), and the two already disagree on items wider than the clear part; move the reveal into one shared helper that both components call.
Approval also needs the real-WebKit result for the remove-button reveal at this head, which the spec can give once its wait is fixed.
Claims and files checked
Review mode: incremental; reason: none
- Claim, release note: in Safari the strip now scrolls a token whose remove button takes keyboard focus fully into view, clear of the fades. False for tokens wider than the clear part (
Tokenizer.tsx:985-992); the Safari part is unverified, since no WebKit result exists for this head. - Claim: Safari keyboard users now see each focused token fully, as in Chromium. False for wide tokens, which regress in Chromium too (button at 339-355 px against a strip ending at 233 px;
mainkept it at 186-202 px). - Claim: pointer users are unchanged. Verified: the
:focus-visibleguard is unchanged (Tokenizer.tsx:953-958). - Claim: no API change. Verified: the built API surface of Core and the themes is identical on base and head.
- Claim: WebKit kept the strip at 0 in 8 of 10 runs and Chromium scrolled in 3 of 3. Not verifiable here, because WebKit could not run in this review.
- Claim: the strip measures the item against its box minus scroll padding and scrolls the least distance, replacing
scrollIntoView. Verified (Tokenizer.tsx:976-997). - Claim: the result is the same under right-to-left. True for tokens that fit; for wide tokens right-to-left keeps the focused button visible and left-to-right does not.
- Claim: an item wider than the visible part keeps its left edge in view. Verified as written; it is the first finding.
- Claim: keyboard focus only. Verified (
Tokenizer.tsx:953-958). - Claim: setting
scrollLeftfollows the strip's computedscroll-behavior, which the strip leaves unset, so the jump stays instant. Verified: the track sets noscroll-behavior(Tokenizer.tsx:560-585). - Claim: the scrollable-area record's keyboard and custom-scrollbar clauses state the reveal clear of the fades. Partly false: they cover keyboard reach and scrollbar presentation; the Tokenizer record's grouped-mode clause states the reveal, and the browser spec asserts the fade clearance.
- Claim: the unit case fails on
mainand passes here. Verified on the same test file ("expected +0 to be 114" on the base); it passes at this head. - Claim: the Tokenizer and InputGroup suites pass 318 of 318, with
tscandeslintclean. Every test passes, but the run exits 1 on an unhandledTypeErrorfrom the new case (the Tokenizer file alone: 176 passed, 1 error). - Claim: real WebKit passed 0 of 10 on
mainand 5 of 10 with the product change alone, and the story's play function raced the case. Not verifiable here (WebKit unavailable); the story's play function does scroll the strip to its end and back (InputGroup.stories.tsx:386,:405). - Claim: the spec's
mount()now waits for the story render to complete and fails if play errored. False: it waits for a phase the render never rests in, so every case times out, and an errored render also ends atfinished, so the error branch never fires. - Claim: the product assertions are unchanged. Verified: the diff touches only
mount()and adds a type. - Claim: at this head Chromium passes 18 of 18. False: 0 of 6 Chromium cases pass, each timing out in
mount(); with the wait onfinished, 6 of 6 pass. - Claim: five overlapping pull requests do not touch the grouped strip's focus reveal. Verified: none of their patches touches it.
- Claim, commit messages: Chromium gives the same result as before (false for wide tokens);
mountwaits for the completed phase and fails on a play error (false, as above). - File
.changeset/tokenizer-strip-reveal-webkit.md: "fully in view" overstates the result for wide tokens (first finding). - File
packages/core/src/Tokenizer/Tokenizer.tsx: first and fourth findings; the new JSDoc's first sentence restates the function (non-blocking). - File
packages/core/src/Tokenizer/Tokenizer.test.tsx: third finding. - File
packages/core/src/Tokenizer/__tests__/TokenizerGroupScroll.a11y.browser.spec.ts: second finding.
…nished or completed This Storybook's render rests at "finished", not "completed", so the wait never resolved. It now accepts either, and fails only if play errored.
|
/approve-spec df0d6d4 |
… whole failure On the device farm, main plus only the spec's wait for the story's play function passes the WebKit group-scroll spec 10 of 10 (remove buttons and fades). The browser's scrollIntoView was never dropped: the story's play function reset the strip under the case. Tokenizer.tsx, its unit case and the changeset go back to main's; only the spec change remains.
|
/approve-spec bf045af |
There was a problem hiding this comment.
Changes requested: the spec's new wait does start each case after the story's play function, but its guard against a failed play function cannot fire, and the description says it does.
mount()accepts the render phasesfinished,completedanderroredand then asserts the phase is noterrored, yet this Storybook leaves a render that caught a play-function exception atfinishedjust like a healthy one, so the assertion never fires: probed with the overflow story's play function forced to throw,mount()resolved as usual and the strip was left at the end of its scroll instead of the rest position play restores, which makes the next case fail on geometry instead of naming the story (TokenizerGroupScroll.a11y.browser.spec.ts:62-69); either detect the play exception on Storybook's addons channel, or wait forfinishedalone as the shared story helper and the CodeBlock, TabBar and AppShell waits do and drop the claim from the description.
Two smaller points, neither blocking: completed is unreachable in this Storybook for the same reason the error branch is, and the wait accepts any current render where the shared helper also checks the render's story id. Reverting the strip's own scroll resolves the three earlier findings on the component and its unit case, and all six cases now pass in Chromium here, three runs out of three. The WebKit result this change is about cannot be reproduced in review, so it stands on the device-farm results stated in the description. CI has not run at this head because the pull request is a draft: marking it ready for review, or adding the ci:run label, runs the accessibility specs.
Claims and files checked
Review mode: incremental; reason: none
- Claim: the spec's mount waits for the story's play function before a case starts. Verified: the wait resolves only once the render rests, which is after play, its animation wait and its afterEach hooks.
- Claim: it fails the case if the play function errored. False, and the blocking finding above.
- Claim: no product code changes, and the net change is the spec file only. Verified: the one changed file at this head is the browser spec, and the component source and story match the default branch.
- Claim: the case assertions are unchanged and nothing is relaxed. Verified: the diff adds one type and the wait inside mount.
- Claim: Chromium passes 18 of 18. Verified here: the six cases passed three times over, with no retries.
- Claim: the device-farm WebKit results, 10 of 10 with this spec change against 2 of 10 for the remove-button case on the default branch. Not verifiable in review: WebKit could not run here, and this repository runs the spec under WebKit only in its weekly report-only job.
- Claim: the story's play function scrolls the strip to its end and back, which raced the case. Verified in the story's source, which scrolls to the end and resets to rest on its last line.
- Claim: test-only, so no changeset. Verified: the repository's changeset classifier treats a path inside a tests folder as outside a package's release surface.
- Claim: the five overlapping pull requests do not touch this spec. Verified: none of their changed files includes it.
- Claim, commit message: the wait accepts either resting phase and fails only if play errored. The first half is verified, the second is the blocking finding.
- File
packages/core/src/Tokenizer/__tests__/TokenizerGroupScroll.a11y.browser.spec.ts: the blocking finding and the two smaller points; the rest of the file is unchanged and passes.
…waits do This Storybook leaves a render at finished whether or not its play function threw, so the errored check could not fire. The wait now matches the CodeBlock and AppShell specs: it resolves when the render reaches finished. A play function that throws is not reported here; the next case fails on its own assertions.
|
/approve-spec 2387055 |
There was a problem hiding this comment.
Approved: every required check has passed on this head.
mount() now waits for the story render to reach finished, which Storybook reaches after the play function in every outcome, so the play function's scroll to the end and back can no longer land inside a case. All six cases pass in this pull request's Chromium accessibility run; the WebKit result rests on the device-farm runs in the description.
Two optional points, neither blocking: the wait accepts whichever render is current where the shared openStory helper also checks the story id, and the description's "the next case fails on its own assertions" holds only for a play function that throws after its scroll to the end, while CI's story play guard reports a throwing play for both overflow stories either way.
Claims and files checked
Review mode: same-head; reason: none
- Claim: the spec failed in WebKit on most runs, with the remove-button reveal case passing 2 of 10 and the left-to-right fades case 9 of 10 on the default branch. Not verifiable in review: WebKit could not run here.
- Claim: the product works and the test raced its own story. Consistent: the head changes only the spec and its cases pass; the WebKit part rests on the device-farm runs.
- Claim: the overflow story's play function scrolls the strip to its end and then back to 0. Verified in the story source.
- Claim: mount waited for a visible token and for fonts, but not for play. Verified in the default branch's spec.
- Claim: in WebKit, play's two scrolls landed 30 to 100 ms into a case's Shift+Tab walk, and an instrumented device-farm run showed every product scroll landing correctly. Not verifiable in review.
- Claim: mount now waits until the render reaches finished, play included, as the CodeBlock and AppShell browser specs already do. Verified: both specs poll the same phase.
- Claim: the render also rests at finished after a play function throws, so a throwing play is not reported by this spec. Verified in the Storybook version the repository uses.
- Claim: the next case then fails on its own assertions. Partly verified: true for a throw after play's scroll to the end, not for an earlier one.
- Claim: no product code changes, the case assertions are unchanged and nothing is relaxed. Verified: the one changed file is the spec, and the diff adds only a type and the wait.
- Claim: an earlier head's component change is reverted and the net diff is the spec file only. Verified.
- Claim: the device-farm table, 51 of 60 for the whole file on the default branch against 60 of 60 with this spec change, with or without the earlier component change. Not verifiable in review.
- Claim: Chromium, three runs, 18 of 18. Verified: 18 passed with no retries against a Storybook built from this head, and all six cases pass in this pull request's CI.
- Claim: the spec diff equals the device-farm build with only the spec change. Not verifiable in review.
- Claim: test-only, so no changeset. Verified: the release changeset check treats a spec file as not shipping.
- Claim: the five overlapping pull requests change the component or the group for other behaviour, not this spec. Verified: none of their changed files is this spec.
- Claim, commit messages: the final wait rests on finished as the other story waits do, and the changeset is dropped because a test-only change takes none. Verified. The revert commit's "the spec race was the whole failure" rests on the device-farm runs.
- File
packages/core/src/Tokenizer/__tests__/TokenizerGroupScroll.a11y.browser.spec.ts: the two optional points above; otherwise clear.
| await page.waitForFunction( | ||
| () => | ||
| (window as StorybookPreviewWindow).__STORYBOOK_PREVIEW__?.currentRender | ||
| ?.phase === 'finished', | ||
| ); |
There was a problem hiding this comment.
Optional: this accepts whichever render is current. openStory in internal/interaction-harness/src/story.ts also checks render.id === storyId and turns off Storybook's highlight module, so openStory(page, storybook.origin, story) could replace the navigation, the fonts wait and this poll. Each mount loads a fresh page with one story, so nothing goes wrong today.
Primary intent
Test fix: the grouped-Tokenizer scroll browser spec waits for the story's play function before a case starts.
Maintainer impact
TokenizerGroupScroll.a11y.browser.spec.tsfailed in WebKit most runs. On main, the remove-button reveal case passed 2 of 10 and the LTR fades case 9 of 10. The product works; the test raced its own story.Cause
The InputGroup overflow story's play function scrolls the token strip to its end and then back to 0 ("leave the row at rest"). The spec's
mount()waited for a visible token and for fonts, but not for play. In WebKit, play's two scrolls landed 30–100 ms into a case's Shift+Tab walk and reset the strip under a focused token. An instrumented device-farm run showed every product scroll landing correctly, and then the story resetting it.Change
mount()now waits until Storybook's story render reachesfinished, play function included, as the CodeBlock and AppShell browser specs already do. This Storybook also rests atfinishedafter a play function throws, so a throwing play isn't reported here; the next case fails on its own assertions.Tokenizer.tsxto set the strip's scroll itself. The farm run below shows that change isn't needed, so it's reverted; the net diff is the spec file only.Evidence
Device farm,
TokenizerGroupScroll.a11y.browser.spec.ts, WebKit, 10 serial runs,--retries 0, SHA-stamped Storybooks:Chromium ×3: 18 of 18. The spec diff in this head is identical to the "main + this spec change only" build.
Scope
Test-only, so no changeset.
Owner and land path
Overlap checked: #11526, #11418, #9030, #8199, #4329 (they change Tokenizer or InputGroup for other behavior; this PR now changes only the group-scroll browser spec)