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>
This commit is contained in:
ryan 2026-09-04 00:11:00 +00:00
parent 9ba6cab889
commit c9f9b4ae9c
2 changed files with 9 additions and 7 deletions

View file

@ -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(() => {

View file

@ -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());