Repository navigation
test(Selector, MultiSelector): wait for the on-demand sheet module before the first open - #8642
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Looks good to merge: loading the bottom-sheet module once per file in beforeAll takes the on-demand load out of the first open's 1 s findByRole wait without touching product code, assertions or timeouts, and the held-load check described in the PR reproduces (the three first-open tests fail before this change and pass after it). As an optional follow-up, Selector.listbox.a11y.test.tsx and MultiSelector.listbox.a11y.test.tsx open the same lazily loaded sheet behind the same wait and could use the same hook.
[Automated review]
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsMultiSelector (@astryxdesign/core) · View in Storybook
Component Size
Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included. Bundle Size SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Looks good to merge: loading the bottom-sheet module once per file in beforeAll takes the on-demand load out of the first open's 1 s findByRole wait in all five Selector and MultiSelector sheet test files, without touching product code, assertions or timeouts. The held-load check in the description reproduces: with the sheet module's load held for 1.2 s, the five first-open tests fail before this change, and all 443 tests in the five files pass after it, also against the current base branch. Nothing else is needed from you.
[Automated review]
|
Posted by Cindy's agent on her behalf: closed and reopened only to restart this PR's CI on the current workflow after tonight's queue-wide cancel; nothing in the PR changed. |
…fore the first open Selector and MultiSelector present their bottom sheet through a lazy import (SelectorBottomSheet). The first sheet test in each file waited for that module load inside its open's `findByRole`, whose budget is Testing Library's 1,000 ms. On a loaded runner the load alone crosses that budget (one run timed out at 1,285 ms), and because the load keeps running, the next tests in the file can fail too until it lands. Loading the module is not part of an open: each of the five files that open a sheet (Selector's and MultiSelector's unit tests, the combobox binding and both listbox bindings) now waits for it once in `beforeAll`, and each open waits only for the open. No timeout is raised. Red first: with the sheet module's load held for 1.2 s (a vi.mock that delays the original module), five first-open tests failed on main; with the preload, all 443 tests in the five files pass under the same held load.
4f6c3b1 to
780fce6
Compare
There was a problem hiding this comment.
Looks good to merge: loading the bottom-sheet module once per file in beforeAll takes the on-demand load out of the first open's 1 s findByRole wait in all five Selector and MultiSelector sheet test files, without touching product code, assertions or timeouts. The held-load check in the description reproduces: with the sheet module's load held for 1.2 s, the five first-open tests fail before this change and every test in the five files passes after it. Nothing else is needed from you.
[Automated review]
…and sheet module before its one-second wait (#8896) ## Why The Tokenizer case of `useAnnounceRenderedText.adopters.test.tsx` fails at random on a busy machine, on pull requests that don't touch Tokenizer: "Unable to find a label with the text of: Search Tags". ## What led to it Tokenizer loads its touch sheet on demand (`loadTokenizerBottomSheet` in `Tokenizer.tsx`). The case opens the sheet and waits one second, the default `findByLabelText` wait, for the sheet's search field, so that second covers the sheet module's first load as well as the open. The load alone takes about a second on an idle machine. With vitest's default worker count on a 166-core box (165 workers), the case failed in all three full core runs I made; with 16 workers it passed in both, and it passes alone. ## Options and tradeoffs - Raise the wait: hides the cause, and a slower machine still fails. - Load the sheet eagerly in Tokenizer: changes product code, and the on-demand load is deliberate (`component:Tokenizer` PR6). - Load the module in the test before the open, so the wait covers only what the test checks (this pull request). ## Why this choice The case checks that the sheet hands its own content to the shared announcement module, not how its code loads. It now awaits `import('../Tokenizer/TokenizerBottomSheet')` before it renders. That load counts against the test's 30-second budget, never against the one-second wait. The other lazily loaded sheets and layers have the same fix open in #8642 (Selector, MultiSelector), #8352 (Item's swipe layer) and #8353 (DropdownMenu's sheet). ## How to check it 1. Make the sheet module's load cost CPU, as on a starved machine: in a copy of the test, mock `../Tokenizer/TokenizerBottomSheet` with a factory that busy-waits 1.2 s before returning the real module. 2. Run that copy. On main the Tokenizer case fails with the error above; with this change all 8 cases pass. 3. Run the real test without the mock: all 8 pass. ## Evidence - With the 1.2 s busy-wait: 3 of 3 runs fail on main, 3 of 3 pass here. - The hooks and Tokenizer test folders pass (46 files, 747 tests), along with core's typecheck and `pnpm check:repo`. - A `setTimeout` delay in the mock did not reproduce it: the sheet rendered before the delay ended. A busy-wait starves the event loop the way load does. Local gates at 4e6b38d: Prettier and ESLint pass on the changed file; the root build passes; the core UI suite passes, and the adopters file passes alone in 5 runs of 5; the node project passes except two process-timing cases in `packages/cli/foundation/release/cache.test.mjs`, which pass when that file runs alone (34 of 34), on this head and on main.
Why
Selector and MultiSelector tests sometimes fail on a busy machine, on pull requests that don't touch these components. In one run, opening a bottom sheet took 1,285 ms against the test's 1-second wait.
What led to it
Found while working on BottomSheet's keyboard handling (part of bringing Astryx's touch behavior to parity with iOS's UIKit, text entry first), and other pull requests' runs kept failing here too. These components load their bottom sheet's code only when it's first needed. The first test in each file that opens a sheet paid for that load inside its 1-second wait for the sheet to appear, and on a loaded machine the load alone could use up the wait.
Options and tradeoffs
Why this choice
The last one fixes the tests without touching product code or timeouts. Loading the module isn't what these tests check, so each file waits for it once, up front.
How to check it
Evidence
beforeAlleach that loads the sheet module; nothing else changes.cache.test.mjslock tests that fail on this machine without the change too (fix(cli): a crashed run's release install is recognized by the Node it ran on, whatever its name #8520).