Skip to content

wiki BrowseTab tests flake under full-suite load by clicking Save before the note editor settles #6051

Description

@atomantic

Problem

client/src/components/wiki/tabs/BrowseTab.test.jsx fails intermittently in a full cd client && npm test run and passes every time in isolation. Observed once in a run of 832 files (1 failed | 830 passed), then green on an immediate re-run of the identical tree.

The failure is a Testing Library "unable to find an element" throw out of the suite's own helper, which queries the Save control the moment the tab mounts:

const clickSave = async () => {
  const before = api.updateNote.mock.calls.length;
  fireEvent.click(screen.getByRole('button', { name: /Save/ }));   // <- throws here
  await waitFor(() => expect(api.updateNote.mock.calls.length).toBe(before + 1));
};

getByRole is synchronous, so under contention (the client suite runs two jsdom workers) the click happens before the editor has finished mounting and the button exists. The dumped DOM in the failure shows the surrounding icon markup rendered but not the control the query wants.

This is the same class as #5857 (ChiefOfStaff page tests flake under full-suite load by querying an unsettled page mount), but a different file — that issue names only the ChiefOfStaff suite, so this one is not covered by it.

Work

Make the helper wait for the control instead of assuming it is present: await screen.findByRole('button', { name: /Save/ }) before the fireEvent.click, and give any other synchronous first-query in the file the same treatment. Do not paper over it with a bare timeout.

While in the file, check whether the mount that precedes clickSave is itself awaited — an unawaited render is the usual upstream cause, and fixing it there is better than making each query async.

Acceptance criteria

  • No synchronous getBy* query in BrowseTab.test.jsx runs against a mount that has not settled.
  • The suite still passes in isolation and in a full cd client && npm test.
  • Assertions are otherwise unchanged — this is a flake fix, not a rewrite.

Files

  • client/src/components/wiki/tabs/BrowseTab.test.jsx

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:uiUI components and stylingbugSomething isn't workingeffort:lowEffort: lowmodel:lightModel size: lightplanTracked by /do:replanplanner:opus-5Plan authored by the opus-5 modelseverity:lowtestsTest suite / test infrastructure

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions