From 22630eeb537160fe2cfa80927a11eecb2c6ea8ce Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Mon, 24 Feb 2025 14:15:59 +0100 Subject: [PATCH] Adjust tests. --- test/e2e/specs/editor/various/a11y.spec.js | 26 ++++++++++++++----- .../editor/various/fullscreen-mode.spec.js | 10 +++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/test/e2e/specs/editor/various/a11y.spec.js b/test/e2e/specs/editor/various/a11y.spec.js index f116476989a133..1f5dec0b9882f5 100644 --- a/test/e2e/specs/editor/various/a11y.spec.js +++ b/test/e2e/specs/editor/various/a11y.spec.js @@ -21,6 +21,7 @@ test.describe( 'a11y (@firefox, @webkit)', () => { page, pageUtils, editor, + browserName, } ) => { // To do: run with iframe. await editor.switchToLegacyCanvas(); @@ -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(); } ); test( 'should constrain tabbing within a modal', async ( { diff --git a/test/e2e/specs/editor/various/fullscreen-mode.spec.js b/test/e2e/specs/editor/various/fullscreen-mode.spec.js index 8b7a0785a7ed6d..d8bb1380593fd1 100644 --- a/test/e2e/specs/editor/various/fullscreen-mode.spec.js +++ b/test/e2e/specs/editor/various/fullscreen-mode.spec.js @@ -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 ( {