From c9f9b4ae9cbd79fd17d66dcaf42be94ad4bfe4e0 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 4 Sep 2026 00:11:00 +0000 Subject: [PATCH] test(ui): hoist mock responses to named variables to stay within lint budget Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../src/components/per_user_usage.test.tsx | 3 ++- .../components/view_logs/RequestLogsPanel.test.tsx | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) 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(); 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());