fix(pagination): window totalItems for performance (#2160)

Fixes #2156
This commit is contained in:
Eric Liu 2025-04-26 13:25:52 -07:00 committed by GitHub
commit ed3928bb01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 102 additions and 20 deletions

View file

@ -196,4 +196,22 @@ describe("Pagination", () => {
expect(screen.getByText("00 of 0 items")).toBeInTheDocument();
});
it("renders a cap of 1000 page numbers by default", () => {
render(Pagination, {
props: { totalItems: 100_000 },
});
const pageNumbers = screen.getByLabelText(/Page number, of 10000 pages/);
expect(pageNumbers).toHaveLength(1_000 + 1);
});
it("renders a custom page window", () => {
render(Pagination, {
props: { totalItems: 100_000, pageWindow: 100 },
});
const pageNumbers = screen.getByLabelText(/Page number, of 10000 pages/);
expect(pageNumbers).toHaveLength(100 + 1);
});
});