|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { test } from '@utils/test/playwright'; |
| 3 | + |
| 4 | +test.describe('accordion: a11y', () => { |
| 5 | + test('accordions should be keyboard navigable', async ({ page, browserName }) => { |
| 6 | + // TODO(FW-1764): remove skip once issue is resolved |
| 7 | + test.skip(browserName === 'firefox', 'https://github.com/ionic-team/ionic-framework/issues/25529'); |
| 8 | + |
| 9 | + await page.goto(`/src/components/accordion/test/a11y`); |
| 10 | + const tabKey = browserName === 'webkit' ? 'Alt+Tab' : 'Tab'; |
| 11 | + |
| 12 | + const personalInfoHeader = page.locator('ion-accordion:first-child > ion-item'); |
| 13 | + const billingAddressHeader = page.locator('ion-accordion:nth-child(2) > ion-item'); |
| 14 | + const shippingAddressHeader = page.locator('ion-accordion:nth-child(3) > ion-item'); |
| 15 | + const addressInput = page.locator('#address1 input'); |
| 16 | + |
| 17 | + await page.keyboard.press(tabKey); |
| 18 | + await expect(personalInfoHeader).toBeFocused(); |
| 19 | + |
| 20 | + await page.keyboard.press('ArrowDown'); |
| 21 | + await expect(billingAddressHeader).toBeFocused(); |
| 22 | + |
| 23 | + await page.keyboard.press('ArrowDown'); |
| 24 | + await expect(shippingAddressHeader).toBeFocused(); |
| 25 | + |
| 26 | + await page.keyboard.press('ArrowDown'); |
| 27 | + await expect(personalInfoHeader).toBeFocused(); |
| 28 | + |
| 29 | + await page.keyboard.press('ArrowUp'); |
| 30 | + await expect(shippingAddressHeader).toBeFocused(); |
| 31 | + |
| 32 | + // open Shipping Address accordion and move focus to the input inside it |
| 33 | + await page.keyboard.press('Enter'); |
| 34 | + await page.waitForChanges(); |
| 35 | + await page.keyboard.press(tabKey); |
| 36 | + await expect(addressInput).toBeFocused(); |
| 37 | + |
| 38 | + // ensure keyboard interaction doesn't move focus from body |
| 39 | + await page.keyboard.press('ArrowDown'); |
| 40 | + await expect(addressInput).toBeFocused(); |
| 41 | + }); |
| 42 | +}); |
0 commit comments