From 89ed873c09f0ea0cf92d1e86b14c8fd4dde35998 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Mon, 20 Feb 2023 13:25:22 +0800 Subject: [PATCH 1/4] Try to fix a11y test flakiness --- test/e2e/specs/editor/various/a11y.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/e2e/specs/editor/various/a11y.spec.js b/test/e2e/specs/editor/various/a11y.spec.js index 4e37c08b08e0cf..750aa5094e28b6 100644 --- a/test/e2e/specs/editor/various/a11y.spec.js +++ b/test/e2e/specs/editor/various/a11y.spec.js @@ -157,6 +157,10 @@ test.describe( 'a11y (@firefox, @webkit)', () => { // in the UI. This isn't part of the user flow we want to test. await tab.click(); await tab.focus(); + // Perform actionability checks implicitly to wait for the modal content + // to be attached with certain attributes. This is necessary for solving + // a flaky result where Playwright runs too fast before DOM catching up. + await expect( preferencesModalContent ).toBeVisible(); } // The General tab panel content is short and not scrollable. From 4447b900699dce2da4dfba1a55d6551cb045058c Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Mon, 20 Feb 2023 17:06:12 +0800 Subject: [PATCH 2/4] Try a different approach --- test/e2e/specs/editor/various/a11y.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/e2e/specs/editor/various/a11y.spec.js b/test/e2e/specs/editor/various/a11y.spec.js index 750aa5094e28b6..b51f5de9ea37d7 100644 --- a/test/e2e/specs/editor/various/a11y.spec.js +++ b/test/e2e/specs/editor/various/a11y.spec.js @@ -176,6 +176,10 @@ test.describe( 'a11y (@firefox, @webkit)', () => { await clickAndFocusTab( blocksTab ); await page.keyboard.press( 'Shift+Tab' ); await expect( closeButton ).toBeFocused(); + await expect( preferencesModalContent ).toHaveAttribute( + 'aria-label', + 'Scrollable section' + ); await page.keyboard.press( 'Shift+Tab' ); await expect( preferencesModalContent ).toBeFocused(); From dbe065b86d9f070189fa3b933152061e8382362f Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Mon, 20 Feb 2023 23:04:06 +0800 Subject: [PATCH 3/4] Try a different approach --- test/e2e/specs/editor/various/a11y.spec.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/e2e/specs/editor/various/a11y.spec.js b/test/e2e/specs/editor/various/a11y.spec.js index b51f5de9ea37d7..361a9de7f69d34 100644 --- a/test/e2e/specs/editor/various/a11y.spec.js +++ b/test/e2e/specs/editor/various/a11y.spec.js @@ -157,10 +157,6 @@ test.describe( 'a11y (@firefox, @webkit)', () => { // in the UI. This isn't part of the user flow we want to test. await tab.click(); await tab.focus(); - // Perform actionability checks implicitly to wait for the modal content - // to be attached with certain attributes. This is necessary for solving - // a flaky result where Playwright runs too fast before DOM catching up. - await expect( preferencesModalContent ).toBeVisible(); } // The General tab panel content is short and not scrollable. @@ -174,13 +170,16 @@ test.describe( 'a11y (@firefox, @webkit)', () => { // The Blocks tab panel content is long and scrollable. // Check it's focusable. await clickAndFocusTab( blocksTab ); - await page.keyboard.press( 'Shift+Tab' ); - await expect( closeButton ).toBeFocused(); + // Explicitly wait for the modal content to be attached with certain attributes. + // This is necessary for solving a flaky result where Playwright runs too fast + // before DOM catching up. await expect( preferencesModalContent ).toHaveAttribute( 'aria-label', 'Scrollable section' ); await page.keyboard.press( 'Shift+Tab' ); + await expect( closeButton ).toBeFocused(); + await page.keyboard.press( 'Shift+Tab' ); await expect( preferencesModalContent ).toBeFocused(); // Make the Blocks tab panel content shorter by searching for a block From 298ada7d5ae85290c96d5434f1816ccb51a40625 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Tue, 21 Feb 2023 00:21:42 +0800 Subject: [PATCH 4/4] Use tabindex --- test/e2e/specs/editor/various/a11y.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/editor/various/a11y.spec.js b/test/e2e/specs/editor/various/a11y.spec.js index 361a9de7f69d34..b73ba5469c0d63 100644 --- a/test/e2e/specs/editor/various/a11y.spec.js +++ b/test/e2e/specs/editor/various/a11y.spec.js @@ -174,8 +174,8 @@ test.describe( 'a11y (@firefox, @webkit)', () => { // This is necessary for solving a flaky result where Playwright runs too fast // before DOM catching up. await expect( preferencesModalContent ).toHaveAttribute( - 'aria-label', - 'Scrollable section' + 'tabindex', + '0' ); await page.keyboard.press( 'Shift+Tab' ); await expect( closeButton ).toBeFocused();