From 15aa40b36e55956f759e8f6d62b9684dfb8bd221 Mon Sep 17 00:00:00 2001 From: Mateo Wang <277851410+mateo-berri@users.noreply.github.com> Date: Sat, 20 Jun 2026 09:10:45 -0700 Subject: [PATCH] test(ui): isolate OldTeams delete-warning tests from leaked mock (#30871) The deprecated OldTeams component takes only accessToken, userID, userRole and premiumUser; it ignores the teams prop these tests passed and instead populates its table from the mocked teamListCall. The delete-warning block never set teamListCall, and vi.clearAllMocks clears call history but not implementations, so the table rendered the "Legacy Team" (keys.length 2) left behind by the previous block's last test. Both delete tests therefore ran against that leaked team: the keys-present case passed only because the leaked count happened to be 2, and the no-keys case rendered the same warning it asserted should be absent, so it failed. Seed the team through the channel the component actually reads (teamListCall) and drop the props it never consumes, so each test renders exactly the team it declares. The keys-present case now uses a distinctive count so it can no longer pass on a coincidental leak --- .../src/components/OldTeams.test.tsx | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ui/litellm-dashboard/src/components/OldTeams.test.tsx b/ui/litellm-dashboard/src/components/OldTeams.test.tsx index afd456ebc7c..d777ba1b0dc 100644 --- a/ui/litellm-dashboard/src/components/OldTeams.test.tsx +++ b/ui/litellm-dashboard/src/components/OldTeams.test.tsx @@ -1046,17 +1046,14 @@ describe("OldTeams - delete team warning copy", () => { }); const openDeleteModal = async (team: any) => { - renderWithQueryClient( - , - ); + vi.mocked(teamListCall).mockResolvedValue({ + teams: [team], + total: 1, + page: 1, + page_size: 100, + total_pages: 1, + }); + renderWithQueryClient(); await waitFor(() => { expect(screen.getByTestId("delete-team-button")).toBeInTheDocument(); }); @@ -1081,9 +1078,9 @@ describe("OldTeams - delete team warning copy", () => { }; it("warns that the team's models are deleted when the team has keys", async () => { - await openDeleteModal({ ...baseTeam, keys: [], keys_count: 2 }); + await openDeleteModal({ ...baseTeam, keys: [], keys_count: 5 }); - expect(screen.getByText(/Warning: This team has 2 keys associated with it/i)).toHaveTextContent( + expect(screen.getByText(/Warning: This team has 5 keys associated with it/i)).toHaveTextContent( /along with any models created for this team/i, ); expect(screen.getByText(/Are you sure you want to delete this team/i)).toHaveTextContent(