Skip to content

test(Selector, MultiSelector): wait for the on-demand sheet module before the first open - #8642

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c08-sheet-preload-tests
Oct 31, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c08-sheet-preload-tests

Conversation

@vjeux

@vjeux vjeux commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Raise the timeout: hides the cause, and a slower machine would still fail.
  • Load the sheet eagerly in the components: changes product code to fix a test.
  • Load the sheet's code once per test file, before the tests run: each open then waits only for the open.

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

  1. Make the sheet's code load slowly: in a test, mock its import to wait 1.2 seconds before returning the real module.
  2. Run the Selector and MultiSelector tests. Expected: on main, five sheet tests time out waiting for the sheet; with this change, all pass.
  3. Remove the delay and run them again. Expected: all pass.

Evidence

  • Five test files gain one beforeAll each that loads the sheet module; nothing else changes.
  • With the 1.2-second delay: 5 failures on main, none with this change (443 tests in the five files).
  • Local gates at 780fce6 (one commit on main): the build, typecheck and repo checks pass; Selector's and MultiSelector's test folders pass (519 tests); the core UI suite passes (16,446 tests); the node suite passes except two cache.test.mjs lock 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).

@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 30, 2026 9:42pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 30, 2026, 9:58 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

MultiSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 273B 273B 0B
Lines of Code 2680 2680 -
Complexity Very High Very High (344) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/MultiSelector 74.3KB 74.3KB 0B 14.8KB 14.8KB 0B
core/Selector 78.3KB 78.3KB 0B 15.3KB 15.3KB 0B
core/SelectorOption 15.6KB 15.6KB 0B 5.3KB 5.3KB 0B

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 Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 35.6KB 35.6KB 0B

Accessibility Audit

Status: The accessibility audit did not run on this pull request. It runs after merges to main and before each release; pull requests that touch components run it with the ci:heavy-lanes label.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@cixzhang

Copy link
Copy Markdown
Contributor

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.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Oct 31, 2026
@cixzhang
cixzhang marked this pull request as ready for review October 31, 2026 00:56
@cixzhang
cixzhang merged commit f77252d into meta:main Oct 31, 2026
140 of 143 checks passed
@vjeux
vjeux deleted the uikit/c08-sheet-preload-tests branch October 31, 2026 01:31
cixzhang pushed a commit that referenced this pull request Oct 31, 2026
…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.

This branch was successfully deployed

1 active deployment
Preview — 780fce6c Deployed Oct 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants