Repository navigation
test: module loads are awaited, not raced against test clocks - #9447
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
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.
Itemloads its swipe layer withimport()the first time a row has swipe actions. Three tests polled for the row's swipe panel withwaitFor's one-second default:Item.swipeLayer.test.tsx's "renders the swipe layer into the root of a row with swipe actions";Item.test.tsx'sswipeActionssetup. When thatbeforeAlltimes out, all 27 swipe tests in the file are skipped with it.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
swipeLayerLoaded()(Item/__tests__/swipeLayerLoaded.ts). It awaits the module the row'simport()loads, insideact, 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 onceswipeLayerLoaded()resolves.waitForand 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.
nullpanel)Item.swipeLayer, layer rendernullpanel)Item.swipeLayer, mutantactflush instead ofswipeLayerLoaded(), load 1.5 s lateItem.test,swipeActionssetupUnder 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.
Supersedes
Supersedes #8352
Scope
Testing
Local gates at 357600c:
pnpm check:repo;pnpm test:ui: 17,826 tests passed.