Skip to content

test: module loads are awaited, not raced against test clocks - #9447

Merged
cixzhang merged 4 commits into
meta:mainfrom
vjeux:uikit/c12-swipe-layer-load-wait
Nov 3, 2026
Merged

cixzhang merged 4 commits into
meta:mainfrom
vjeux:uikit/c12-swipe-layer-load-wait

Conversation

@vjeux

@vjeux vjeux commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

On a loaded machine, some Core tests fail with nothing wrong in the component: each races a module load against a clock. A cold load (Vite's transform of a module graph on first import) can take longer than any fixed wait when the machine is busy, so a full ui run under load fails tests that pass alone.

  • Item's swipe layer. Item loads its swipe layer with import() the first time a row has swipe actions. Three tests polled for the row's swipe panel with waitFor's one-second default:
    • List's "passes swipeActions and swipeBehavior through to the row unchanged";
    • Item.swipeLayer.test.tsx's "renders the swipe layer into the root of a row with swipe actions";
    • Item.test.tsx's swipeActions setup. When that beforeAll times out, all 27 swipe tests in the file are skipped with it.
  • DropdownMenu's first open (DropdownMenuSheetFirstOpen.test.tsx) polled up to 15 s, under a 20 s test limit, for both sheet modules to load while the menu is closed.

Two other load races of the same kind are fixed by their own open drafts: #8353 (DropdownMenu's on-demand sheet, DropdownMenuLazySheet.test.tsx) and #8471 (Resizable's root re-export check).

Intended invariant

Each test checks what it checked before, and only the waits change: a test waits for the module load itself, never for a clock that bounds it. No product code changes.

Change

  • Item's swipe layer: swipeLayerLoaded() (Item/__tests__/swipeLayerLoaded.ts). It awaits the module the row's import() loads, inside act, which then renders what the load let through, so the panels are in the DOM when it resolves. The three tests use it and read the panel directly afterwards.
    • Item.swipeLayer.test.tsx's mock of the layer module now holds its load until the test releases it. The test checks that nothing is drawn before the release, then that the panel is there once swipeLayerLoaded() resolves.
  • DropdownMenu's first open: the check waits for the dropdown's own request of each module (a signal the module mock fires), then the loads themselves, then one task boundary, after which every microtask the loads let through has run. It still checks that the first open renders the rows in the same commit. The 15 s waitFor and the 20 s test override are gone; a dropdown that never requests the rows at rest still fails, at the test's limit.

Evidence

Red-first seams: local copies of each test file, three runs each.

Site Seam Before the change After the change
List, swipe pass-through swipe layer module loads 1.5 s late 3/3 fail (null panel) 3/3 pass
Item.swipeLayer, layer render the layer's load comes 1.5 s late 3/3 fail (null panel) 3/3 pass
Item.swipeLayer, mutant one act flush instead of swipeLayerLoaded(), load 1.5 s late n/a 3/3 fail
Item.test, swipeActions setup swipe layer module loads 1.5 s late 3/3 fail (setup fails, 27 swipe tests skipped) 3/3 pass (27 swipe tests run)
DropdownMenu, first open the sheet's module loads 16 s late 3/3 fail (only the rows had loaded) 3/3 pass
DropdownMenu, first open the dropdown skips the rows' preload at rest 3/3 fail still fails, 2/2 (at the test's 30 s limit)

Under load: the four test files ran ×10 on two pinned cores with two busy loops beside them (4 workers): 1,730 test runs, 0 failures. The slowest test, the first-open check with its cold load, took at most 21.4 s.

  • Product behavior unchanged: only test files and a test helper change. No changeset, since nothing ships.

Supersedes

Supersedes #8352

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

Local gates at 357600c:

  • Prettier and strict ESLint on the five files;
  • the core typecheck;
  • pnpm check:repo;
  • the four test files ×10 on two pinned cores with two busy loops beside them (4 workers): 1,730/1,730 passed;
  • pnpm test:ui: 17,826 tests passed.

…second

List's "passes swipeActions and swipeBehavior through to the row
unchanged", Item.swipeLayer's "renders the swipe layer into the root of a
row with swipe actions" and Item.test's swipeActions setup polled for the
row's swipe panel with waitFor's one-second default. The panel arrives
with the swipe layer Item loads with import() the first time a row has
swipe actions; on a loaded machine that load can take longer than the
second, and the test read null (or, for the setup, skipped every swipe
test in the file).

swipeLayerLoaded() awaits the module the row's import loads, inside act,
which then renders what the load let through, so the panels are in the
DOM when it resolves, however long the load took. Item.swipeLayer's mock
of the layer module now also loads it 1.5 s late, and its test checks
that nothing is drawn before the load and the panel is there after it.
@vercel

vercel Bot commented Nov 2, 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 Nov 2, 2026 11:03pm UTC

Request Review

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

