Skip to content

test: settle the ChiefOfStaff page mount before querying it (#5857) - #6061

Merged
atomantic merged 1 commit into
mainfrom
claim/issue-5857
Sep 3, 2026
Merged

test: settle the ChiefOfStaff page mount before querying it (#5857)#6061
atomantic merged 1 commit into
mainfrom
claim/issue-5857

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

client/src/pages/ChiefOfStaff.test.jsx passed in isolation but flaked under a full client run, 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.

Fixed the settle, not the budget:

  • Every test that reaches into a tab's contents now mounts through one renderSettledAt(tab) helper that waits for the page's own settle signal — the loading branch's role="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 the MemoryRouter/Routes block that had accumulated across describes.
  • The two loading-skeleton guards keep mounting bare: they hold a core read open on purpose so the busy branch is what renders.
  • asyncUtilTimeout (3s, QuotaBurn retry-budget test flakes ~1 in 3 on testing-library's 1000ms default timeout #3474), the two-worker client cap, and testTimeout are 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: one onEvaluate call 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...HEAD touches only the two test files; client/src/test/setup.js and client/vitest.config.js are unchanged.

Follow-up filed as #6060 for an unrelated bug hit while running the configured local reviewer.

Closes #5857

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
@atomantic
atomantic merged commit 77acfd8 into main Sep 3, 2026
7 checks passed
@atomantic
atomantic deleted the claim/issue-5857 branch September 3, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChiefOfStaff page tests flake under full-suite load by querying an unsettled page mount

1 participant