Skip to content

Commit

Permalink
Remove tab keypresses from webkit menu interaction tests
Browse files Browse the repository at this point in the history
Tab keypreses on webkit playwright are really flakey (or it's something in our code that we haven't isolated) so I've split out the webkit tests to test everything I can without using a tab keypress.
  • Loading branch information
jeryj committed Oct 18, 2023
1 parent f6d50ac commit b92bf04
Showing 1 changed file with 137 additions and 3 deletions.
140 changes: 137 additions & 3 deletions test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Navigation block - Frontend interactivity (@firefox, @webkit)', () => {
test.describe( 'Navigation block - Frontend interactivity', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'emptytheme' );
await requestUtils.deleteAllTemplates( 'wp_template_part' );
Expand Down Expand Up @@ -80,6 +80,51 @@ test.describe( 'Navigation block - Frontend interactivity (@firefox, @webkit)',
await expect( overlayMenuFirstElement ).toBeHidden();
await expect( openMenuButton ).toBeFocused();
} );

/**
* These are already tested within the Overlay Interactions test above, but Safari is flakey on the Tab
* keypresses (passes 50 - 70% of the time). Tab keypresses are testing fine manually in Safari, but not
* in the test. nce we figure out why the Tab keypresses are flakey in the test, we can
* remove this test and only rely on the Overlay Interactions test above and add a (@firefox, @webkit)
* directive to the describe() statement. https://github.com/WordPress/gutenberg/pull/55198
*/
test( 'Overlay menu interactions in Safari (@webkit)', async ( {
page,
pageUtils,
} ) => {
await page.goto( '/' );
const overlayMenuFirstElement = page.getByRole( 'link', {
name: 'Item 1',
} );
const openMenuButton = page.getByRole( 'button', {
name: 'Open menu',
} );

const closeMenuButton = page.getByRole( 'button', {
name: 'Close menu',
} );

// Test: overlay menu opens on click on open menu button
await expect( overlayMenuFirstElement ).toBeHidden();
await openMenuButton.click();
await expect( overlayMenuFirstElement ).toBeVisible();

// Test: overlay menu focuses on first element after opening
await expect( overlayMenuFirstElement ).toBeFocused();

// Not Tested: overlay menu traps focus

// Test: overlay menu closes on click on close menu button
await closeMenuButton.click();
await expect( overlayMenuFirstElement ).toBeHidden();

// Test: overlay menu closes on ESC key
await openMenuButton.click();
await expect( overlayMenuFirstElement ).toBeVisible();
await pageUtils.pressKeys( 'Escape' );
await expect( overlayMenuFirstElement ).toBeHidden();
await expect( openMenuButton ).toBeFocused();
} );
} );

test.describe( 'Submenu mouse and keyboard interactions', () => {
Expand Down Expand Up @@ -204,9 +249,98 @@ test.describe( 'Navigation block - Frontend interactivity (@firefox, @webkit)',
await page.keyboard.press( 'Tab' );
await expect( firstLevelElement ).toBeHidden();
} );

/**
* These are already tested within the Submenu Interactions test above, but Safari is flakey on the
* Tab keypresses (passes 50 - 70% of the time). Tab keypresses are testing fine manually in Safari,
* but not in the test. Once we figure out why the Tab keypresses are flakey in the test, we can
* remove this test and only rely on the Submenu interactions test above and add a (@firefox, @webkit)
* directive to the describe() statement. https://github.com/WordPress/gutenberg/pull/55198
*/
test( 'Submenu interactions on Safari (@webkit)', async ( {
page,
pageUtils,
} ) => {
await page.goto( '/' );
const simpleSubmenuButton = page.getByRole( 'button', {
name: 'Simple Submenu',
} );
const innerElement = page.getByRole( 'link', {
name: 'Simple Submenu Link 1',
} );
const complexSubmenuButton = page.getByRole( 'button', {
name: 'Complex Submenu',
} );
const nestedSubmenuButton = page.getByRole( 'button', {
name: 'Nested Submenu',
} );
const firstLevelElement = page.getByRole( 'link', {
name: 'Complex Submenu Link 1',
} );
const secondLevelElement = page.getByRole( 'link', {
name: 'Nested Submenu Link 1',
} );

// Test: submenu opens on click and focuses the button
await expect( innerElement ).toBeHidden();
await simpleSubmenuButton.click();
await expect( simpleSubmenuButton ).toBeFocused();
await expect( innerElement ).toBeVisible();

// Test: a second click closes the submenu
await simpleSubmenuButton.click();
await expect( simpleSubmenuButton ).toBeFocused();
await expect( innerElement ).toBeHidden();

// Test: submenu opens on Enter keypress
await simpleSubmenuButton.focus();
await pageUtils.pressKeys( 'Enter' );
await expect( simpleSubmenuButton ).toBeFocused();
await expect( innerElement ).toBeVisible();

// Test: submenu closes on second Enter keypress
await pageUtils.pressKeys( 'Enter' );
await expect( innerElement ).toBeHidden();
await expect( simpleSubmenuButton ).toBeFocused();

// Test: inner submenu opens on click and focuses the button
await complexSubmenuButton.click();
await expect( complexSubmenuButton ).toBeFocused();
await expect( firstLevelElement ).toBeVisible();
await expect( secondLevelElement ).toBeHidden();
// Click the inner menu button and check it opens the third level menu
await nestedSubmenuButton.click();
await expect( nestedSubmenuButton ).toBeFocused();
await expect( firstLevelElement ).toBeVisible();
await expect( secondLevelElement ).toBeVisible();

// Click the inner menu button and check it closes the third level menu
await nestedSubmenuButton.click();
await expect( nestedSubmenuButton ).toBeFocused();
await expect( firstLevelElement ).toBeVisible();
await expect( secondLevelElement ).toBeHidden();

// Do the same with Enter keypresses: open the third level menu
await pageUtils.pressKeys( 'Enter' );
await expect( nestedSubmenuButton ).toBeFocused();
await expect( firstLevelElement ).toBeVisible();
await expect( secondLevelElement ).toBeVisible();

// Close the third level menu
await pageUtils.pressKeys( 'Enter' );
await expect( nestedSubmenuButton ).toBeFocused();
await expect( firstLevelElement ).toBeVisible();
await expect( secondLevelElement ).toBeHidden();

// Close all the menus with click on a non-body element outside the menu
await page.getByText( 'Just another Gutenberg site' ).click();

Check failure on line 336 in test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 1

[chromium] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@webkit)

1) [chromium] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@WebKit) TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for getByText('Just another Gutenberg site') ============================================================ 334 | 335 | // Close all the menus with click on a non-body element outside the menu > 336 | await page.getByText( 'Just another Gutenberg site' ).click(); | ^ 337 | await expect( firstLevelElement ).toBeHidden(); 338 | 339 | // Tests not covered: Tabbing to close menus at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:336:58

