From c1f515ddc4c480bae0c34adee2ced8010775cfea Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 10 May 2026 06:46:53 +0200 Subject: [PATCH] test(primitives): cover Pagination bridge-page and totalPages=0 branches Bridge-page-replaces-ellipsis paths (left and right), totalPages=0 hide-the-nav. 3 new tests covering ~5 branches. Refs #496. Co-Authored-By: Claude Sonnet 4.6 --- .../primitives/Pagination.svelte.test.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frontend/src/lib/shared/primitives/Pagination.svelte.test.ts b/frontend/src/lib/shared/primitives/Pagination.svelte.test.ts index 0dbb1c84..31cb310d 100644 --- a/frontend/src/lib/shared/primitives/Pagination.svelte.test.ts +++ b/frontend/src/lib/shared/primitives/Pagination.svelte.test.ts @@ -84,4 +84,28 @@ describe('Pagination', () => { const nav = document.querySelector('nav'); expect(nav?.getAttribute('aria-label')).toBe('Custom pagination'); }); + + it('renders the bridge page (no ellipsis) when window is exactly 2 pages from start', async () => { + // page=3 (1-indexed=4), totalPages=10 → windowStart=3, first+2=3 → bridge to page 2 + render(Pagination, { props: { page: 3, totalPages: 10, makeHref } }); + + // Should have page 2 directly, not an ellipsis + const ellipsisLeft = document.querySelector('[data-testid="pagination-ellipsis-left"]'); + expect(ellipsisLeft).toBeNull(); + }); + + it('renders the bridge page (no ellipsis) when window is exactly 2 pages from end', async () => { + // page=6 (1-indexed=7), totalPages=10 → windowEnd=8, last-2=8 → bridge to page 9 + render(Pagination, { props: { page: 6, totalPages: 10, makeHref } }); + + // Should have page 9 directly, not an ellipsis on the right + const ellipsisRight = document.querySelector('[data-testid="pagination-ellipsis-right"]'); + expect(ellipsisRight).toBeNull(); + }); + + it('returns no result when totalPages is 0', async () => { + render(Pagination, { props: { page: 0, totalPages: 0, makeHref } }); + + expect(document.querySelector('nav')).toBeNull(); + }); });