From c8ce098b65d9e0d804e162c2a29568eec6cc5f1b Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Thu, 12 Mar 2026 11:24:15 -0700 Subject: [PATCH] fixing tests --- .../components/EntityUsage/EntityUsage.tsx | 6 +++--- .../MCPToolPermissions.test.tsx | 16 +++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.tsx b/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.tsx index 5129db0a01..92d9c25c6b 100644 --- a/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.tsx +++ b/ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.tsx @@ -465,7 +465,7 @@ const EntityUsage: React.FC = ({ accessToken, entityType, enti Cost {entityType === "agent" ? "Request / Token Consumption" : "Model Activity"} - {entityType === "team" ? Agent Activity : null} + {entityType === "team" ? Agent Activity : <>} Key Activity Endpoint Activity @@ -768,11 +768,11 @@ const EntityUsage: React.FC = ({ accessToken, entityType, enti - {entityType === "team" && ( + {entityType === "team" ? ( - )} + ) : <>} diff --git a/ui/litellm-dashboard/src/components/mcp_server_management/MCPToolPermissions.test.tsx b/ui/litellm-dashboard/src/components/mcp_server_management/MCPToolPermissions.test.tsx index 5b8611f4e9..42ecdd6fd9 100644 --- a/ui/litellm-dashboard/src/components/mcp_server_management/MCPToolPermissions.test.tsx +++ b/ui/litellm-dashboard/src/components/mcp_server_management/MCPToolPermissions.test.tsx @@ -19,7 +19,8 @@ describe("MCPToolPermissions", () => { it("should update tool permissions when user selects a tool", async () => { /** * Tests that clicking a tool checkbox calls onChange with updated permissions. - * This is the core functionality of the component. + * Pre-populates toolPermissions so the auto-populate logic on fetch is skipped, + * and switches to flat view for predictable checkbox ordering. */ const mockOnChange = vi.fn(); const mockTools = [ @@ -43,11 +44,12 @@ describe("MCPToolPermissions", () => { error: false, }); + // Pre-populate with all tools selected so auto-populate doesn't fire renderWithProviders( , ); @@ -61,13 +63,17 @@ describe("MCPToolPermissions", () => { expect(screen.getByText("read_wiki_structure")).toBeInTheDocument(); }); - // Get all checkboxes and click the first one (for read_wiki_structure) + // Switch to Flat List view for predictable checkbox ordering + const flatListOption = screen.getByText("Flat List"); + await userEvent.click(flatListOption); + + // Click the first checkbox to deselect read_wiki_structure const checkboxes = screen.getAllByRole("checkbox"); await userEvent.click(checkboxes[0]); - // Verify onChange was called with correct permissions + // Verify onChange was called with read_wiki_structure removed expect(mockOnChange).toHaveBeenCalledWith({ - [mockServerId]: ["read_wiki_structure"], + [mockServerId]: ["read_wiki_contents", "ask_question"], }); // Verify API calls