From fde80e898f44dabe86db5045fb838ba8f6ed75c6 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 8 Sep 2026 20:06:55 +0000 Subject: [PATCH] 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 --- ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx b/ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx index 7b3153f6e13..6b8678a6520 100644 --- a/ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx +++ b/ui/litellm-dashboard/src/components/TeamSSOSettings.test.tsx @@ -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(); + }); }); });