diff --git a/src/app/(protected)/uplifts/index.tsx b/src/app/(protected)/uplifts/index.tsx index 01779410..2aaf0005 100644 --- a/src/app/(protected)/uplifts/index.tsx +++ b/src/app/(protected)/uplifts/index.tsx @@ -48,14 +48,11 @@ const TAB_LABELS: Record = { rejected: "Rejected", }; -// A tab's total is only known once its queue has loaded without error; until then the -// pill must not claim a count (a loading or failed queue is not an empty one). -function knownTotal(query: { - data?: UpliftsQueueResult | undefined; - error: unknown; -}): number | null { - if (query.error || !query.data) return null; - return query.data.totalCount; +// A tab's total is only known once its queue has loaded at least once; until then the +// pill and pager must not claim a count (a loading or failed queue is not an empty one). +// A failed refetch keeps the last loaded page, so its total stays usable. +function knownTotal(query: { data?: UpliftsQueueResult | undefined }): number | null { + return query.data ? query.data.totalCount : null; } function TabCountPill({ tab, count }: { tab: UpliftApprovalTab; count: number | null }) { diff --git a/src/test/app/(protected)/uplifts/uplift-approvals-rejected-tab.test.tsx b/src/test/app/(protected)/uplifts/uplift-approvals-rejected-tab.test.tsx index 7cd67af7..23323d0a 100644 --- a/src/test/app/(protected)/uplifts/uplift-approvals-rejected-tab.test.tsx +++ b/src/test/app/(protected)/uplifts/uplift-approvals-rejected-tab.test.tsx @@ -170,6 +170,16 @@ describe("Uplift Approvals rejected tab", () => { expect(screen.getByLabelText("1 pending uplifts")).toBeInTheDocument(); }); + it("keeps the count and pager for kept rows when a rejected refetch fails", async () => { + queueState.errorByStatus.Rejected = new Error("Failed to load uplift queue"); + const table = await openRejectedTab(); + + expect(screen.getByRole("alert")).toHaveTextContent("Failed to load uplift queue"); + expect(within(table).getAllByRole("row")).toHaveLength(3); + expect(screen.getByLabelText("12 rejected uplifts")).toHaveTextContent("12"); + expect(screen.getByText(/of 12/)).toBeInTheDocument(); + }); + it("shows the load error instead of an empty archive when the rejected queue fails", async () => { queueState.byStatus.Rejected = undefined; queueState.errorByStatus.Rejected = new Error("Failed to load uplift queue");