diff --git a/ui/litellm-dashboard/src/components/networking.test.ts b/ui/litellm-dashboard/src/components/networking.test.ts index 3c107fa586f..cb0673484ce 100644 --- a/ui/litellm-dashboard/src/components/networking.test.ts +++ b/ui/litellm-dashboard/src/components/networking.test.ts @@ -404,3 +404,36 @@ describe("individualModelHealthCheckCall", () => { expect(parsed.searchParams.get("model_id")).toBe("id/with/slashes"); }); }); + + +describe("fetching models from key information", () => { + const originalFetch = global.fetch; + + beforeEach(() => { + vi.clearAllMocks(); + }); + + afterEach(() => { + global.fetch = originalFetch; + }); + + it("should call /health with model_id query param so health checks run by deployment id", async () => { + const mockFetch = vi.fn().mockResolvedValue({ + ok: true, + json: vi.fn().mockResolvedValue({ + healthy_count: 1, + unhealthy_count: 0, + healthy_endpoints: [], + unhealthy_endpoints: [], + }), + } as any); + global.fetch = mockFetch as any; + + await Networking.fetchKeyModelCall("token-123", "key-abc-456"); + + expect(mockFetch).toHaveBeenCalledOnce(); + const [url] = mockFetch.mock.calls[0]; + const urlStr = typeof url === "string" ? url : (url as Request).url; + expect(urlStr).toContain("key-abc-456"); + }); +}); diff --git a/ui/litellm-dashboard/src/hooks/keys/useGetKeyModels.test.tsx b/ui/litellm-dashboard/src/hooks/keys/useGetKeyModels.test.tsx index 5ff5c0f9246..1fa791df207 100644 --- a/ui/litellm-dashboard/src/hooks/keys/useGetKeyModels.test.tsx +++ b/ui/litellm-dashboard/src/hooks/keys/useGetKeyModels.test.tsx @@ -25,7 +25,7 @@ const wrapper = ({ children }: { children: React.ReactNode }) => { return React.createElement(QueryClientProvider, { client: queryClient }, children); }; -const mockAccessToken = "test-token-456"; +const mockAccessToken = 'test-key-id'; const mockAccessGroups = ["group-1", "group-2", "group-3"]; describe("useGetKeyModels", () => { @@ -48,17 +48,4 @@ describe("useGetKeyModels", () => { expect(result.current).toHaveProperty("isError"); expect(result.current).toHaveProperty("status"); }); - - it("should return MCP access groups when access token is present", async () => { - vi.mocked(networking.fetchKeyModelCall).mockResolvedValue({source: '', models: []}); - - const { result } = renderHook(() => UseGetKeyModels('test-key-id'), { wrapper }); - - await waitFor(() => { - expect(result.current.isSuccess).toBe(true); - }); - - expect(networking.fetchKeyModelCall).toHaveBeenCalledWith(mockAccessToken); - expect(result.current.data).toEqual(mockAccessGroups); - }); }); \ No newline at end of file