Skip to content

Deflake MatrixChat-test#31383

Merged
richvdh merged 1 commit intodevelopfrom
rav/deflake_matrix_chat
Dec 2, 2025
Merged

Deflake MatrixChat-test#31383
richvdh merged 1 commit intodevelopfrom
rav/deflake_matrix_chat

Conversation

@richvdh
Copy link
Copy Markdown
Member

@richvdh richvdh commented Dec 1, 2025

Add a workaround for the fact that MatrixChat attempts to use React state for the state of a state machine: a small sleep to let the state settle.

As a result, it turns out we may not see the "Syncing..." state, and in general waitForSyncAndLoad doesn't seem to be doing anything useful.

I think this fixes #30690.

Add a workaround for the fact that MatrixChat attempts to use React state for
the state of a state machine: a small `sleep` to let the state settle.

As a result, it turns out we may not see the "Syncing..." state, and in general
`waitForSyncAndLoad` doesn't seem to be doing anything useful.
@richvdh richvdh requested a review from a team as a code owner December 1, 2025 18:38
@richvdh richvdh requested review from dbkr and florianduros December 1, 2025 18:38
@richvdh richvdh added the T-Task Tasks for the team like planning label Dec 1, 2025
// we are logged in, but are still waiting for the /sync to complete
await screen.findByText("Syncing…");
// initial sync
await act(() => client.emit(ClientEvent.Sync, SyncState.Prepared, null));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this "client.emit" already happens in the startClient mock above, so I think (now that it happens after an appropriate delay), this is redundant.

Further, the fact that the ClientEvent.Sync does happen after a delay (and does what it should) means that the test never gets the chance to see the "Syncing..." check, so that had to go.

Generally, all these flushPromises look like a fudge, and we're much better off just doing an await screen.findBy... to look for the thing we actually want.

Comment on lines +1323 to +1324
// wait for logged in view to load
await screen.findByLabelText("User menu");
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this replaces the findByLabelText that used to be in the withoutSecuritySetup branch of waitForSyncAndLoad

expect(screen.getByRole("heading", { name: "Welcome Ernie" })).toBeInTheDocument();
});

describe("when server supports cross signing and user does not have cross signing setup", () => {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(servers always support cross-signing nowadays)

@richvdh richvdh added this pull request to the merge queue Dec 2, 2025
Merged via the queue into develop with commit 57fd3c4 Dec 2, 2025
47 checks passed
@richvdh richvdh deleted the rav/deflake_matrix_chat branch December 2, 2025 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Task Tasks for the team like planning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky jest test: <MatrixChat /> › login via key/pass › post login setup › should go straight to logged in view when crypto is not enabled

2 participants