mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
test(frontend tests)
This commit is contained in:
parent
c1384fa8e3
commit
c9c87dd52c
2 changed files with 34 additions and 14 deletions
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue