Repository navigation
Remove the safeTab() test helper, and type-check userEvent options - #4257
Merged
Merged
Conversation
Its click-then-Tab fallback no longer runs in any browser: the grid only lets Tab leave it from the first header cell or the last cell, so tests call `userEvent.tab()` directly. `renderTextEditor.test.tsx` renders a button after its one-cell grid, so tabbing out of the editor keeps focus on the page in Firefox r1564 (Playwright 1.65). Co-Authored-By: Claude Opus 5.5 <[email protected]>
`tsconfig.test.json` didn't load the Playwright provider's types, so `UserEventClickOptions` and the other option interfaces stayed empty: any object literal type-checked, and editors offered no completions. The provider's types include Node's, which declare `Error.stackTraceLimit`, so its `@ts-expect-error` is no longer needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
safeTab() test helpersafeTab() test helper, and type-check userEvent options
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
safeTab()calleduserEvent.tab(), and when focus left the page, it clicked a temporary button and tabbed again. That fallback no longer runs: with an assertion added to it, the browser suite never reached it in Chromium, Firefox, or WebKit. The grid only lets Tab leave it from the first header cell or the last cell (canExitGrid), and the tests that tab out of the grid have another element to move focus to.This PR calls
userEvent.tab()directly and removes the helper.renderTextEditor.test.tsxrenders a button after its one-cell grid, so tabbing out of the editor keeps focus on the page. Firefox r1555 (Playwright 1.64.1) can't tab out of Vitest's iframe ([Regression]: Firefox cannot move focus from an iframe to its parent since r1553 microsoft/playwright#43280), so the test passes without the button today, but Firefox r1564 (Playwright 1.65) can, and theafterEachfocus check then fails.afterEachfocus check explains what moves focus out of the page and suggests rendering a focusable element before or after the grid.Types of
userEventoptionstsconfig.test.jsonnow loads the Playwright provider's types (vite-plus/test/browser-playwright). Without them,UserEventClickOptionsand the other option interfaces ofvitest/browserstayed empty, souserEvent.click(element, { obviousTypo: 123 })type-checked, and editors offered no completions for the options.The provider's types include Node's, so Node globals like
processalso type-check in browser tests, andError.stackTraceLimitno longer needs its@ts-expect-error.How Tab behaves past the page's edges
Measured in Vitest's iframe by tabbing past the last of 3 buttons, and Shift+Tabbing past the first:
document.hasFocus()staysfalse, and it later turnstrueon a Tab that doesn't move focus.In every browser, one click on the page restores
document.hasFocus().Testing
vp run cipasses. The browser tests also passed with shuffled files and tests (--sequence.shuffle.files --sequence.shuffle.tests), one browser at a time, in 3 seeds per browser. Earlier seeds had Firefox and WebKit click timeouts in thebeforeEachfocus click, which happen before any Tab, also failed once onmain, and passed when the seeds ran again.🤖 Generated with Claude Code