test: settle the ChiefOfStaff page mount before querying it (#5857) - #6061
Merged
Conversation
The ChiefOfStaff page suite passed in isolation but flaked under a full
`npm test`, timing out in `findByRole('button', { name: /Force Evaluate/i })`.
The page fans out several mocked reads on mount and each resolution is its own
macrotask, so a bare `findBy*` straight after render polls blind through that
whole chain — on a contended worker it ran past Testing Library's async budget
before the config panel had rendered.
Wait on the settle signal the page already publishes instead of buying more
budget: the loading branch renders a `role="status"` busy region labelled
"Loading Chief of Staff". Every test that reaches into a tab's contents now
mounts through one `renderSettledAt(tab)` helper that waits for that region to
clear, so the following query spends its budget on a single render. The
loading-skeleton guards keep mounting bare — they hold a core read open on
purpose so the busy branch is what renders.
`asyncUtilTimeout` (3s, #3474), the two-worker client cap, and `testTimeout`
are all left untouched; raising them was already spent on this file twice.
Also pins the Force Evaluate button's own contract in ConfigTab's suite, where
it renders directly with no page mount to wait on: one `onEvaluate` call per
click, the explanatory title, no API or toast of its own, and availability
while the settings editor is open. The page suite keeps the half that is
genuinely page state — the toast and status-bubble result of the handler the
button invokes.
Closes #5857
Claude-Session: https://claude.ai/code/session_01YHCY5GnrNp66Gprb9JHYvi
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.
Summary
client/src/pages/ChiefOfStaff.test.jsxpassed in isolation but flaked under a full client run, timing out infindByRole('button', { name: /Force Evaluate/i }). The page fans out several mocked reads on mount and each resolution is its own macrotask, so a barefindBy*straight after render polls blind through that whole chain — on a contended worker it ran past Testing Library's async budget before the config panel had rendered.Fixed the settle, not the budget:
renderSettledAt(tab)helper that waits for the page's own settle signal — the loading branch'srole="status"busy region labelled "Loading Chief of Staff" — to clear. The following query then spends its budget on a single render instead of the entire mount chain. This also collapses four copies of theMemoryRouter/Routesblock that had accumulated across describes.asyncUtilTimeout(3s, QuotaBurn retry-budget test flakes ~1 in 3 on testing-library's 1000ms default timeout #3474), the two-worker client cap, andtestTimeoutare all untouched — raising them was already spent on this file twice and a third bump would slow every genuinely-hung assertion in the suite.The Force Evaluate button's own contract moved down to
ConfigTab.test.jsx, where it renders directly with no page mount to wait on: oneonEvaluatecall per click, the explanatory title, no API call or toast of its own, and availability while the settings editor is open. The page suite keeps the half that is genuinely page state — the toast and status-bubble result of the handler the button invokes.Nothing was dropped in the move: assertions across the two files went from 141 to 148.
Test plan
cd client && npx vitest run— green on three consecutive full runs (831 passed | 1 skipped).npx vitest run src/pages/ChiefOfStaff.test.jsx src/components/cos/tabs/ConfigTab.test.jsx— 49 passed (was 47).git diff origin/main...HEADtouches only the two test files;client/src/test/setup.jsandclient/vitest.config.jsare unchanged.Follow-up filed as #6060 for an unrelated bug hit while running the configured local reviewer.
Closes #5857