Skip to content

test(ui): wait 10 s for a query that waits, not Testing Library's 1 s - #671

Merged
ixuz merged 1 commit into
mainfrom
fix/card-pictures-test-flake
Nov 8, 2026
Merged

ixuz merged 1 commit into
mainfrom
fix/card-pictures-test-flake

Conversation

@ixuz

@ixuz ixuz commented Nov 8, 2026

Copy link
Copy Markdown
Member

What and why

Two tests failed in the merge queue for pull requests that don't touch the UI. In each, the "Show pictures from author.example" button wasn't found within findByRole's 1 s:

This isn't a race; the button always comes. It never failed locally: not under CPU load, not with coverage on, and not with random delays on every use case (60 runs). The button is just late. A card screen shows it only after five reads in a row: the instances, the deck, its cards, whether the deck is in the learner's pod, then the library's index. With every read slowed to 200 ms, the card's heading came at about 630 ms and the button at about 840 ms.

CI takes some tests fifty times as long as a laptop does, so a test may already take 60 s (vitest.shared.ts). The 1 s wait of findBy… and waitFor had no such allowance.

Changes:

  • packages/ui/src/test/setup.ts: configure({ asyncUtilTimeout: 10_000 }). The Studio and web app test setups import this file, so it covers all three packages. A query that never matches still fails, just later.
  • apps/studio/src/ui/StudioWorkspace.test.tsx: removed two { timeout: 3000 } waits for a saved draft, which would now shorten the wait.
  • docs/testing.md: documents the 10 s wait next to the 60 s test timeout.

npm run check passes.

After this merges, requeue #666 and #670.

Refs: #666, #670

Two tests of a linked deck's pictures failed in the merge queue for pull
requests that change nothing in the UI: on the learner's card page
(#666) and on the Studio's card screen (#670), the "Show pictures from
author.example" button was not there within findByRole's 1 s. Neither
fails on a laptop, under CPU load, with coverage on, or with random
delays on every use case: the button always comes. It comes late,
though. A card screen shows the button only after the instances, the
deck and its cards are read, then whether the deck is in the learner's
pod, then the library's index. With every read slowed to 200 ms, the
card's heading came at about 630 ms and the button at about 840 ms,
the closest of these tests to 1 s.

CI takes some tests fifty times as long as a laptop does, which is why
a test may take 60 s (vitest.shared.ts). The 1 s wait of findBy and
waitFor had no such allowance, so any screen that reads its data in a
few steps could fail the same way. The UI's test setup, which the
Studio's and the web app's import, now sets it to 10 s. A query that
never matches still fails, only later. The Studio's two waits of 3 s
for a saved draft would now shorten the wait, so they go.

Refs: #666, #670
@ixuz ixuz added the testing Test suites, journeys and flaky tests label Nov 8, 2026
@ixuz
ixuz enabled auto-merge November 8, 2026 18:04
@ixuz
ixuz added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit eb1e354 Nov 8, 2026
51 checks passed
@ixuz
ixuz deleted the fix/card-pictures-test-flake branch November 8, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Test suites, journeys and flaky tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant