Skip to content

test(Item): wait for the swipe layer's module, not a one-second window - #8352

Closed
vjeux wants to merge 4 commits into
meta:mainfrom
vjeux:uikit/f3-item-swipe-wait
Closed

vjeux wants to merge 4 commits into
meta:mainfrom
vjeux:uikit/f3-item-swipe-wait

Conversation

@vjeux

@vjeux vjeux commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review only this PR's change: vjeux/astryx@a00afee...8284b8b

Why

On a busy machine, all 26 swipeActions tests in Item.test.tsx fail together, on main too. The suite's warm-up waited for the lazily loaded swipe layer inside waitFor's one-second window; when the module's first load takes longer, the warm-up times out and the whole block fails. That breaks parallel runs of the core suite, in CI shards and locally, on changes that have nothing to do with Item.

What led to it

We run the full UI suite many times in parallel while bringing touch components to native behavior, and Item's swipe tests kept failing on unrelated changes.

Options and tradeoffs

  • Raise waitFor's timeout: a bigger window, still a race against the machine's speed.
  • Load the swipe layer eagerly: changes the product, more code on every page, to fix a test.
  • Wait for the module itself (this pull request): await import('./ItemSwipeLayer') inside act, then check synchronously. The lazy component keeps the resolved module, so every row below renders as before.

Why this choice

The test waits on what it needs, the module being loaded, not on a clock, and no product code changes. Item.swipeLayer.test.tsx, and the one List.test.tsx case that waited on the layer the same way, get the same fix.

How to check it

  1. pnpm exec vitest run packages/core/src/Item/Item.test.tsx packages/core/src/Item/Item.swipeLayer.test.tsx packages/core/src/List/List.test.tsx: all pass.
  2. To see the old failure, slow the layer's first load: mock ./ItemSwipeLayer with a factory that waits 1.5 s and returns the real module. On main, the warm-up times out and the 26 swipe tests never run. With this change all 80 pass, even with a 31 s delay.
  3. The whole UI project on 8 cores with 64 workers: main skips the 26; this branch passes them.

Evidence

  • Test files only; no product source changes.

The swipe layer loads lazily, and the swipeActions tests waited for its
first render with `waitFor`'s one-second window. On a busy machine the
module's first load takes longer: the warm-up `beforeAll` timed out and
every swipeActions test failed (red under parallel full-core runs, on main
too).

Both tests now await the module itself inside `act`, however long the load
takes, then check the panel synchronously. With the first load slowed to
1.5 s, the old suite fails (the 26 swipeActions tests never run) and the new
one passes.
@vercel

vercel Bot commented Oct 25, 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 27, 2026 6:17am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 27, 2026, 7:08 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 25, 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.

Recommended for approval: both tests now wait for the swipe layer's module instead of a one-second waitFor window, keep every existing assertion, and change no product code. With the module's first load slowed to 1.5 s the old warm-up fails while the new one passes, and the new checks still fail when the layer renders no panel. Nothing further is needed from you.

[Automated review]

@github-actions

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

Item (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 284B 284B 0B
Lines of Code 1372 1372 -
Complexity Very High Very High (121) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/Item 11.4KB 11.4KB 0B 4.7KB 4.7KB 0B
core/List 6.7KB 6.7KB 0B 3.4KB 3.4KB 0B
core/ListItem 53.5KB 53.5KB 0B 10.5KB 10.5KB 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 34.6KB 34.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


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

…a timed hook

The swipeActions warm-up awaited the lazy swipe layer's first load inside beforeAll, which the hook timeout bounds; on a busy machine that load (the gesture system with it) can outlast it, and the describe block's 26 tests are skipped. The module is now imported at the top of the file, during collection, which no timeout bounds; the warm-up resolves from the cache. Item.swipeLayer.test.tsx still covers the lazy load itself.

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

Recommended for approval: both Item test files now wait for the swipe layer's module instead of a one-second waitFor window, keep every existing assertion, and change no product code. With the module's first load slowed to 1.5 s the old warm-up fails while the new one passes, and the new checks still fail when the layer renders no panel. The red pr-interaction and test checks are unrelated to this change: this branch predates playwright.interaction.config.ts on main, so merging main should clear them.

[Automated review]

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

Recommended for approval: both Item test files now wait for the swipe layer's module instead of a one-second waitFor window, keep every existing assertion, and change no product code. With the module's first load slowed to 1.5 s the old suites fail while the new ones pass, and the new checks still fail when the layer renders no panel. One optional follow-up outside this pull request: List.test.tsx still waits for the same swipe panel with waitFor and fails the same way when the first load is slow.

[Automated review]

List's swipeActions case waited for the lazily loaded ItemSwipeLayer's panel inside waitFor's one-second default, which a busy machine outlasts on the module's first load. Like Item's tests, the file now imports the layer while it is collected, which no timeout bounds, and the case renders its panel from that cached module.

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

Recommended for approval: the three swipe tests now wait for the swipe layer's module instead of a one-second waitFor window, keep every existing assertion, and change no product code. With the module's first load slowed to 1.5 s the old tests fail while the new ones pass, and the new checks still fail when the layer renders no panel. Nothing further is needed from you.

[Automated review]

@vjeux
vjeux marked this pull request as draft October 29, 2026 22:35
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.
@vjeux

vjeux commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #9447, which carries the same fix for these three swipe sites plus DropdownMenu ×2 and Resizable.

@vjeux vjeux closed this Nov 2, 2026
@vjeux
vjeux deleted the uikit/f3-item-swipe-wait branch November 2, 2026 10:59

This branch was successfully deployed

1 active deployment
Preview — 8284b8b9 Deployed Oct 27, 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