Check failure on line 336 in test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 1

[chromium] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@webkit)

1) [chromium] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@WebKit) Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for getByText('Just another Gutenberg site') ============================================================ 334 | 335 | // Close all the menus with click on a non-body element outside the menu > 336 | await page.getByText( 'Just another Gutenberg site' ).click(); | ^ 337 | await expect( firstLevelElement ).toBeHidden(); 338 | 339 | // Tests not covered: Tabbing to close menus at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:336:58

Check failure on line 336 in test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 1

[chromium] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@webkit)

1) [chromium] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@WebKit) Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for getByText('Just another Gutenberg site') ============================================================ 334 | 335 | // Close all the menus with click on a non-body element outside the menu > 336 | await page.getByText( 'Just another Gutenberg site' ).click(); | ^ 337 | await expect( firstLevelElement ).toBeHidden(); 338 | 339 | // Tests not covered: Tabbing to close menus at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:336:58

Check failure on line 336 in test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[webkit] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@webkit)

1) [webkit] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@WebKit) TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for getByText('Just another Gutenberg site') ============================================================ 334 | 335 | // Close all the menus with click on a non-body element outside the menu > 336 | await page.getByText( 'Just another Gutenberg site' ).click(); | ^ 337 | await expect( firstLevelElement ).toBeHidden(); 338 | 339 | // Tests not covered: Tabbing to close menus at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:336:58

Check failure on line 336 in test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[webkit] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@webkit)

1) [webkit] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@WebKit) Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for getByText('Just another Gutenberg site') ============================================================ 334 | 335 | // Close all the menus with click on a non-body element outside the menu > 336 | await page.getByText( 'Just another Gutenberg site' ).click(); | ^ 337 | await expect( firstLevelElement ).toBeHidden(); 338 | 339 | // Tests not covered: Tabbing to close menus at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:336:58

Check failure on line 336 in test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 4

[webkit] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@webkit)

1) [webkit] › editor/blocks/navigation-frontend-interactivity.spec.js:260:3 › Navigation block - Frontend interactivity › Submenu mouse and keyboard interactions › Submenu interactions on Safari (@WebKit) Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for getByText('Just another Gutenberg site') ============================================================ 334 | 335 | // Close all the menus with click on a non-body element outside the menu > 336 | await page.getByText( 'Just another Gutenberg site' ).click(); | ^ 337 | await expect( firstLevelElement ).toBeHidden(); 338 | 339 | // Tests not covered: Tabbing to close menus at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:336:58
await expect( firstLevelElement ).toBeHidden();

// Tests not covered: Tabbing to close menus
} );
} );

test.describe( 'Submenus (Arrow setting)', () => {
test.describe( 'Submenus (Arrow setting) (@firefox, @webkit)', () => {
test.beforeEach( async ( { admin, editor, requestUtils } ) => {
await admin.visitSiteEditor( {
postId: 'emptytheme//header',
Expand Down Expand Up @@ -289,7 +423,7 @@ test.describe( 'Navigation block - Frontend interactivity (@firefox, @webkit)',
} );
} );

test.describe( 'Page list block', () => {
test.describe( 'Page list block (@firefox, @webkit)', () => {
test.beforeEach( async ( { admin, editor, requestUtils } ) => {
const parentPage = await requestUtils.createPage( {
title: 'Parent Page',
Expand Down

0 comments on commit b92bf04

Please sign in to comment.