Skip to content

Commit 7ce3c69

Browse files
committed
test: check pagination accessibility on a single-listing page
1 parent 371d3f2 commit 7ce3c69

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Single Listing Pagination Test
3+
listing:
4+
- id: only
5+
contents: posts
6+
type: default
7+
page-size: 1
8+
sort: title
9+
pagination:
10+
outer-window: 1
11+
---
12+
13+
## Posts
14+
15+
::: {#only}
16+
:::

‎tests/integration/playwright/tests/listing-pagination.spec.ts‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, Page, test } from "@playwright/test";
22

33
const fixture = "./listings/pagination/_site/index.html";
4+
const singleFixture = "./listings/pagination/_site/single.html";
45

56
// Link texts of each listing; the active page is wrapped in brackets.
67
const expected: Record<string, { page1: string; page6: string }> = {
@@ -207,21 +208,26 @@ test.describe("Listing pagination accessibility", () => {
207208
`);
208209
});
209210

210-
// landmark-unique: every listing nav shares one label, as it did before.
211-
// region: the skip link sits outside any landmark. Neither comes from the
212-
// pagination options or the ARIA attributes tested here.
213-
const ignoredAxeRules = ["landmark-unique", "region"];
214-
215-
for (const state of ["page 1", "page 6"]) {
216-
test(`axe finds no violation on ${state}`, async ({ page }) => {
211+
// With five listings on one page, every nav shares one label, so axe reports
212+
// landmark-unique. The single-listing page below checks that rule too.
213+
// region: the skip link sits outside any landmark, which has nothing to do
214+
// with pagination.
215+
const axeCases = [
216+
{ name: "page 1", page: fixture, hash: "", ignored: ["landmark-unique", "region"] },
217+
{ name: "page 6", page: fixture, hash: "#listing-outer-page=6", ignored: ["landmark-unique", "region"] },
218+
{ name: "single listing page 1", page: singleFixture, hash: "", ignored: ["region"] },
219+
{ name: "single listing page 6", page: singleFixture, hash: "#listing-only-page=6", ignored: ["region"] },
220+
];
221+
222+
for (const { name, page: url, hash, ignored } of axeCases) {
223+
test(`axe finds no violation on ${name}`, async ({ page }) => {
217224
const messages = collectLogs(page);
218-
const hash = state === "page 6" ? "#listing-outer-page=6" : "";
219-
await page.goto(`${fixture}${hash}`, { waitUntil: "networkidle" });
225+
await page.goto(`${url}${hash}`, { waitUntil: "networkidle" });
220226
const violations = await axeViolations(page, messages);
221227
expect(violations).toBeDefined();
222228
const ids = violations.map((v: { id: string }) => v.id).filter((
223229
id: string,
224-
) => !ignoredAxeRules.includes(id));
230+
) => !ignored.includes(id));
225231
expect(ids).toEqual([]);
226232
});
227233
}

0 commit comments

Comments
 (0)