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]

test(ui): hoist mock responses to named variables to stay within lint budget

ryanc9f9b4ae9cbd
diff --git a/ui/litellm-dashboard/src/components/per_user_usage.test.tsx b/ui/litellm-dashboard/src/components/per_user_usage.test.tsx
index 5cd0591bb15..01494ef8bfa 100644
--- a/ui/litellm-dashboard/src/components/per_user_usage.test.tsx
+++ b/ui/litellm-dashboard/src/components/per_user_usage.test.tsx
@@ -80,7 +80,8 @@ describe("PerUserUsage", () => {
it("shows every fetched row with a footer that matches the server total and page size", async () => {
const results = Array.from({ length: 25 }, (_, index) => userRow(`user-${index}`, "curl/8.0", index));
- mockPerUserAnalyticsCall.mockResolvedValue({ ...mockResponse, results, total_count: 60, total_pages: 3 });
+ const firstPage = { ...mockResponse, results, total_count: 60, total_pages: 3 };
+ mockPerUserAnalyticsCall.mockResolvedValue(firstPage);
render(<PerUserUsage {...defaultProps} />);
await waitFor(() => {
diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx
index b10b2584548..295446186b1 100644
--- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx
@@ -170,7 +170,7 @@ describe("RequestLogsPanel", () => {
});
it("counts the rendered rows in the footer instead of the server's session total", async () => {
- vi.mocked(uiSpendLogsCall).mockResolvedValue({
+ const lastPage = {
data: [logEntry({ request_id: "req-a" }), logEntry({ request_id: "req-b" }), logEntry({ request_id: "req-c" })],
total: 40,
page: 1,
@@ -178,7 +178,8 @@ describe("RequestLogsPanel", () => {
total_pages: 2,
next_session_cursor: null,
has_more: false,
- });
+ };
+ vi.mocked(uiSpendLogsCall).mockResolvedValue(lastPage);
renderPanel();
await waitFor(() => expect(row("req-a")).not.toBeNull());
@@ -187,16 +188,16 @@ describe("RequestLogsPanel", () => {
});
it("keeps Next enabled from the server total while more session pages remain", async () => {
- const firstPage = Array.from({ length: 25 }, (_, index) => logEntry({ request_id: `req-${index}` }));
- vi.mocked(uiSpendLogsCall).mockResolvedValue({
- data: firstPage,
+ const firstPage = {
+ data: Array.from({ length: 25 }, (_, index) => logEntry({ request_id: `req-${index}` })),
total: 80,
page: 1,
page_size: 25,
total_pages: 4,
next_session_cursor: "2026-07-07 09:50:13|key-1|sess-1",
has_more: true,
- });
+ };
+ vi.mocked(uiSpendLogsCall).mockResolvedValue(firstPage);
renderPanel();
await waitFor(() => expect(row("req-0")).not.toBeNull());