Skip to content

test(Selector, MultiSelector): load the lazy BottomSheet before the sheet tests - #9082

Merged
cixzhang merged 1 commit into
mainfrom
test/multiselector-sheet-lazy-wait
Oct 31, 2026
Merged

cixzhang merged 1 commit into
mainfrom
test/multiselector-sheet-lazy-wait

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Maintainer impact

"uses a bottom sheet and stays open while toggling options" (MultiSelector) and "uses a bottom sheet and closes after a selection when requested" (Selector) fail at random on loaded CI runners with Unable to find role="dialog" and name "Fruit". They block unrelated pull requests: #9018 failed test-ui (4/4) on two attempts, and #9017 and #9028 hit the same miss. On a busy local machine (load average ~70), the MultiSelector file failed 3 of 3 runs on main.

Intended invariant

The sheet tests keep asserting the same behavior: the bottom-sheet presentation opens a dialog named by the label, and toggling or selecting keeps or closes it as before. Only the time to first load the BottomSheet module leaves the measured window.

Change

Both test files import ../BottomSheet/BottomSheet once in a file-level beforeAll. SelectorBottomSheet renders BottomSheet through React.lazy. The first import() in a test file transforms the whole BottomSheet module tree, which under load takes longer than findByRole's 1 s default, so the first sheet test in each file timed out before the dialog existed. With the module already loaded, lazy() resolves from the module cache and each sheet test waits only for the open itself. This removes the cause instead of raising the query timeout. No product code changes.

The original sheet tests come from #5395 (rubyycheung).

Evidence

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm vitest run packages/core/src/MultiSelector/MultiSelector.test.tsx packages/core/src/Selector/Selector.test.tsx (3× under load).

…heet tests

The bottom-sheet presentation renders BottomSheet through React.lazy; its first
import transforms the BottomSheet module tree, which on a loaded runner takes
longer than findByRole's 1 s wait, so the first sheet test in each file timed
out before the dialog existed. Import the module once in beforeAll so lazy()
resolves from the module cache.
@vercel

vercel Bot commented Oct 31, 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 31, 2026 12:15am UTC

Request Review

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

astracat-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 31, 2026, 12:20 AM UTC

@github-actions

github-actions Bot commented Oct 31, 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

Choose a reason for hiding this comment

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

Looks good to merge: preloading ../BottomSheet/BottomSheet in a file-level beforeAll takes the lazy sheet's first module load out of the first sheet test's 1 s findByRole window without changing any assertion, the same pattern PopoverPresentation.test.tsx already uses. Both test files pass on this head, and the first sheet test in each now runs roughly a second faster than on main. One optional tidy-up: the existing // Mock showPopover and hidePopover… comment now sits above the new block instead of the beforeEach it describes (see the inline note).

[Automated review]

}

// Mock showPopover and hidePopover methods since they're not implemented in jsdom
// The bottom-sheet presentation renders BottomSheet through React.lazy. Its

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit (non-blocking): this block landed between the existing // Mock showPopover and hidePopover methods… comment on line 75 and the beforeEach it describes, so that comment now reads as if it labels the BottomSheet preload. Moving the new comment and beforeAll above line 75 keeps each comment with its code. Same in Selector.test.tsx at lines 71-72.

@cixzhang
cixzhang merged commit 040393b into main Oct 31, 2026
143 of 147 checks passed
@github-actions
github-actions Bot deleted the test/multiselector-sheet-lazy-wait branch October 31, 2026 06:09

This branch was successfully deployed

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

Labels

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.

1 participant