From ff10bbd8ec43d1f636124b2f4f4e0182c8535b50 Mon Sep 17 00:00:00 2001 From: Alexandre Brandizzi Date: Wed, 22 Jul 2026 11:00:08 -0300 Subject: [PATCH] fix(vendors): report the filtered total --- src/app/(protected)/vendors/index.tsx | 4 ++-- .../(protected)/vendors/vendors-list.test.tsx | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/app/(protected)/vendors/index.tsx b/src/app/(protected)/vendors/index.tsx index 92b9112b..68abe1a0 100644 --- a/src/app/(protected)/vendors/index.tsx +++ b/src/app/(protected)/vendors/index.tsx @@ -416,8 +416,8 @@ export default function VendorsListPage() { }} > - {rows.length} {isActive ? "active" : "inactive"}{" "} - {rows.length === 1 ? "technician" : "technicians"} + {totalCount} {isActive ? "active" : "inactive"}{" "} + {totalCount === 1 ? "technician" : "technicians"} {(appliedChips.length > 0 || debouncedSearch) && " · filtered"} {` · ${activeCount} active · ${inactiveCount} inactive`} diff --git a/src/test/app/(protected)/vendors/vendors-list.test.tsx b/src/test/app/(protected)/vendors/vendors-list.test.tsx index 64785ad0..1db80de8 100644 --- a/src/test/app/(protected)/vendors/vendors-list.test.tsx +++ b/src/test/app/(protected)/vendors/vendors-list.test.tsx @@ -65,4 +65,22 @@ describe("VendorsListPage", () => { expect(screen.getByText("Drain Cleaning Bros")).toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Deactivate vendor" })).not.toBeInTheDocument(); }); + + it("reports the filtered totalCount in the footer when page rows are fewer than total", () => { + const pageVendors = Array.from({ length: 3 }, (_, index) => ({ + ...activeVendor, + id: 100 + index, + companyName: `Vendor ${index + 1}`, + })); + + useVendorsList.mockImplementation((params: { isActive?: boolean; pageSize?: number }) => { + if (params.pageSize === 1) return result([], params.isActive ? 25 : 0); + return result(pageVendors, 25); + }); + + renderWithProviders(, { route: "/vendors", withAuth: false }); + + expect(screen.getByText(/25 active technicians/)).toBeInTheDocument(); + expect(screen.queryByText(/3 active technicians/)).not.toBeInTheDocument(); + }); });