From 8ae1fe32c43541dcb92f84b19f53de83ced64e76 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Fri, 6 Feb 2026 20:47:43 -0800 Subject: [PATCH] fixing test --- .../mcp_tools/MCPPermissionManagement.test.tsx | 10 ++++++++-- .../src/components/mcp_tools/mcp_servers.test.tsx | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.test.tsx b/ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.test.tsx index 3784680062..393c9e4a61 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.test.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.test.tsx @@ -44,7 +44,10 @@ const renderWithForm = (props = {}) => { it("should default allow_all_keys switch to unchecked for new servers", async () => { renderWithForm(); await expandPanel(); - const toggle = screen.getByRole("switch"); + // Find the switch associated with "Allow All LiteLLM Keys" text + // The first switch in the component is for allow_all_keys + const switches = screen.getAllByRole("switch"); + const toggle = switches[0]; expect(toggle).toHaveAttribute("aria-checked", "false"); }); @@ -62,7 +65,10 @@ const renderWithForm = (props = {}) => { }); const user = await expandPanel(); - const toggle = screen.getByRole("switch"); + // Find the switch associated with "Allow All LiteLLM Keys" text + // The first switch in the component is for allow_all_keys + const switches = screen.getAllByRole("switch"); + const toggle = switches[0]; expect(toggle).toHaveAttribute("aria-checked", "true"); await user.click(toggle); diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.test.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.test.tsx index 4d80b38370..173b623a2f 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.test.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.test.tsx @@ -11,6 +11,10 @@ vi.mock("../networking", () => ({ fetchMCPServerHealth: vi.fn(), deleteMCPServer: vi.fn(), getProxyBaseUrl: vi.fn().mockReturnValue("http://localhost:4000"), + fetchMCPClientIp: vi.fn().mockResolvedValue(null), + getGeneralSettingsCall: vi.fn().mockResolvedValue([]), + updateConfigFieldSetting: vi.fn().mockResolvedValue(undefined), + deleteConfigFieldSetting: vi.fn().mockResolvedValue(undefined), })); // Mock NotificationsManager