test(ui): wait for save to finish so TeamSSOSettings state updates don't leak past teardown

The 'should disable cancel button while saving' test mocks the save API with
setTimeout(100) but never waits for the promise to resolve. When the timer
fires after the test tears down, setSaving(false) tries to schedule a React
update on an unmounted root, and resolveUpdatePriority reads window on a
dead JSDOM. Vitest surfaces this as 'ReferenceError: window is not defined'
and fails the whole UI Unit Tests job intermittently.

Wait for the Edit Settings button to reappear after Save Changes so the
mocked save resolves before the test exits.

Co-authored-by: Krrish Dholakia <krrish-berri-2@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-09-08 20:06:55 +00:00
parent d36e032241
commit fde80e898f
No known key found for this signature in database

View file

@ -567,5 +567,9 @@ describe("TeamSSOSettings", () => {
await userEvent.click(screen.getByRole("button", { name: /Save Changes/i }));
expect(screen.getByRole("button", { name: /Cancel/i })).toBeDisabled();
await waitFor(() => {
expect(screen.getByRole("button", { name: /Edit Settings/i })).toBeInTheDocument();
});
});
});