|
1 | 1 | import { expect, Page, test } from "@playwright/test"; |
2 | 2 |
|
3 | 3 | const fixture = "./listings/pagination/_site/index.html"; |
| 4 | +const singleFixture = "./listings/pagination/_site/single.html"; |
4 | 5 |
|
5 | 6 | // Link texts of each listing; the active page is wrapped in brackets. |
6 | 7 | const expected: Record<string, { page1: string; page6: string }> = { |
@@ -207,21 +208,26 @@ test.describe("Listing pagination accessibility", () => { |
207 | 208 | `); |
208 | 209 | }); |
209 | 210 |
|
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 }) => { |
217 | 224 | 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" }); |
220 | 226 | const violations = await axeViolations(page, messages); |
221 | 227 | expect(violations).toBeDefined(); |
222 | 228 | const ids = violations.map((v: { id: string }) => v.id).filter(( |
223 | 229 | id: string, |
224 | | - ) => !ignoredAxeRules.includes(id)); |
| 230 | + ) => !ignored.includes(id)); |
225 | 231 | expect(ids).toEqual([]); |
226 | 232 | }); |
227 | 233 | } |
|
0 commit comments