Skip to content

test: fix flaky BrowseTab Save-button query racing the Edit transition - #6109

Merged
atomantic merged 1 commit into
atomantic:mainfrom
Bryandero98:fix/browsetab-flaky-save-query
Sep 3, 2026
Merged

test: fix flaky BrowseTab Save-button query racing the Edit transition#6109
atomantic merged 1 commit into
atomantic:mainfrom
Bryandero98:fix/browsetab-flaky-save-query

Conversation

@Bryandero98

Copy link
Copy Markdown
Contributor

Summary

  • openEditor and clickSave in BrowseTab.test.jsx used synchronous getByRole/getByText queries immediately after a fireEvent.click that triggers an async state transition (Edit → editable form with a Save button).
  • Under full-suite CPU contention (multiple jsdom workers) this occasionally ran before React committed the new state, even though it reliably passed in isolation — a classic React Testing Library race, not a bug in the component itself (BrowseTab.jsx's Edit→Save transition is a plain synchronous setState).
  • Both helpers now await screen.findByRole(...) instead of a bare getBy*, so the query itself waits for the transition to settle.

Test plan

  • client/src/components/wiki/tabs/BrowseTab.test.jsx — 8/8, re-run 5x for stability, plus the whole wiki/ directory together

🤖 Generated with Claude Code

atomantic#6051)

openEditor and clickSave used synchronous getByRole/getByText queries right
after a fireEvent.click that triggers an async state transition. Under full-
suite CPU contention that occasionally ran before React committed the new
state, even though it reliably passed in isolation. Both helpers now await
findByRole so the query itself waits for the transition to settle instead of
racing it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@atomantic atomantic left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against the live schema/behavior — change is correct, focused, and covered by tests. Approving.

@atomantic
atomantic merged commit ce46386 into atomantic:main Sep 3, 2026
7 checks passed
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.

2 participants