From 3ed45547db4386a0fb69724d2f7beb6fc8c652dc Mon Sep 17 00:00:00 2001 From: Alexandre Brandizzi Date: Fri, 25 Sep 2026 16:48:46 -0300 Subject: [PATCH] fix(uplifts): keep a failed queue from rendering as an empty archive --- .../_components/uplift-approvals-table.tsx | 29 +++++++++++++++---- src/app/(protected)/uplifts/index.tsx | 14 +++++---- .../uplift-approvals-rejected-tab.test.tsx | 19 +++++++++++- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/app/(protected)/uplifts/_components/uplift-approvals-table.tsx b/src/app/(protected)/uplifts/_components/uplift-approvals-table.tsx index 129df140..9819d2cd 100644 --- a/src/app/(protected)/uplifts/_components/uplift-approvals-table.tsx +++ b/src/app/(protected)/uplifts/_components/uplift-approvals-table.tsx @@ -295,9 +295,31 @@ function UpliftApprovalsEmptyState({ tab }: { tab: UpliftApprovalTab }) { ); } +// A failed queue is not an empty one: the page's error alert explains it, so the +// empty-state copy must not also claim the list has nothing in it. +function UpliftApprovalsEmptyRow({ + tab, + colSpan, + hasError, +}: { + tab: UpliftApprovalTab; + colSpan: number; + hasError: boolean; +}) { + if (hasError) return null; + return ( + + + + + + ); +} + export function UpliftApprovalsTable({ tab, isLoading, + hasError, rows, canRevoke, onOpenDetail, @@ -309,6 +331,7 @@ export function UpliftApprovalsTable({ }: { tab: UpliftApprovalTab; isLoading: boolean; + hasError: boolean; rows: UpliftQueueItem[]; canRevoke: boolean; onOpenDetail: (row: UpliftQueueItem) => void; @@ -339,11 +362,7 @@ export function UpliftApprovalsTable({ ) : rows.length === 0 ? ( - - - - - + ) : ( rows.map((row) => ( { @@ -189,6 +190,7 @@ export default function UpliftQueuePage() { - setPages((current) => ({ ...current, [tab]: page }))} - /> + {activeTotal != null && ( + setPages((current) => ({ ...current, [tab]: page }))} + /> + )} {detailItem != null && ( { + // Load the page module once up front so the first test's budget is not spent on a + // cold import of the whole route. + beforeAll(async () => { + await import("@/app/(protected)/uplifts/index"); + }, 60_000); + beforeEach(() => { queueState.requestedStatuses = []; queueState.errorByStatus = {}; @@ -164,6 +170,17 @@ describe("Uplift Approvals rejected tab", () => { expect(screen.getByLabelText("1 pending uplifts")).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"); + const table = await openRejectedTab(); + + expect(screen.getByRole("alert")).toHaveTextContent("Failed to load uplift queue"); + expect(within(table).queryByText("No rejected uplifts.")).not.toBeInTheDocument(); + expect(within(table).queryByTestId("HighlightOffOutlinedIcon")).not.toBeInTheDocument(); + expect(screen.queryByText(/of 0/)).not.toBeInTheDocument(); + }); + it("lists only rejected uplifts, in the server's most-recently-rejected order", async () => { const table = await openRejectedTab();