astracat-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 2, 2026, 11:10 PM UTC

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 357600c

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
ContextMenuItem 57.2 kB (0) · 9.9 kB CSS (0) — — · — · —
DropdownMenu 77.5 kB (0) · 15.4 kB CSS (0) — ✓ · ✓ · ✓
DropdownMenuCheckboxItem 18.2 kB (0) · 5.9 kB CSS (0) — ✓ · ✓ · ✓
9 more components
Component Size LoC Visual · A11y · RTL
DropdownMenuDivider 5.2 kB (0) · 548 B CSS (0) — ✓ · ✓ · —
DropdownMenuGroup 6.2 kB (0) · 3.4 kB CSS (0) — ✓ · ✓ · —
DropdownMenuItem 17.4 kB (0) · 5.5 kB CSS (0) — ✓ · ✓ · —
DropdownMenuRadioGroup 6.1 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · —
DropdownMenuRadioItem 18.2 kB (0) · 5.9 kB CSS (0) — ✓ · ✓ · —
DropdownMenuSubMenu 62.7 kB (0) · 9.9 kB CSS (0) — ✓ · ✓ · ✓
Item · Storybook 13.2 kB (0) · 4.9 kB CSS (0) 1,606 (0) ✓ · ✓ · —
List 5.4 kB (0) · 435 B CSS (0) — ✓ · ✓ · —
ListItem 57.7 kB (0) · 11.0 kB CSS (0) — ✓ · ✓ · ✓

Package size: no published package changed; no new dependencies.

API changes: none in this pull request

Committed API report behind this build: core 4 rows; run pnpm api:report.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | 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.

This looks ready to approve. The three swipe tests now wait for the swipe layer's module instead of a one-second poll, and with the layer's load delayed 1.5 s the old waits fail and the new ones pass. No product code changes, and nothing else needs to change before the pull request is marked ready.

[Automated review]

…ainst test clocks

DropdownMenuLazySheet imported DropdownMenu under an explicit 10 s hook
timeout, its detector for an eager sheet import (the held sheet would hang
the import), so a cold load slower than 10 s failed it; and after
releasing the held sheet it polled 15 s for the first row's focus. A sheet
module requested while DropdownMenu itself loads now fails at once, naming
the eager import, so the import's completion is the signal and the 10 s
override is gone. After the release the test awaits the sheet modules
inside act, then one animation frame: the dropdown focuses the first row a
frame after the rows appear, and the test's frame runs after that one.

Resizable/utils' root re-export check ran import('@astryxdesign/core'),
every module in Core, inside the test, against its 30 s limit. The root
entry and the Resizable/utils subpath are now static imports, loaded with
the file, which no test clock bounds.
@vjeux vjeux changed the title test(Item, List): swipe tests wait for the swipe layer's load, not a second test: module loads are awaited, not raced against test clocks Nov 2, 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.

This looks ready to approve: the DropdownMenu and Resizable tests now wait for the module load itself, and with the loads delayed, the old waits fail and the new ones pass. No product code changes, and nothing needs to change before the pull request is marked ready. As an optional follow-up, DropdownMenuSheetFirstOpen.test.tsx still polls 15 s for the same sheet modules and could use the same approach.

[Automated review]

…ts and loads, not 15 s

DropdownMenuSheetFirstOpen polled up to 15 s (under a 20 s test limit)
for both sheet modules to load at rest, racing a cold load against that
clock. It now waits for the dropdown's own request of each module (a
signal the module mock fires), then for the loads themselves, then a task
boundary, after which every microtask the loads let through has run; the
first open still has to render the rows in the same commit. A dropdown
that never requests the rows at rest still fails, at the test's limit.

@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.

This looks ready to approve: the DropdownMenu first-open test now waits for the dropdown's own module requests and the loads instead of a 15 s poll, and with the sheet delayed 16 s the old wait fails while the new one passes. The new wait still fails when the rows' preload at rest is removed, so the check keeps its teeth. No product code changes, and nothing needs to change before the pull request is marked ready.

[Automated review]

…t releases it, and comments run in short sentences

The DropdownMenuLazySheet and Resizable changes leave this branch: open drafts carry them. Item.swipeLayer's mock waited 1.5 s before it loaded the layer. It now waits until the test releases it, so the check is exact and adds no real time.

@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.

This looks ready to approve. The three swipe tests and the DropdownMenu first-open test now wait for the module load itself instead of a fixed clock, and with each load delayed the old waits fail while the new ones pass. No product code changes, and nothing needs to change before the pull request is marked ready. One trade-off, already noted in the description: a dropdown that stops preloading its rows now fails the first-open test as a 30 s timeout rather than naming the missing module.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 3, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 01:09
@cixzhang
cixzhang merged commit b53bec6 into meta:main Nov 3, 2026
107 checks passed
@vjeux
vjeux deleted the uikit/c12-swipe-layer-load-wait branch November 3, 2026 04:18

This branch was successfully deployed

1 active deployment
Preview — 357600ce Deployed Nov 2, 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