fix(vendors): report the filtered total

This commit is contained in:
Alexandre Brandizzi 2026-07-22 11:00:08 -03:00
parent a6054279a2
commit ff10bbd8ec
2 changed files with 20 additions and 2 deletions

View file

@ -416,8 +416,8 @@ export default function VendorsListPage() {
}} }}
> >
<Typography variant="body2" sx={{ color: "text.secondary" }}> <Typography variant="body2" sx={{ color: "text.secondary" }}>
{rows.length} {isActive ? "active" : "inactive"}{" "} {totalCount} {isActive ? "active" : "inactive"}{" "}
{rows.length === 1 ? "technician" : "technicians"} {totalCount === 1 ? "technician" : "technicians"}
{(appliedChips.length > 0 || debouncedSearch) && " · filtered"} {(appliedChips.length > 0 || debouncedSearch) && " · filtered"}
{` · ${activeCount} active · ${inactiveCount} inactive`} {` · ${activeCount} active · ${inactiveCount} inactive`}
</Typography> </Typography>

View file

@ -65,4 +65,22 @@ describe("VendorsListPage", () => {
expect(screen.getByText("Drain Cleaning Bros")).toBeInTheDocument(); expect(screen.getByText("Drain Cleaning Bros")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Deactivate vendor" })).not.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(<VendorsListPage />, { route: "/vendors", withAuth: false });
expect(screen.getByText(/25 active technicians/)).toBeInTheDocument();
expect(screen.queryByText(/3 active technicians/)).not.toBeInTheDocument();
});
}); });