From b93fe4b93e5bff3c88331181ecef8a4b559d815b Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Wed, 26 Nov 2025 13:41:03 -0800 Subject: [PATCH 1/2] Add explicit timeout for flaky tests --- .../src/components/team/team_info.test.tsx | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/ui/litellm-dashboard/src/components/team/team_info.test.tsx b/ui/litellm-dashboard/src/components/team/team_info.test.tsx index 17041659cec..8ea1a1571a5 100644 --- a/ui/litellm-dashboard/src/components/team/team_info.test.tsx +++ b/ui/litellm-dashboard/src/components/team/team_info.test.tsx @@ -58,7 +58,7 @@ describe("TeamInfoView", () => { team_memberships: [], }); - vi.mocked(networking.getGuardrailsList).mockResolvedValue([]); + vi.mocked(networking.getGuardrailsList).mockResolvedValue({ guardrails: [] }); vi.mocked(networking.fetchMCPAccessGroups).mockResolvedValue([]); render( @@ -74,9 +74,13 @@ describe("TeamInfoView", () => { premiumUser={false} />, ); - await waitFor(() => { - expect(screen.queryByText("User ID")).not.toBeNull(); - }); + await waitFor( + () => { + expect(screen.queryByText("User ID")).not.toBeNull(); + }, + // This is a workaround to fix the flaky test issue. TODO: Remove this once we have a better solution. + { timeout: 10000 }, + ); }); it("should not show all-proxy-models option when user has no access to it", async () => { @@ -116,7 +120,7 @@ describe("TeamInfoView", () => { team_memberships: [], }); - vi.mocked(networking.getGuardrailsList).mockResolvedValue([]); + vi.mocked(networking.getGuardrailsList).mockResolvedValue({ guardrails: [] }); vi.mocked(networking.fetchMCPAccessGroups).mockResolvedValue([]); render( @@ -133,27 +137,39 @@ describe("TeamInfoView", () => { />, ); - await waitFor(() => { - expect(screen.getAllByText("Test Team")).not.toBeNull(); - }); + await waitFor( + () => { + expect(screen.getAllByText("Test Team")).not.toBeNull(); + }, + // This is a workaround to fix the flaky test issue. TODO: Remove this once we have a better solution. + { timeout: 10000 }, + ); const settingsTab = screen.getByRole("tab", { name: "Settings" }); act(() => { fireEvent.click(settingsTab); }); - await waitFor(() => { - expect(screen.getByText("Team Settings")).toBeInTheDocument(); - }); + await waitFor( + () => { + expect(screen.getByText("Team Settings")).toBeInTheDocument(); + }, + // This is a workaround to fix the flaky test issue. TODO: Remove this once we have a better solution. + { timeout: 10000 }, + ); const editButton = screen.getByRole("button", { name: "Edit Settings" }); act(() => { fireEvent.click(editButton); }); - await waitFor(() => { - expect(screen.getByLabelText("Models")).toBeInTheDocument(); - }); + await waitFor( + () => { + expect(screen.getByLabelText("Models")).toBeInTheDocument(); + }, + // This is a workaround to fix the flaky test issue. TODO: Remove this once we have a better solution. + { timeout: 10000 }, + ); const allProxyModelsOption = screen.queryByText("All Proxy Models"); expect(allProxyModelsOption).not.toBeInTheDocument(); From cfdade1a6f38ef74e0237af5913f6af1999a0b88 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Wed, 26 Nov 2025 13:53:31 -0800 Subject: [PATCH 2/2] Adding timeout it instead --- .../src/components/team/team_info.test.tsx | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/ui/litellm-dashboard/src/components/team/team_info.test.tsx b/ui/litellm-dashboard/src/components/team/team_info.test.tsx index 8ea1a1571a5..54362193350 100644 --- a/ui/litellm-dashboard/src/components/team/team_info.test.tsx +++ b/ui/litellm-dashboard/src/components/team/team_info.test.tsx @@ -137,41 +137,30 @@ describe("TeamInfoView", () => { />, ); - await waitFor( - () => { - expect(screen.getAllByText("Test Team")).not.toBeNull(); - }, - // This is a workaround to fix the flaky test issue. TODO: Remove this once we have a better solution. - { timeout: 10000 }, - ); + await waitFor(() => { + expect(screen.getAllByText("Test Team")).not.toBeNull(); + }); const settingsTab = screen.getByRole("tab", { name: "Settings" }); act(() => { fireEvent.click(settingsTab); }); - await waitFor( - () => { - expect(screen.getByText("Team Settings")).toBeInTheDocument(); - }, - // This is a workaround to fix the flaky test issue. TODO: Remove this once we have a better solution. - { timeout: 10000 }, - ); + await waitFor(() => { + expect(screen.getByText("Team Settings")).toBeInTheDocument(); + }); const editButton = screen.getByRole("button", { name: "Edit Settings" }); act(() => { fireEvent.click(editButton); }); - await waitFor( - () => { - expect(screen.getByLabelText("Models")).toBeInTheDocument(); - }, - // This is a workaround to fix the flaky test issue. TODO: Remove this once we have a better solution. - { timeout: 10000 }, - ); + await waitFor(() => { + expect(screen.getByLabelText("Models")).toBeInTheDocument(); + }); const allProxyModelsOption = screen.queryByText("All Proxy Models"); expect(allProxyModelsOption).not.toBeInTheDocument(); - }); + }, // This is a workaround to fix the flaky test issue. TODO: Remove this once we have a better solution. + 10000); });