Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(ui): repair router_settings tests broken by full antd mock

Ryan Crabbe260679679f78
diff --git a/ui/litellm-dashboard/src/components/router_settings/RouterSettingsForm.test.tsx b/ui/litellm-dashboard/src/components/router_settings/RouterSettingsForm.test.tsx
index 3988f012814..a8ff485cf9b 100644
--- a/ui/litellm-dashboard/src/components/router_settings/RouterSettingsForm.test.tsx
+++ b/ui/litellm-dashboard/src/components/router_settings/RouterSettingsForm.test.tsx
@@ -4,25 +4,30 @@ import userEvent from "@testing-library/user-event";
import RouterSettingsForm from "./RouterSettingsForm";
import type { RouterSettingsFormValue } from "./RouterSettingsForm";
-// Use the same antd mock as RoutingStrategySelector to keep things consistent
-vi.mock("antd", () => ({
- Select: Object.assign(
- ({ value, onChange, children }: any) => (
- <select
- data-testid="strategy-select"
- value={value ?? ""}
- onChange={(e) => onChange(e.target.value)}
- >
- {children}
- </select>
- ),
- {
- Option: ({ value, children }: any) => (
- <option value={value}>{children}</option>
+// Override antd Select (complex to drive in JSDOM) while preserving the rest
+// of antd (Switch, Button, etc.) so nested components render normally.
+vi.mock("antd", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("antd")>();
+ return {
+ ...actual,
+ Select: Object.assign(
+ ({ value, onChange, children }: any) => (
+ <select
+ data-testid="strategy-select"
+ value={value ?? ""}
+ onChange={(e) => onChange(e.target.value)}
+ >
+ {children}
+ </select>
),
- }
- ),
-}));
+ {
+ Option: ({ value, children }: any) => (
+ <option value={value}>{children}</option>
+ ),
+ }
+ ),
+ };
+});
const defaultValue: RouterSettingsFormValue = {
routerSettings: {},
diff --git a/ui/litellm-dashboard/src/components/router_settings/TagFilteringToggle.test.tsx b/ui/litellm-dashboard/src/components/router_settings/TagFilteringToggle.test.tsx
index b469751ac2d..cc071117b82 100644
--- a/ui/litellm-dashboard/src/components/router_settings/TagFilteringToggle.test.tsx
+++ b/ui/litellm-dashboard/src/components/router_settings/TagFilteringToggle.test.tsx
@@ -90,6 +90,7 @@ describe("TagFilteringToggle", () => {
await user.click(screen.getByRole("switch"));
- expect(onToggle).toHaveBeenCalledWith(true);
+ expect(onToggle).toHaveBeenCalledTimes(1);
+ expect(onToggle.mock.calls[0][0]).toBe(true);
});
});
diff --git a/ui/litellm-dashboard/src/components/router_settings/index.test.tsx b/ui/litellm-dashboard/src/components/router_settings/index.test.tsx
index eea2717298a..80f0ed98c81 100644
--- a/ui/litellm-dashboard/src/components/router_settings/index.test.tsx
+++ b/ui/litellm-dashboard/src/components/router_settings/index.test.tsx
@@ -3,24 +3,28 @@ import { renderWithProviders, screen, waitFor } from "../../../tests/test-utils"
import userEvent from "@testing-library/user-event";
import RouterSettings from "./index";
-vi.mock("antd", () => ({
- Select: Object.assign(
- ({ value, onChange, children }: any) => (
- <select
- data-testid="strategy-select"
- value={value ?? ""}
- onChange={(e) => onChange(e.target.value)}
- >
- {children}
- </select>
- ),
- {
- Option: ({ value, children }: any) => (
- <option value={value}>{children}</option>
+vi.mock("antd", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("antd")>();
+ return {
+ ...actual,
+ Select: Object.assign(
+ ({ value, onChange, children }: any) => (
+ <select
+ data-testid="strategy-select"
+ value={value ?? ""}
+ onChange={(e) => onChange(e.target.value)}
+ >
+ {children}
+ </select>
),
- }
- ),
-}));
+ {
+ Option: ({ value, children }: any) => (
+ <option value={value}>{children}</option>
+ ),
+ }
+ ),
+ };
+});
vi.mock("@/components/networking", () => ({
getCallbacksCall: vi.fn(),