Skip to content

Commit ab63623

Browse files
test(accordion): migrate tests to Playwright (#25524)
1 parent 50d806e commit ab63623

File tree

83 files changed

+129
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+129
-556
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
});

core/src/components/accordion/test/a11y/e2e.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { expect } from '@playwright/test';
2+
import { test } from '@utils/test/playwright';
3+
4+
test.describe('accordion: basic', () => {
5+
test('should not have visual regressions', async ({ page }) => {
6+
await page.goto(`/src/components/accordion/test/basic`);
7+
8+
await page.setIonViewport();
9+
10+
expect(await page.screenshot()).toMatchSnapshot(`accordion-basic-${page.getSnapshotSettings()}.png`);
11+
});
12+
});
275 KB
Loading
88.4 KB
Loading
244 KB
Loading
275 KB
Loading
88 KB
Loading
244 KB
Loading
255 KB
Loading

0 commit comments

Comments
 (0)