test(a11y): add A3a-A3d aria-pressed and aria-expanded tests
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user