Skip to content

Commit

Permalink
Adjust tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia committed Feb 24, 2025
1 parent 90878da commit 22630ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
26 changes: 20 additions & 6 deletions test/e2e/specs/editor/various/a11y.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test.describe( 'a11y (@firefox, @webkit)', () => {
page,
pageUtils,
editor,
browserName,
} ) => {
// To do: run with iframe.
await editor.switchToLegacyCanvas();
Expand All @@ -38,13 +39,26 @@ test.describe( 'a11y (@firefox, @webkit)', () => {
// Navigate to the 'Editor top bar' region.
await pageUtils.pressKeys( 'ctrl+`' );

// This test assumes the Editor is not in Fullscreen mode. Check the
// first tabbable element within the 'Editor top bar' region is the
// 'Block Inserter' button.
await pageUtils.pressKeys( 'Tab' );
await expect(
page.locator( 'role=button[name=/Block Inserter/i]' )
).toBeFocused();

const isFullScreenMode = await page.evaluate( () => {
return window.wp.data
.select( 'core/edit-post' )
.isFeatureActive( 'fullscreenMode' );
} );
// When full screen mode is enabled, check the first tabbable element
// within the 'Editor top bar' region is the 'View Posts' link otherwise
// check it's the 'Block Inserter' button.
// In webkit (Safari) links aren't tabbable by default so we always test
// for the 'Block Inserter' button.
let elementToTest = isFullScreenMode
? 'role=link[name=/View Posts/i]'
: 'role=button[name=/Block Inserter/i]';
if ( browserName === 'webkit' ) {
elementToTest = 'role=button[name=/Block Inserter/i]';
}

await expect( page.locator( elementToTest ) ).toBeFocused();

Check failure on line 61 in test/e2e/specs/editor/various/a11y.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 7

[webkit] › editor/various/a11y.spec.js:20:2 › a11y (@firefox

1) [webkit] › editor/various/a11y.spec.js:20:2 › a11y (@Firefox, @WebKit) › navigating through the Editor regions four times should land on the Editor top bar region Error: Timed out 5000ms waiting for expect(locator).toBeFocused() Locator: locator('role=button[name=/Block Inserter/i]') Expected: focused Received: inactive Call log: - expect.toBeFocused with timeout 5000ms - waiting for locator('role=button[name=/Block Inserter/i]') 9 × locator resolved to <button id=":r1:" type="button" aria-pressed="false" aria-expanded="false" data-active-item="true" data-toolbar-item="true" aria-label="Block Inserter" class="components-button components-toolbar-button editor-document-tools__inserter-toggle is-primary is-compact has-icon">…</button> - unexpected value "not focused" 59 | } 60 | > 61 | await expect( page.locator( elementToTest ) ).toBeFocused(); | ^ 62 | } ); 63 | 64 | test( 'should constrain tabbing within a modal', async ( { at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/a11y.spec.js:61:49

Check failure on line 61 in test/e2e/specs/editor/various/a11y.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 7

[webkit] › editor/various/a11y.spec.js:20:2 › a11y (@firefox

1) [webkit] › editor/various/a11y.spec.js:20:2 › a11y (@Firefox, @WebKit) › navigating through the Editor regions four times should land on the Editor top bar region Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toBeFocused() Locator: locator('role=button[name=/Block Inserter/i]') Expected: focused Received: inactive Call log: - expect.toBeFocused with timeout 5000ms - waiting for locator('role=button[name=/Block Inserter/i]') 9 × locator resolved to <button id=":r1:" type="button" aria-pressed="false" aria-expanded="false" data-active-item="true" data-toolbar-item="true" aria-label="Block Inserter" class="components-button components-toolbar-button editor-document-tools__inserter-toggle is-primary is-compact has-icon">…</button> - unexpected value "not focused" 59 | } 60 | > 61 | await expect( page.locator( elementToTest ) ).toBeFocused(); | ^ 62 | } ); 63 | 64 | test( 'should constrain tabbing within a modal', async ( { at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/a11y.spec.js:61:49

Check failure on line 61 in test/e2e/specs/editor/various/a11y.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 7

[webkit] › editor/various/a11y.spec.js:20:2 › a11y (@firefox

1) [webkit] › editor/various/a11y.spec.js:20:2 › a11y (@Firefox, @WebKit) › navigating through the Editor regions four times should land on the Editor top bar region Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toBeFocused() Locator: locator('role=button[name=/Block Inserter/i]') Expected: focused Received: inactive Call log: - expect.toBeFocused with timeout 5000ms - waiting for locator('role=button[name=/Block Inserter/i]') 8 × locator resolved to <button id=":r1:" type="button" aria-pressed="false" aria-expanded="false" data-active-item="true" data-toolbar-item="true" aria-label="Block Inserter" class="components-button components-toolbar-button editor-document-tools__inserter-toggle is-primary is-compact has-icon">…</button> - unexpected value "not focused" 59 | } 60 | > 61 | await expect( page.locator( elementToTest ) ).toBeFocused(); | ^ 62 | } ); 63 | 64 | test( 'should constrain tabbing within a modal', async ( { at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/a11y.spec.js:61:49
} );

test( 'should constrain tabbing within a modal', async ( {
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/specs/editor/various/fullscreen-mode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Fullscreen Mode', () => {
test.beforeEach( async ( { admin } ) => {
test.beforeEach( async ( { admin, editor } ) => {
await admin.createNewPost();
await editor.setPreferences( 'core/edit-post', {
fullscreenMode: false,
} );
} );

test.afterEach( async ( { requestUtils } ) => {
test.afterEach( async ( { requestUtils, editor } ) => {
await requestUtils.deleteAllPosts();
await editor.setPreferences( 'core/edit-post', {
fullscreenMode: true,
} );
} );

test( 'should open the fullscreen mode from the more menu', async ( {
Expand Down

0 comments on commit 22630ee

Please sign in to comment.