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 - resolve flaky tests from leaked @tremor/react Tooltip timer

yuneng-jiang2285dc78b945
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 01f318b909a..3988f012814 100644
--- a/ui/litellm-dashboard/src/components/router_settings/RouterSettingsForm.test.tsx
+++ b/ui/litellm-dashboard/src/components/router_settings/RouterSettingsForm.test.tsx
@@ -24,21 +24,6 @@ vi.mock("antd", () => ({
),
}));
-vi.mock("@tremor/react", async (importOriginal) => {
- const actual = await importOriginal<typeof import("@tremor/react")>();
- return {
- ...actual,
- Switch: ({ checked, onChange }: any) => (
- <input
- type="checkbox"
- role="switch"
- checked={checked}
- onChange={(e) => onChange(e.target.checked)}
- />
- ),
- };
-});
-
const defaultValue: RouterSettingsFormValue = {
routerSettings: {},
selectedStrategy: null,
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 593721db023..b469751ac2d 100644
--- a/ui/litellm-dashboard/src/components/router_settings/TagFilteringToggle.test.tsx
+++ b/ui/litellm-dashboard/src/components/router_settings/TagFilteringToggle.test.tsx
@@ -3,24 +3,6 @@ import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import TagFilteringToggle from "./TagFilteringToggle";
-// setupTests.ts mocks @tremor/react but leaves Switch as the real implementation.
-// Re-mock Switch as a plain checkbox so toggle interactions are trivially testable.
-vi.mock("@tremor/react", async (importOriginal) => {
- const actual = await importOriginal<typeof import("@tremor/react")>();
- return {
- ...actual,
- Switch: ({ checked, onChange, className }: any) => (
- <input
- type="checkbox"
- role="switch"
- checked={checked}
- onChange={(e) => onChange(e.target.checked)}
- className={className}
- />
- ),
- };
-});
-
const baseMetadata = {
enable_tag_filtering: {
ui_field_name: "Tag Filtering",
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 8edb0ac6e07..eea2717298a 100644
--- a/ui/litellm-dashboard/src/components/router_settings/index.test.tsx
+++ b/ui/litellm-dashboard/src/components/router_settings/index.test.tsx
@@ -22,21 +22,6 @@ vi.mock("antd", () => ({
),
}));
-vi.mock("@tremor/react", async (importOriginal) => {
- const actual = await importOriginal<typeof import("@tremor/react")>();
- return {
- ...actual,
- Switch: ({ checked, onChange }: any) => (
- <input
- type="checkbox"
- role="switch"
- checked={checked}
- onChange={(e) => onChange(e.target.checked)}
- />
- ),
- };
-});
-
vi.mock("@/components/networking", () => ({
getCallbacksCall: vi.fn(),
getRouterSettingsCall: vi.fn(),
diff --git a/ui/litellm-dashboard/tests/setupTests.ts b/ui/litellm-dashboard/tests/setupTests.ts
index e1ae45e8c58..e8de9f72485 100644
--- a/ui/litellm-dashboard/tests/setupTests.ts
+++ b/ui/litellm-dashboard/tests/setupTests.ts
@@ -30,6 +30,15 @@ vi.mock("@tremor/react", async (importOriginal) => {
// This avoids issues with hover states, positioning, and DOM queries in tests
return React.createElement(React.Fragment, null, children);
},
+ // Render as a plain checkbox so toggle interactions are testable without Tremor internals
+ Switch: ({ checked, onChange, className }: { checked?: boolean; onChange?: (v: boolean) => void; className?: string }) =>
+ React.createElement("input", {
+ type: "checkbox",
+ role: "switch",
+ checked,
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => onChange?.(e.target.checked),
+ className,
+ }),
};
});