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 3988f01281..a8ff485cf9 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) => ( - - ), - { - Option: ({ value, children }: any) => ( - +// 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(); + return { + ...actual, + Select: Object.assign( + ({ value, onChange, children }: any) => ( + ), - } - ), -})); + { + Option: ({ value, children }: any) => ( + + ), + } + ), + }; +}); 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 b469751ac2..cc071117b8 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 eea2717298..80f0ed98c8 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) => ( - - ), - { - Option: ({ value, children }: any) => ( - +vi.mock("antd", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + Select: Object.assign( + ({ value, onChange, children }: any) => ( + ), - } - ), -})); + { + Option: ({ value, children }: any) => ( + + ), + } + ), + }; +}); vi.mock("@/components/networking", () => ({ getCallbacksCall: vi.fn(),