From 204a861b2735015b8d7991ab672672a5440d5508 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Wed, 20 Dec 2023 14:47:46 -0800 Subject: [PATCH] test(radio): re-enable keyboard navigation (#28747) Issue number: internal --------- ## What is the current behavior? The keyboard navigation tests for radio were disable due to flakiness with Safari when it came to the CI. ## What is the new behavior? - Re-enabled the tests. Debugging was done with a saved artifact. The artifact didn't provide a clear reason of why it flakes. But it did seem that the test was tabbing before the Safari page finished loading. I've added a `waitFor()` to verify that the radios have rendered. This was done for Safari only to prevent any additional wait time. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information There is no great way to test this since it only flakes on GitHub. --- .../components/radio/test/a11y/radio.e2e.ts | 20 ++++++++++++++++--- .../radio/test/legacy/a11y/radio.e2e.ts | 18 +++++++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/core/src/components/radio/test/a11y/radio.e2e.ts b/core/src/components/radio/test/a11y/radio.e2e.ts index eaa52c548c..e5a375bc96 100644 --- a/core/src/components/radio/test/a11y/radio.e2e.ts +++ b/core/src/components/radio/test/a11y/radio.e2e.ts @@ -15,9 +15,8 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => }); }); - // TODO(FW-5715): re-enable test - test.skip(title('radio: keyboard navigation'), () => { - test.beforeEach(async ({ page }) => { + test.describe(title('radio: keyboard navigation'), () => { + test.beforeEach(async ({ page, browserName }) => { await page.setContent( ` @@ -59,6 +58,21 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => `, config ); + + if (browserName === 'webkit') { + const radio = page.locator('#first-group ion-radio').first(); + /** + * Sometimes Safari does not focus the first radio. + * This is a workaround to ensure the first radio is focused. + * + * Wait for the first radio to be rendered before tabbing. + * This is necessary because the first radio may not be rendered + * when the page first loads. + * + * This would cause the first radio to be skipped when tabbing. + */ + await radio.waitFor(); + } }); test('tabbing should switch between radio groups', async ({ page, pageUtils }) => { diff --git a/core/src/components/radio/test/legacy/a11y/radio.e2e.ts b/core/src/components/radio/test/legacy/a11y/radio.e2e.ts index af6ccbfeb2..98ccc80a46 100644 --- a/core/src/components/radio/test/legacy/a11y/radio.e2e.ts +++ b/core/src/components/radio/test/legacy/a11y/radio.e2e.ts @@ -6,9 +6,23 @@ import { configs, test } from '@utils/test/playwright'; */ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => { test.describe(title('radio: a11y'), () => { - test.beforeEach(async ({ page, skip }) => { - skip.browser('webkit', 'Tabbing is flaky in Safari'); + test.beforeEach(async ({ page, browserName }) => { await page.goto(`/src/components/radio/test/legacy/a11y`, config); + + if (browserName === 'webkit') { + const radio = page.locator('#first-group ion-radio').first(); + /** + * Sometimes Safari does not focus the first radio. + * This is a workaround to ensure the first radio is focused. + * + * Wait for the first radio to be rendered before tabbing. + * This is necessary because the first radio may not be rendered + * when the page first loads. + * + * This would cause the first radio to be skipped when tabbing. + */ + await radio.waitFor(); + } }); test('tabbing should switch between radio groups', async ({ page, pageUtils }) => { const firstGroupRadios = page.locator('#first-group ion-radio');