From 54180321be47c55b0778e84179b37d11c79274ba Mon Sep 17 00:00:00 2001 From: Mischa Date: Sat, 20 Jun 2026 20:27:50 +0200 Subject: [PATCH] test(a11y): add A3a-A3d aria-pressed and aria-expanded tests --- tests/ui/accessibility.spec.js | 31 +++++++++++++++++++++++++++++++ user | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/ui/accessibility.spec.js b/tests/ui/accessibility.spec.js index 9706f85..08ad0ec 100644 --- a/tests/ui/accessibility.spec.js +++ b/tests/ui/accessibility.spec.js @@ -21,3 +21,34 @@ test('A2: contrast tokens meet WCAG AA 4.5:1 floor', async ({ page }) => { expect(muted.toLowerCase()).toBe('#90887e'); expect(accent.toLowerCase()).toBe('#2e9880'); }); + +// ── A3: Filter button aria-pressed + toggle aria-expanded ────────────────────── +const TRIP_URL = '/trips/japan-korea-2026'; + +test('A3a: All-content filter has aria-pressed="true" on load', async ({ page }) => { + await page.goto(TRIP_URL); + await expect(page.locator('.trip-filter-btn[data-filter="all"]')).toHaveAttribute('aria-pressed', 'true'); + await expect(page.locator('.trip-filter-btn[data-filter="journal"]')).toHaveAttribute('aria-pressed', 'false'); + await expect(page.locator('.trip-filter-btn[data-filter="story"]')).toHaveAttribute('aria-pressed', 'false'); +}); + +test('A3b: clicking Journal filter toggles aria-pressed', async ({ page }) => { + await page.goto(TRIP_URL); + await page.click('.trip-filter-btn[data-filter="journal"]'); + await expect(page.locator('.trip-filter-btn[data-filter="journal"]')).toHaveAttribute('aria-pressed', 'true'); + await expect(page.locator('.trip-filter-btn[data-filter="all"]')).toHaveAttribute('aria-pressed', 'false'); +}); + +test('A3c: Stats toggle has aria-expanded="false" and aria-controls on load', async ({ page }) => { + await page.goto(TRIP_URL); + await expect(page.locator('#trip-stats-toggle')).toHaveAttribute('aria-expanded', 'false'); + await expect(page.locator('#trip-stats-toggle')).toHaveAttribute('aria-controls', 'trip-stats-block'); +}); + +test('A3d: clicking Stats toggle sets aria-expanded="true" then back to false', async ({ page }) => { + await page.goto(TRIP_URL); + await page.click('#trip-stats-toggle'); + await expect(page.locator('#trip-stats-toggle')).toHaveAttribute('aria-expanded', 'true'); + await page.click('#trip-stats-toggle'); + await expect(page.locator('#trip-stats-toggle')).toHaveAttribute('aria-expanded', 'false'); +}); diff --git a/user b/user index b1e1a5c..ce5d520 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit b1e1a5cb9a187634918bc24a0b0a273cf4bbd7b1 +Subproject commit ce5d520817e9fed085a4b61c9c2ce86d54ab7474