Repository navigation
test(ui): wait 10 s for a query that waits, not Testing Library's 1 s - #671
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:Workspace.test.tsx, "holds it back on a card's page until the learner chooses"StudioWorkspace.test.tsx, "holds a linked deck's pictures back on its card screen until the learner chooses their host"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 offindBy…andwaitForhad 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 checkpasses.After this merges, requeue #666 and #670.
Refs: #666, #670