diff --git a/core/src/components/accordion/test/a11y/accordion.e2e.ts b/core/src/components/accordion/test/a11y/accordion.e2e.ts new file mode 100644 index 00000000000..3fdcdeb447c --- /dev/null +++ b/core/src/components/accordion/test/a11y/accordion.e2e.ts @@ -0,0 +1,42 @@ +import { expect } from '@playwright/test'; +import { test } from '@utils/test/playwright'; + +test.describe('accordion: a11y', () => { + test('accordions should be keyboard navigable', async ({ page, browserName }) => { + // TODO(FW-1764): remove skip once issue is resolved + test.skip(browserName === 'firefox', 'https://github.com/ionic-team/ionic-framework/issues/25529'); + + await page.goto(`/src/components/accordion/test/a11y`); + const tabKey = browserName === 'webkit' ? 'Alt+Tab' : 'Tab'; + + const personalInfoHeader = page.locator('ion-accordion:first-child > ion-item'); + const billingAddressHeader = page.locator('ion-accordion:nth-child(2) > ion-item'); + const shippingAddressHeader = page.locator('ion-accordion:nth-child(3) > ion-item'); + const addressInput = page.locator('#address1 input'); + + await page.keyboard.press(tabKey); + await expect(personalInfoHeader).toBeFocused(); + + await page.keyboard.press('ArrowDown'); + await expect(billingAddressHeader).toBeFocused(); + + await page.keyboard.press('ArrowDown'); + await expect(shippingAddressHeader).toBeFocused(); + + await page.keyboard.press('ArrowDown'); + await expect(personalInfoHeader).toBeFocused(); + + await page.keyboard.press('ArrowUp'); + await expect(shippingAddressHeader).toBeFocused(); + + // open Shipping Address accordion and move focus to the input inside it + await page.keyboard.press('Enter'); + await page.waitForChanges(); + await page.keyboard.press(tabKey); + await expect(addressInput).toBeFocused(); + + // ensure keyboard interaction doesn't move focus from body + await page.keyboard.press('ArrowDown'); + await expect(addressInput).toBeFocused(); + }); +}); diff --git a/core/src/components/accordion/test/a11y/e2e.ts b/core/src/components/accordion/test/a11y/e2e.ts deleted file mode 100644 index f25141b93a5..00000000000 --- a/core/src/components/accordion/test/a11y/e2e.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { newE2EPage } from '@stencil/core/testing'; - -const getActiveElementText = async (page) => { - const activeElement = await page.evaluateHandle(() => document.activeElement); - return page.evaluate((el) => el?.innerText, activeElement); -}; - -const getActiveInputID = async (page) => { - const activeElement = await page.evaluateHandle(() => document.activeElement); - return page.evaluate((el) => el?.closest('ion-input')?.id, activeElement); -}; - -test('accordion: a11y', async () => { - const page = await newE2EPage({ - url: '/src/components/accordion/test/a11y?ionic:_testing=true', - }); - - const compare = await page.compareScreenshot(); - expect(compare).toMatchScreenshot(); -}); - -test('accordion:rtl: a11y', async () => { - const page = await newE2EPage({ - url: '/src/components/accordion/test/a11y?ionic:_testing=true&rtl=true', - }); - - const compare = await page.compareScreenshot(); - expect(compare).toMatchScreenshot(); -}); - -test('accordion: keyboard navigation', async () => { - const page = await newE2EPage({ - url: '/src/components/accordion/test/a11y?ionic:_testing=true', - }); - - await page.keyboard.press('Tab'); - expect(await getActiveElementText(page)).toEqual('Personal Information'); - - await page.keyboard.press('ArrowDown'); - expect(await getActiveElementText(page)).toEqual('Billing Address'); - - await page.keyboard.press('ArrowDown'); - expect(await getActiveElementText(page)).toEqual('Shipping Address'); - - await page.keyboard.press('ArrowDown'); - expect(await getActiveElementText(page)).toEqual('Personal Information'); - - await page.keyboard.press('ArrowUp'); - expect(await getActiveElementText(page)).toEqual('Shipping Address'); - - // open Shipping Address accordion and move focus to the input inside it - await page.keyboard.press('Enter'); - await page.waitForChanges(); - await page.keyboard.press('Tab'); - - const activeID = await getActiveInputID(page); - expect(activeID).toEqual('address1'); - - // ensure keyboard interaction doesn't move focus from body - await page.keyboard.press('ArrowDown'); - const activeIDAgain = await getActiveInputID(page); - expect(activeIDAgain).toEqual('address1'); -}); diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts b/core/src/components/accordion/test/basic/accordion.e2e.ts new file mode 100644 index 00000000000..3263fdde5cf --- /dev/null +++ b/core/src/components/accordion/test/basic/accordion.e2e.ts @@ -0,0 +1,12 @@ +import { expect } from '@playwright/test'; +import { test } from '@utils/test/playwright'; + +test.describe('accordion: basic', () => { + test('should not have visual regressions', async ({ page }) => { + await page.goto(`/src/components/accordion/test/basic`); + + await page.setIonViewport(); + + expect(await page.screenshot()).toMatchSnapshot(`accordion-basic-${page.getSnapshotSettings()}.png`); + }); +}); diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Chrome-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..9ae8357d19d Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Firefox-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..ed66c275b7c Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Safari-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Safari-linux.png new file mode 100644 index 00000000000..844d76c106a Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Chrome-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..8dd6f51a17e Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Chrome-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Firefox-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..13c6cdb9d52 Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Firefox-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Safari-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Safari-linux.png new file mode 100644 index 00000000000..16bc9ed8889 Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-ios-rtl-Mobile-Safari-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Chrome-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..93f46388395 Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Firefox-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..afb42d65b82 Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Safari-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Safari-linux.png new file mode 100644 index 00000000000..0e658f359ca Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Chrome-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Chrome-linux.png new file mode 100644 index 00000000000..70f8202722b Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Chrome-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Firefox-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Firefox-linux.png new file mode 100644 index 00000000000..3d19a6782d6 Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Firefox-linux.png differ diff --git a/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Safari-linux.png b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Safari-linux.png new file mode 100644 index 00000000000..5ce5433b71a Binary files /dev/null and b/core/src/components/accordion/test/basic/accordion.e2e.ts-snapshots/accordion-basic-md-rtl-Mobile-Safari-linux.png differ diff --git a/core/src/components/accordion/test/basic/e2e.ts b/core/src/components/accordion/test/basic/e2e.ts deleted file mode 100644 index 99771845ae5..00000000000 --- a/core/src/components/accordion/test/basic/e2e.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { newE2EPage } from '@stencil/core/testing'; - -test('accordion: basic', async () => { - const page = await newE2EPage({ - url: '/src/components/accordion/test/basic?ionic:_testing=true', - }); - - const compare = await page.compareScreenshot(); - expect(compare).toMatchScreenshot(); -}); diff --git a/core/src/components/accordion/test/basic/index.html b/core/src/components/accordion/test/basic/index.html index 9f26b6bf0a5..0307c164aa3 100644 --- a/core/src/components/accordion/test/basic/index.html +++ b/core/src/components/accordion/test/basic/index.html @@ -42,12 +42,12 @@