From 1ec177831a0e2531b041f2e7063a2c56f8c3c86e Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 9 Oct 2024 12:35:43 +0200 Subject: [PATCH 1/4] Remove the verb Toggle from the Block Inserter button. --- packages/e2e-test-utils/src/inserter.js | 14 +++++------ .../components/header/document-tools/index.js | 2 +- .../src/components/document-tools/index.js | 2 +- test/e2e/specs/editor/blocks/columns.spec.js | 6 ++--- test/e2e/specs/editor/blocks/group.spec.js | 2 +- test/e2e/specs/editor/blocks/image.spec.js | 2 +- .../editor/plugins/allowed-blocks.spec.js | 4 +--- .../editor/plugins/block-directory.spec.js | 4 ++-- .../specs/editor/plugins/block-icons.spec.js | 10 ++++---- .../editor/plugins/block-variations.spec.js | 8 ++----- .../specs/editor/plugins/child-blocks.spec.js | 6 ++--- .../inner-blocks-allowed-blocks.spec.js | 4 ++-- .../editor/plugins/pattern-recursion.spec.js | 6 ++--- .../editor/plugins/post-type-locking.spec.js | 2 +- .../plugins/register-block-type-hooks.spec.js | 2 +- test/e2e/specs/editor/various/a11y.spec.js | 4 ++-- .../editor/various/adding-patterns.spec.js | 2 +- .../editor/various/allowed-patterns.spec.js | 4 ++-- .../editor/various/block-visibility.spec.js | 24 +++++-------------- .../specs/editor/various/editor-modes.spec.js | 2 +- .../editor/various/inserting-blocks.spec.js | 22 ++++++++--------- .../editor/various/parsing-patterns.spec.js | 2 +- .../e2e/specs/editor/various/patterns.spec.js | 8 +++---- .../various/shortcut-focus-toolbar.spec.js | 4 ++-- .../block-style-variations.spec.js | 2 +- test/e2e/specs/site-editor/pages.spec.js | 2 +- .../site-editor/site-editor-inserter.spec.js | 6 ++--- test/e2e/specs/site-editor/style-book.spec.js | 2 +- .../e2e/specs/widgets/editing-widgets.spec.js | 4 ++-- test/performance/specs/post-editor.spec.js | 8 +++---- 30 files changed, 73 insertions(+), 97 deletions(-) diff --git a/packages/e2e-test-utils/src/inserter.js b/packages/e2e-test-utils/src/inserter.js index 5beab3c6205b6..90ea39b49f00d 100644 --- a/packages/e2e-test-utils/src/inserter.js +++ b/packages/e2e-test-utils/src/inserter.js @@ -49,12 +49,12 @@ async function isGlobalInserterOpen() { return !! document.querySelector( '.edit-post-header [aria-label="Add block"].is-pressed,' + '.edit-site-header-edit-mode [aria-label="Add block"].is-pressed,' + - '.edit-post-header [aria-label="Toggle block inserter"].is-pressed,' + - '.edit-site-header [aria-label="Toggle block inserter"].is-pressed,' + - '.edit-widgets-header [aria-label="Toggle block inserter"].is-pressed,' + + '.edit-post-header [aria-label="Block Inserter"].is-pressed,' + + '.edit-site-header [aria-label="Block Inserter"].is-pressed,' + + '.edit-widgets-header [aria-label="Block Inserter"].is-pressed,' + '.edit-widgets-header [aria-label="Add block"].is-pressed,' + '.edit-site-header-edit-mode__inserter-toggle.is-pressed,' + - '.editor-header [aria-label="Toggle block inserter"].is-pressed' + '.editor-header [aria-label="Block Inserter"].is-pressed' ); } ); } @@ -68,10 +68,10 @@ export async function toggleGlobalBlockInserter() { '.editor-document-tools__inserter-toggle,' + '.edit-post-header [aria-label="Add block"],' + '.edit-site-header [aria-label="Add block"],' + - '.edit-post-header [aria-label="Toggle block inserter"],' + - '.edit-site-header [aria-label="Toggle block inserter"],' + + '.edit-post-header [aria-label="Block Inserter"],' + + '.edit-site-header [aria-label="Block Inserter"],' + '.edit-widgets-header [aria-label="Add block"],' + - '.edit-widgets-header [aria-label="Toggle block inserter"],' + + '.edit-widgets-header [aria-label="Block Inserter"],' + '.edit-site-header-edit-mode__inserter-toggle' ); } diff --git a/packages/edit-widgets/src/components/header/document-tools/index.js b/packages/edit-widgets/src/components/header/document-tools/index.js index a0d69cde376cf..567a5e1240747 100644 --- a/packages/edit-widgets/src/components/header/document-tools/index.js +++ b/packages/edit-widgets/src/components/header/document-tools/index.js @@ -72,7 +72,7 @@ function DocumentTools() { /* translators: button label text should, if possible, be under 16 characters. */ label={ _x( - 'Toggle block inserter', + 'Block Inserter', 'Generic label for block inserter button' ) } size="compact" diff --git a/packages/editor/src/components/document-tools/index.js b/packages/editor/src/components/document-tools/index.js index 6a8c20c8d7055..146945f7343bf 100644 --- a/packages/editor/src/components/document-tools/index.js +++ b/packages/editor/src/components/document-tools/index.js @@ -96,7 +96,7 @@ function DocumentTools( { className, disableBlockTools = false } ) { /* translators: button label text should, if possible, be under 16 characters. */ const longLabel = _x( - 'Toggle block inserter', + 'Block Inserter', 'Generic label for block inserter button' ); const shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' ); diff --git a/test/e2e/specs/editor/blocks/columns.spec.js b/test/e2e/specs/editor/blocks/columns.spec.js index e322a52eeba10..eea6e321aacb1 100644 --- a/test/e2e/specs/editor/blocks/columns.spec.js +++ b/test/e2e/specs/editor/blocks/columns.spec.js @@ -33,10 +33,8 @@ test.describe( 'Columns', () => { .first() .click(); - // Toggle Block inserter - await page - .locator( 'role=button[name="Toggle block inserter"i]' ) - .click(); + // Block Inserter + await page.locator( 'role=button[name="Block Inserter"i]' ).click(); // Verify Column const inserterOptions = page.locator( diff --git a/test/e2e/specs/editor/blocks/group.spec.js b/test/e2e/specs/editor/blocks/group.spec.js index 871974c1f44dd..0d815872c0bbb 100644 --- a/test/e2e/specs/editor/blocks/group.spec.js +++ b/test/e2e/specs/editor/blocks/group.spec.js @@ -14,7 +14,7 @@ test.describe( 'Group', () => { } ) => { // Search for the group block and insert it. const inserterButton = page.locator( - 'role=button[name="Toggle block inserter"i]' + 'role=button[name="Block Inserter"i]' ); await inserterButton.click(); diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index 43527b48fbf70..0ae15f3b0a106 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -437,7 +437,7 @@ test.describe( 'Image', () => { async function openMediaTab() { const blockInserter = page.getByRole( 'button', { - name: 'Toggle block inserter', + name: 'Block Inserter', } ); const isClosed = ( await blockInserter.getAttribute( 'aria-pressed' ) ) === diff --git a/test/e2e/specs/editor/plugins/allowed-blocks.spec.js b/test/e2e/specs/editor/plugins/allowed-blocks.spec.js index 6c8f4ead41c6f..bfd258da8ed8c 100644 --- a/test/e2e/specs/editor/plugins/allowed-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/allowed-blocks.spec.js @@ -20,9 +20,7 @@ test.describe( 'Allowed Blocks Filter', () => { page, } ) => { // The paragraph block is available. - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); const searchbox = page .getByRole( 'region', { name: 'Block Library' } ) diff --git a/test/e2e/specs/editor/plugins/block-directory.spec.js b/test/e2e/specs/editor/plugins/block-directory.spec.js index f9bf1f8515186..a73ee9915806a 100644 --- a/test/e2e/specs/editor/plugins/block-directory.spec.js +++ b/test/e2e/specs/editor/plugins/block-directory.spec.js @@ -122,7 +122,7 @@ test.describe( 'Block Directory', () => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -209,7 +209,7 @@ test.describe( 'Block Directory', () => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); const blockLibrary = page.getByRole( 'region', { diff --git a/test/e2e/specs/editor/plugins/block-icons.spec.js b/test/e2e/specs/editor/plugins/block-icons.spec.js index 0418f4200afc0..454e3875d5490 100644 --- a/test/e2e/specs/editor/plugins/block-icons.spec.js +++ b/test/e2e/specs/editor/plugins/block-icons.spec.js @@ -26,7 +26,7 @@ test.describe( 'Block Icons', () => { test( 'Block with svg icon', async ( { editor, page } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -60,7 +60,7 @@ test.describe( 'Block Icons', () => { test( 'Block with dash icon', async ( { editor, page } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -100,7 +100,7 @@ test.describe( 'Block Icons', () => { test( 'Block with function icon', async ( { editor, page } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -137,7 +137,7 @@ test.describe( 'Block Icons', () => { } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -185,7 +185,7 @@ test.describe( 'Block Icons', () => { } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); const blockLibrary = page.getByRole( 'region', { diff --git a/test/e2e/specs/editor/plugins/block-variations.spec.js b/test/e2e/specs/editor/plugins/block-variations.spec.js index 653680b48e1e6..9ba56f3126ad0 100644 --- a/test/e2e/specs/editor/plugins/block-variations.spec.js +++ b/test/e2e/specs/editor/plugins/block-variations.spec.js @@ -21,9 +21,7 @@ test.describe( 'Block variations', () => { test( 'Search for the overridden default Quote block', async ( { page, } ) => { - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); await page .getByRole( 'region', { name: 'Block Library' } ) @@ -62,9 +60,7 @@ test.describe( 'Block variations', () => { test( 'Search for the Paragraph block with 2 additional variations', async ( { page, } ) => { - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); await page .getByRole( 'region', { name: 'Block Library' } ) diff --git a/test/e2e/specs/editor/plugins/child-blocks.spec.js b/test/e2e/specs/editor/plugins/child-blocks.spec.js index 0cd043c6a4610..187920eb17d3c 100644 --- a/test/e2e/specs/editor/plugins/child-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/child-blocks.spec.js @@ -19,7 +19,7 @@ test.describe( 'Child Blocks', () => { test( 'are hidden from the global block inserter', async ( { page } ) => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ); + .getByRole( 'button', { name: 'Block Inserter' } ); const blockLibrary = page.getByRole( 'region', { name: 'Block Library', } ); @@ -47,7 +47,7 @@ test.describe( 'Child Blocks', () => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ); + .getByRole( 'button', { name: 'Block Inserter' } ); const blockLibrary = page .getByRole( 'region', { name: 'Block Library', @@ -85,7 +85,7 @@ test.describe( 'Child Blocks', () => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ); + .getByRole( 'button', { name: 'Block Inserter' } ); const blockLibrary = page .getByRole( 'region', { name: 'Block Library', diff --git a/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js b/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js index d2dc521f0196b..4d20e96c6e600 100644 --- a/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js @@ -45,7 +45,7 @@ test.describe( 'Allowed Blocks Setting on InnerBlocks', () => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ); + .getByRole( 'button', { name: 'Block Inserter' } ); const blockLibrary = page .getByRole( 'region', { name: 'Block Library', @@ -92,7 +92,7 @@ test.describe( 'Allowed Blocks Setting on InnerBlocks', () => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ); + .getByRole( 'button', { name: 'Block Inserter' } ); const blockLibrary = page .getByRole( 'region', { name: 'Block Library', diff --git a/test/e2e/specs/editor/plugins/pattern-recursion.spec.js b/test/e2e/specs/editor/plugins/pattern-recursion.spec.js index 9a8292271be8e..9d7683fac6dee 100644 --- a/test/e2e/specs/editor/plugins/pattern-recursion.spec.js +++ b/test/e2e/specs/editor/plugins/pattern-recursion.spec.js @@ -59,10 +59,8 @@ test.describe( 'Preventing Pattern Recursion (server)', () => { page, editor, } ) => { - // Click the Toggle block inserter button - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + // Click the Block Inserter button + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); // Click the Patterns tab await page.getByRole( 'tab', { name: 'Patterns' } ).click(); // Click the Uncategorized tab diff --git a/test/e2e/specs/editor/plugins/post-type-locking.spec.js b/test/e2e/specs/editor/plugins/post-type-locking.spec.js index af6256d05e02e..e49b989517b1d 100644 --- a/test/e2e/specs/editor/plugins/post-type-locking.spec.js +++ b/test/e2e/specs/editor/plugins/post-type-locking.spec.js @@ -208,7 +208,7 @@ test.describe( 'Post-type locking', () => { await expect( page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) ).toBeEnabled(); await editor.insertBlock( { name: 'core/list' } ); diff --git a/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js b/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js index 2ec62ffd056d3..a7e6f970179a4 100644 --- a/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js +++ b/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js @@ -18,7 +18,7 @@ test.describe( 'Register block type hooks', () => { } ); test( 'has a custom category for Paragraph block', async ( { page } ) => { - await page.click( 'role=button[name="Toggle block inserter"i]' ); + await page.click( 'role=button[name="Block Inserter"i]' ); expect( page.locator( diff --git a/test/e2e/specs/editor/various/a11y.spec.js b/test/e2e/specs/editor/various/a11y.spec.js index 8f63b57fda657..f116476989a13 100644 --- a/test/e2e/specs/editor/various/a11y.spec.js +++ b/test/e2e/specs/editor/various/a11y.spec.js @@ -40,10 +40,10 @@ test.describe( 'a11y (@firefox, @webkit)', () => { // This test assumes the Editor is not in Fullscreen mode. Check the // first tabbable element within the 'Editor top bar' region is the - // 'Toggle block inserter' button. + // 'Block Inserter' button. await pageUtils.pressKeys( 'Tab' ); await expect( - page.locator( 'role=button[name=/Toggle block inserter/i]' ) + page.locator( 'role=button[name=/Block Inserter/i]' ) ).toBeFocused(); } ); diff --git a/test/e2e/specs/editor/various/adding-patterns.spec.js b/test/e2e/specs/editor/various/adding-patterns.spec.js index b634798b45540..3226965b18d70 100644 --- a/test/e2e/specs/editor/various/adding-patterns.spec.js +++ b/test/e2e/specs/editor/various/adding-patterns.spec.js @@ -9,7 +9,7 @@ test.describe( 'adding patterns', () => { } ); test( 'should insert a block pattern', async ( { page, editor } ) => { - await page.getByLabel( 'Toggle block inserter' ).click(); + await page.getByLabel( 'Block Inserter' ).click(); await page.getByRole( 'tab', { name: 'Patterns' } ).click(); await page.fill( diff --git a/test/e2e/specs/editor/various/allowed-patterns.spec.js b/test/e2e/specs/editor/various/allowed-patterns.spec.js index a99b1f5c29106..00814e768ac98 100644 --- a/test/e2e/specs/editor/various/allowed-patterns.spec.js +++ b/test/e2e/specs/editor/various/allowed-patterns.spec.js @@ -18,7 +18,7 @@ test.describe( 'Allowed Patterns', () => { await admin.createNewPost(); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); await page @@ -61,7 +61,7 @@ test.describe( 'Allowed Patterns', () => { await admin.createNewPost(); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); await page diff --git a/test/e2e/specs/editor/various/block-visibility.spec.js b/test/e2e/specs/editor/various/block-visibility.spec.js index 814276af6e25f..69a0427fd21c1 100644 --- a/test/e2e/specs/editor/various/block-visibility.spec.js +++ b/test/e2e/specs/editor/various/block-visibility.spec.js @@ -42,9 +42,7 @@ test.describe( 'Block Visibility', () => { } ) .getByRole( 'button', { name: 'Close' } ) .click(); - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); await page .getByRole( 'region', { name: 'Block Library' } ) .getByRole( 'searchbox', { @@ -59,9 +57,7 @@ test.describe( 'Block Visibility', () => { 'Heading block should not be visible' ).toBeHidden(); - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); // Show heading block again. await BlockVisibilityUtils.openBlockVisibilityManager(); @@ -83,9 +79,7 @@ test.describe( 'Block Visibility', () => { } ) .getByRole( 'button', { name: 'Close' } ) .click(); - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); await page .getByRole( 'region', { name: 'Block Library' } ) .getByRole( 'searchbox', { @@ -117,9 +111,7 @@ test.describe( 'Block Visibility', () => { } ) .getByRole( 'button', { name: 'Close' } ) .click(); - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); await expect( page @@ -128,9 +120,7 @@ test.describe( 'Block Visibility', () => { 'Media category should not be visible' ).toBeHidden(); - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); // Show Media category blocks again. await BlockVisibilityUtils.openBlockVisibilityManager(); @@ -152,9 +142,7 @@ test.describe( 'Block Visibility', () => { } ) .getByRole( 'button', { name: 'Close' } ) .click(); - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); await expect( page diff --git a/test/e2e/specs/editor/various/editor-modes.spec.js b/test/e2e/specs/editor/various/editor-modes.spec.js index 95c409f0589e3..292ec0101b92e 100644 --- a/test/e2e/specs/editor/various/editor-modes.spec.js +++ b/test/e2e/specs/editor/various/editor-modes.spec.js @@ -115,7 +115,7 @@ test.describe( 'Editing modes (visual/HTML)', () => { await expect( page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) ).toBeDisabled(); // Go back to the visual editor. diff --git a/test/e2e/specs/editor/various/inserting-blocks.spec.js b/test/e2e/specs/editor/various/inserting-blocks.spec.js index 83b919585a695..38f8a2926ab21 100644 --- a/test/e2e/specs/editor/various/inserting-blocks.spec.js +++ b/test/e2e/specs/editor/various/inserting-blocks.spec.js @@ -72,7 +72,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { ); await page.click( - 'role=region[name="Editor top bar"i] >> role=button[name="Toggle block inserter"i]' + 'role=region[name="Editor top bar"i] >> role=button[name="Block Inserter"i]' ); await page.fill( @@ -135,7 +135,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { ); await page.click( - 'role=region[name="Editor top bar"i] >> role=button[name="Toggle block inserter"i]' + 'role=region[name="Editor top bar"i] >> role=button[name="Block Inserter"i]' ); await page.fill( @@ -191,7 +191,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { ); await page.click( - 'role=region[name="Editor top bar"i] >> role=button[name="Toggle block inserter"i]' + 'role=region[name="Editor top bar"i] >> role=button[name="Block Inserter"i]' ); const PATTERN_NAME = 'Standard'; @@ -283,7 +283,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { // Insert a synced pattern. await page.click( - 'role=region[name="Editor top bar"i] >> role=button[name="Toggle block inserter"i]' + 'role=region[name="Editor top bar"i] >> role=button[name="Block Inserter"i]' ); await page.fill( 'role=region[name="Block Library"i] >> role=searchbox[name="Search"i]', @@ -347,7 +347,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { ); await page.click( - 'role=region[name="Editor top bar"i] >> role=button[name="Toggle block inserter"i]' + 'role=region[name="Editor top bar"i] >> role=button[name="Block Inserter"i]' ); const PATTERN_NAME = 'Standard'; @@ -389,7 +389,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await admin.createNewPost(); const inserterButton = page.getByRole( 'button', { - name: 'Toggle block inserter', + name: 'Block Inserter', } ); const blockLibrary = page.getByRole( 'region', { name: 'Block Library', @@ -503,7 +503,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await editor.selectBlocks( paragraphBlock ); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); await page .getByRole( 'listbox', { name: 'Text' } ) @@ -624,7 +624,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await admin.createNewPost(); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); await page.getByRole( 'option', { name: 'More', exact: true } ).click(); @@ -646,7 +646,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await admin.createNewPost(); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); await page .getByRole( 'listbox', { name: 'Text' } ) @@ -674,7 +674,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); await page .getByRole( 'listbox', { name: 'Media' } ) @@ -726,7 +726,7 @@ test.describe( 'insert media from inserter', () => { } ) => { await admin.createNewPost(); - await page.getByLabel( 'Toggle block inserter' ).click(); + await page.getByLabel( 'Block Inserter' ).click(); await page.getByRole( 'tab', { name: 'Media' } ).click(); await page.getByRole( 'tab', { name: 'Images' } ).click(); await page.getByLabel( uploadedMedia.title.raw ).click(); diff --git a/test/e2e/specs/editor/various/parsing-patterns.spec.js b/test/e2e/specs/editor/various/parsing-patterns.spec.js index 62c8ba2de2410..f8538572c20e1 100644 --- a/test/e2e/specs/editor/various/parsing-patterns.spec.js +++ b/test/e2e/specs/editor/various/parsing-patterns.spec.js @@ -15,7 +15,7 @@ test.describe( 'Parsing patterns', () => { innerBlocks: [ { name: 'core/button', attributes: { text: 'a' } } ], } ); await page.keyboard.press( 'ArrowDown' ); - await page.getByLabel( 'Toggle block inserter' ).click(); + await page.getByLabel( 'Block Inserter' ).click(); await page.getByRole( 'tab', { name: 'Patterns' } ).click(); await page.evaluate( () => { diff --git a/test/e2e/specs/editor/various/patterns.spec.js b/test/e2e/specs/editor/various/patterns.spec.js index 7204f2bace51a..27386671757bc 100644 --- a/test/e2e/specs/editor/various/patterns.spec.js +++ b/test/e2e/specs/editor/various/patterns.spec.js @@ -63,7 +63,7 @@ test.describe( 'Unsynced pattern', () => { // Check that the new pattern is available in the inserter and that it gets inserted as // a plain paragraph block. - await page.getByLabel( 'Toggle block inserter' ).click(); + await page.getByLabel( 'Block Inserter' ).click(); await page .getByRole( 'tab', { name: 'Patterns', @@ -166,7 +166,7 @@ test.describe( 'Synced pattern', () => { ).toBe( true ); // Check that the new pattern is available in the inserter. - await page.getByLabel( 'Toggle block inserter' ).click(); + await page.getByLabel( 'Block Inserter' ).click(); await page .getByRole( 'tab', { name: 'Patterns', @@ -495,9 +495,7 @@ test.describe( 'Synced pattern', () => { attributes: { ref: id }, } ); - await page - .getByRole( 'button', { name: 'Toggle block inserter' } ) - .click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); await page .getByRole( 'searchbox', { name: 'Search', diff --git a/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js b/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js index cfaf4e0be9188..fc54a1a71c8da 100644 --- a/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js +++ b/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js @@ -201,11 +201,11 @@ class ToolbarUtils { this.pageUtils = pageUtils; this.documentToolbarButton = this.page.getByRole( 'button', { - name: 'Toggle block inserter', + name: 'Block Inserter', exact: true, } ); this.documentToolbarTooltip = this.page.locator( - 'text=Toggle block inserter' + 'text=Block Inserter' ); this.blockToolbarParagraphButton = this.page.getByRole( 'button', { name: 'Paragraph', diff --git a/test/e2e/specs/site-editor/block-style-variations.spec.js b/test/e2e/specs/site-editor/block-style-variations.spec.js index 97ebc74db8308..3c642ea9d1299 100644 --- a/test/e2e/specs/site-editor/block-style-variations.spec.js +++ b/test/e2e/specs/site-editor/block-style-variations.spec.js @@ -318,7 +318,7 @@ async function draftNewPage( page ) { // Create a Group block with 2 nested Group blocks. async function addPageContent( editor, page ) { const inserterButton = page.locator( - 'role=button[name="Toggle block inserter"i]' + 'role=button[name="Block Inserter"i]' ); await inserterButton.click(); await page.type( 'role=searchbox[name="Search"i]', 'Group' ); diff --git a/test/e2e/specs/site-editor/pages.spec.js b/test/e2e/specs/site-editor/pages.spec.js index 7a76db40337c2..ed16c6445a850 100644 --- a/test/e2e/specs/site-editor/pages.spec.js +++ b/test/e2e/specs/site-editor/pages.spec.js @@ -36,7 +36,7 @@ async function addPageContent( editor, page ) { .fill( 'Lorem ipsum dolor sit amet' ); // Insert into Page Content using global inserter. - await page.getByRole( 'button', { name: 'Toggle block inserter' } ).click(); + await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); await page.getByRole( 'option', { name: 'Heading', exact: true } ).click(); await editor.canvas .getByRole( 'document', { diff --git a/test/e2e/specs/site-editor/site-editor-inserter.spec.js b/test/e2e/specs/site-editor/site-editor-inserter.spec.js index acb0c5409f9b0..b51699632440f 100644 --- a/test/e2e/specs/site-editor/site-editor-inserter.spec.js +++ b/test/e2e/specs/site-editor/site-editor-inserter.spec.js @@ -24,13 +24,13 @@ test.describe( 'Site Editor Inserter', () => { test( 'inserter toggle button should toggle global inserter', async ( { page, } ) => { - await page.click( 'role=button[name="Toggle block inserter"i]' ); + await page.click( 'role=button[name="Block Inserter"i]' ); // Visibility check await expect( page.locator( 'role=searchbox[name="Search"i]' ) ).toBeVisible(); - await page.click( 'role=button[name="Toggle block inserter"i]' ); + await page.click( 'role=button[name="Block Inserter"i]' ); //Hidden State check await expect( page.locator( 'role=searchbox[name="Search"i]' ) @@ -43,7 +43,7 @@ test.describe( 'Site Editor Inserter', () => { editor, } ) => { const inserterButton = page.getByRole( 'button', { - name: 'Toggle block inserter', + name: 'Block Inserter', } ); const blockLibrary = page.getByRole( 'region', { name: 'Block Library', diff --git a/test/e2e/specs/site-editor/style-book.spec.js b/test/e2e/specs/site-editor/style-book.spec.js index 3f871d28ef941..9a34f30f82ff9 100644 --- a/test/e2e/specs/site-editor/style-book.spec.js +++ b/test/e2e/specs/site-editor/style-book.spec.js @@ -29,7 +29,7 @@ test.describe( 'Style Book', () => { test( 'should disable toolbar buttons when open', async ( { page } ) => { await expect( - page.locator( 'role=button[name="Toggle block inserter"i]' ) + page.locator( 'role=button[name="Block Inserter"i]' ) ).toBeDisabled(); await expect( page.locator( 'role=button[name="Tools"i]' ) diff --git a/test/e2e/specs/widgets/editing-widgets.spec.js b/test/e2e/specs/widgets/editing-widgets.spec.js index 92a264492c018..5ef90e7c24050 100644 --- a/test/e2e/specs/widgets/editing-widgets.spec.js +++ b/test/e2e/specs/widgets/editing-widgets.spec.js @@ -56,7 +56,7 @@ test.describe( 'Widgets screen', () => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); const blockLibrary = page.getByRole( 'region', { name: 'Block Library', @@ -698,7 +698,7 @@ class WidgetsScreen { if ( await blockLibrary.isHidden() ) { await this.#page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Toggle block inserter' } ) + .getByRole( 'button', { name: 'Block Inserter' } ) .click(); } diff --git a/test/performance/specs/post-editor.spec.js b/test/performance/specs/post-editor.spec.js index 20925ebb36587..7e2071d217726 100644 --- a/test/performance/specs/post-editor.spec.js +++ b/test/performance/specs/post-editor.spec.js @@ -369,7 +369,7 @@ test.describe( 'Post Editor Performance', () => { await admin.editPost( draftId ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { - name: 'Toggle block inserter', + name: 'Block Inserter', } ); const samples = 10; @@ -425,7 +425,7 @@ test.describe( 'Post Editor Performance', () => { await admin.editPost( draftId ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { - name: 'Toggle block inserter', + name: 'Block Inserter', } ); // Open Inserter. await globalInserterToggle.click(); @@ -484,7 +484,7 @@ test.describe( 'Post Editor Performance', () => { await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { - name: 'Toggle block inserter', + name: 'Block Inserter', } ); const paragraphBlockItem = page.locator( '.block-editor-inserter__menu .editor-block-list-item-paragraph' @@ -536,7 +536,7 @@ test.describe( 'Post Editor Performance', () => { await admin.createNewPost(); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { - name: 'Toggle block inserter', + name: 'Block Inserter', } ); const testPatterns = [ From 32038377b2b484b6b7be10ad44f162610c5511eb Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 9 Oct 2024 14:29:48 +0200 Subject: [PATCH 2/4] Adjust tests. --- .../src/components/inserter/menu.js | 2 +- .../secondary-sidebar/inserter-sidebar.js | 2 +- test/e2e/specs/editor/blocks/image.spec.js | 1 + .../editor/plugins/allowed-blocks.spec.js | 4 +++- .../editor/plugins/block-directory.spec.js | 4 ++-- .../specs/editor/plugins/block-icons.spec.js | 10 ++++---- .../editor/plugins/block-variations.spec.js | 8 +++++-- .../specs/editor/plugins/child-blocks.spec.js | 6 ++--- .../inner-blocks-allowed-blocks.spec.js | 4 ++-- .../editor/plugins/pattern-recursion.spec.js | 4 +++- .../editor/plugins/post-type-locking.spec.js | 5 +++- .../editor/various/allowed-patterns.spec.js | 4 ++-- .../editor/various/block-visibility.spec.js | 24 ++++++++++++++----- .../specs/editor/various/editor-modes.spec.js | 2 +- .../editor/various/inserting-blocks.spec.js | 9 +++---- .../e2e/specs/editor/various/patterns.spec.js | 4 +++- test/e2e/specs/site-editor/pages.spec.js | 4 +++- .../site-editor/site-editor-inserter.spec.js | 1 + .../e2e/specs/widgets/editing-widgets.spec.js | 4 ++-- test/performance/specs/post-editor.spec.js | 4 ++++ 20 files changed, 70 insertions(+), 36 deletions(-) diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index fa72728f6de20..bdd4ff11abcee 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -322,7 +322,7 @@ function InserterMenu( onSelect={ handleSetSelectedTab } onClose={ onClose } selectedTab={ selectedTab } - closeButtonLabel={ __( 'Close block inserter' ) } + closeButtonLabel={ __( 'Close Block Inserter' ) } tabs={ [ { name: 'blocks', diff --git a/packages/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js b/packages/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js index 156a15e2f460c..4b26dd306ea0a 100644 --- a/packages/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js +++ b/packages/edit-widgets/src/components/secondary-sidebar/inserter-sidebar.js @@ -47,7 +47,7 @@ export default function InserterSidebar() { __next40pxDefaultSize icon={ close } onClick={ closeInserter } - label={ __( 'Close block inserter' ) } + label={ __( 'Close Block Inserter' ) } />
diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index 0ae15f3b0a106..6110a125ff6f7 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -438,6 +438,7 @@ test.describe( 'Image', () => { async function openMediaTab() { const blockInserter = page.getByRole( 'button', { name: 'Block Inserter', + exact: true, } ); const isClosed = ( await blockInserter.getAttribute( 'aria-pressed' ) ) === diff --git a/test/e2e/specs/editor/plugins/allowed-blocks.spec.js b/test/e2e/specs/editor/plugins/allowed-blocks.spec.js index bfd258da8ed8c..ed7490afe84fe 100644 --- a/test/e2e/specs/editor/plugins/allowed-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/allowed-blocks.spec.js @@ -20,7 +20,9 @@ test.describe( 'Allowed Blocks Filter', () => { page, } ) => { // The paragraph block is available. - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); const searchbox = page .getByRole( 'region', { name: 'Block Library' } ) diff --git a/test/e2e/specs/editor/plugins/block-directory.spec.js b/test/e2e/specs/editor/plugins/block-directory.spec.js index a73ee9915806a..2fa4ee33e6c1a 100644 --- a/test/e2e/specs/editor/plugins/block-directory.spec.js +++ b/test/e2e/specs/editor/plugins/block-directory.spec.js @@ -122,7 +122,7 @@ test.describe( 'Block Directory', () => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -209,7 +209,7 @@ test.describe( 'Block Directory', () => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); const blockLibrary = page.getByRole( 'region', { diff --git a/test/e2e/specs/editor/plugins/block-icons.spec.js b/test/e2e/specs/editor/plugins/block-icons.spec.js index 454e3875d5490..3a00b41b9e71e 100644 --- a/test/e2e/specs/editor/plugins/block-icons.spec.js +++ b/test/e2e/specs/editor/plugins/block-icons.spec.js @@ -26,7 +26,7 @@ test.describe( 'Block Icons', () => { test( 'Block with svg icon', async ( { editor, page } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -60,7 +60,7 @@ test.describe( 'Block Icons', () => { test( 'Block with dash icon', async ( { editor, page } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -100,7 +100,7 @@ test.describe( 'Block Icons', () => { test( 'Block with function icon', async ( { editor, page } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -137,7 +137,7 @@ test.describe( 'Block Icons', () => { } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); const blockLibrary = page.getByRole( 'region', { @@ -185,7 +185,7 @@ test.describe( 'Block Icons', () => { } ) => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); const blockLibrary = page.getByRole( 'region', { diff --git a/test/e2e/specs/editor/plugins/block-variations.spec.js b/test/e2e/specs/editor/plugins/block-variations.spec.js index 9ba56f3126ad0..3f71d2b57d9fd 100644 --- a/test/e2e/specs/editor/plugins/block-variations.spec.js +++ b/test/e2e/specs/editor/plugins/block-variations.spec.js @@ -21,7 +21,9 @@ test.describe( 'Block variations', () => { test( 'Search for the overridden default Quote block', async ( { page, } ) => { - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); await page .getByRole( 'region', { name: 'Block Library' } ) @@ -60,7 +62,9 @@ test.describe( 'Block variations', () => { test( 'Search for the Paragraph block with 2 additional variations', async ( { page, } ) => { - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); await page .getByRole( 'region', { name: 'Block Library' } ) diff --git a/test/e2e/specs/editor/plugins/child-blocks.spec.js b/test/e2e/specs/editor/plugins/child-blocks.spec.js index 187920eb17d3c..765b4040a4b97 100644 --- a/test/e2e/specs/editor/plugins/child-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/child-blocks.spec.js @@ -19,7 +19,7 @@ test.describe( 'Child Blocks', () => { test( 'are hidden from the global block inserter', async ( { page } ) => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ); + .getByRole( 'button', { name: 'Block Inserter', exact: true } ); const blockLibrary = page.getByRole( 'region', { name: 'Block Library', } ); @@ -47,7 +47,7 @@ test.describe( 'Child Blocks', () => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ); + .getByRole( 'button', { name: 'Block Inserter', exact: true } ); const blockLibrary = page .getByRole( 'region', { name: 'Block Library', @@ -85,7 +85,7 @@ test.describe( 'Child Blocks', () => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ); + .getByRole( 'button', { name: 'Block Inserter', exact: true } ); const blockLibrary = page .getByRole( 'region', { name: 'Block Library', diff --git a/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js b/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js index 4d20e96c6e600..4ee6d7a0fc4fe 100644 --- a/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js @@ -45,7 +45,7 @@ test.describe( 'Allowed Blocks Setting on InnerBlocks', () => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ); + .getByRole( 'button', { name: 'Block Inserter', exact: true } ); const blockLibrary = page .getByRole( 'region', { name: 'Block Library', @@ -92,7 +92,7 @@ test.describe( 'Allowed Blocks Setting on InnerBlocks', () => { const blockInserter = page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ); + .getByRole( 'button', { name: 'Block Inserter', exact: true } ); const blockLibrary = page .getByRole( 'region', { name: 'Block Library', diff --git a/test/e2e/specs/editor/plugins/pattern-recursion.spec.js b/test/e2e/specs/editor/plugins/pattern-recursion.spec.js index 9d7683fac6dee..c688f3580c370 100644 --- a/test/e2e/specs/editor/plugins/pattern-recursion.spec.js +++ b/test/e2e/specs/editor/plugins/pattern-recursion.spec.js @@ -60,7 +60,9 @@ test.describe( 'Preventing Pattern Recursion (server)', () => { editor, } ) => { // Click the Block Inserter button - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); // Click the Patterns tab await page.getByRole( 'tab', { name: 'Patterns' } ).click(); // Click the Uncategorized tab diff --git a/test/e2e/specs/editor/plugins/post-type-locking.spec.js b/test/e2e/specs/editor/plugins/post-type-locking.spec.js index e49b989517b1d..ff02d18c51464 100644 --- a/test/e2e/specs/editor/plugins/post-type-locking.spec.js +++ b/test/e2e/specs/editor/plugins/post-type-locking.spec.js @@ -208,7 +208,10 @@ test.describe( 'Post-type locking', () => { await expect( page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { + name: 'Block Inserter', + exact: true, + } ) ).toBeEnabled(); await editor.insertBlock( { name: 'core/list' } ); diff --git a/test/e2e/specs/editor/various/allowed-patterns.spec.js b/test/e2e/specs/editor/various/allowed-patterns.spec.js index 00814e768ac98..01ca5ba0480c3 100644 --- a/test/e2e/specs/editor/various/allowed-patterns.spec.js +++ b/test/e2e/specs/editor/various/allowed-patterns.spec.js @@ -18,7 +18,7 @@ test.describe( 'Allowed Patterns', () => { await admin.createNewPost(); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); await page @@ -61,7 +61,7 @@ test.describe( 'Allowed Patterns', () => { await admin.createNewPost(); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); await page diff --git a/test/e2e/specs/editor/various/block-visibility.spec.js b/test/e2e/specs/editor/various/block-visibility.spec.js index 69a0427fd21c1..6e4163f4ed583 100644 --- a/test/e2e/specs/editor/various/block-visibility.spec.js +++ b/test/e2e/specs/editor/various/block-visibility.spec.js @@ -42,7 +42,9 @@ test.describe( 'Block Visibility', () => { } ) .getByRole( 'button', { name: 'Close' } ) .click(); - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); await page .getByRole( 'region', { name: 'Block Library' } ) .getByRole( 'searchbox', { @@ -57,7 +59,9 @@ test.describe( 'Block Visibility', () => { 'Heading block should not be visible' ).toBeHidden(); - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); // Show heading block again. await BlockVisibilityUtils.openBlockVisibilityManager(); @@ -79,7 +83,9 @@ test.describe( 'Block Visibility', () => { } ) .getByRole( 'button', { name: 'Close' } ) .click(); - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); await page .getByRole( 'region', { name: 'Block Library' } ) .getByRole( 'searchbox', { @@ -111,7 +117,9 @@ test.describe( 'Block Visibility', () => { } ) .getByRole( 'button', { name: 'Close' } ) .click(); - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); await expect( page @@ -120,7 +128,9 @@ test.describe( 'Block Visibility', () => { 'Media category should not be visible' ).toBeHidden(); - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); // Show Media category blocks again. await BlockVisibilityUtils.openBlockVisibilityManager(); @@ -142,7 +152,9 @@ test.describe( 'Block Visibility', () => { } ) .getByRole( 'button', { name: 'Close' } ) .click(); - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); await expect( page diff --git a/test/e2e/specs/editor/various/editor-modes.spec.js b/test/e2e/specs/editor/various/editor-modes.spec.js index 292ec0101b92e..4e856e6214ca8 100644 --- a/test/e2e/specs/editor/various/editor-modes.spec.js +++ b/test/e2e/specs/editor/various/editor-modes.spec.js @@ -115,7 +115,7 @@ test.describe( 'Editing modes (visual/HTML)', () => { await expect( page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) ).toBeDisabled(); // Go back to the visual editor. diff --git a/test/e2e/specs/editor/various/inserting-blocks.spec.js b/test/e2e/specs/editor/various/inserting-blocks.spec.js index 38f8a2926ab21..29b59b727acfe 100644 --- a/test/e2e/specs/editor/various/inserting-blocks.spec.js +++ b/test/e2e/specs/editor/various/inserting-blocks.spec.js @@ -390,6 +390,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { const inserterButton = page.getByRole( 'button', { name: 'Block Inserter', + exact: true, } ); const blockLibrary = page.getByRole( 'region', { name: 'Block Library', @@ -503,7 +504,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await editor.selectBlocks( paragraphBlock ); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); await page .getByRole( 'listbox', { name: 'Text' } ) @@ -624,7 +625,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await admin.createNewPost(); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); await page.getByRole( 'option', { name: 'More', exact: true } ).click(); @@ -646,7 +647,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await admin.createNewPost(); await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); await page .getByRole( 'listbox', { name: 'Text' } ) @@ -674,7 +675,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); await page .getByRole( 'listbox', { name: 'Media' } ) diff --git a/test/e2e/specs/editor/various/patterns.spec.js b/test/e2e/specs/editor/various/patterns.spec.js index 27386671757bc..00a68a9f08ea5 100644 --- a/test/e2e/specs/editor/various/patterns.spec.js +++ b/test/e2e/specs/editor/various/patterns.spec.js @@ -495,7 +495,9 @@ test.describe( 'Synced pattern', () => { attributes: { ref: id }, } ); - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); await page .getByRole( 'searchbox', { name: 'Search', diff --git a/test/e2e/specs/site-editor/pages.spec.js b/test/e2e/specs/site-editor/pages.spec.js index ed16c6445a850..4817651bac8f9 100644 --- a/test/e2e/specs/site-editor/pages.spec.js +++ b/test/e2e/specs/site-editor/pages.spec.js @@ -36,7 +36,9 @@ async function addPageContent( editor, page ) { .fill( 'Lorem ipsum dolor sit amet' ); // Insert into Page Content using global inserter. - await page.getByRole( 'button', { name: 'Block Inserter' } ).click(); + await page + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) + .click(); await page.getByRole( 'option', { name: 'Heading', exact: true } ).click(); await editor.canvas .getByRole( 'document', { diff --git a/test/e2e/specs/site-editor/site-editor-inserter.spec.js b/test/e2e/specs/site-editor/site-editor-inserter.spec.js index b51699632440f..04075cbedab30 100644 --- a/test/e2e/specs/site-editor/site-editor-inserter.spec.js +++ b/test/e2e/specs/site-editor/site-editor-inserter.spec.js @@ -44,6 +44,7 @@ test.describe( 'Site Editor Inserter', () => { } ) => { const inserterButton = page.getByRole( 'button', { name: 'Block Inserter', + exact: true, } ); const blockLibrary = page.getByRole( 'region', { name: 'Block Library', diff --git a/test/e2e/specs/widgets/editing-widgets.spec.js b/test/e2e/specs/widgets/editing-widgets.spec.js index 5ef90e7c24050..019e07fe87daa 100644 --- a/test/e2e/specs/widgets/editing-widgets.spec.js +++ b/test/e2e/specs/widgets/editing-widgets.spec.js @@ -56,7 +56,7 @@ test.describe( 'Widgets screen', () => { await page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); const blockLibrary = page.getByRole( 'region', { name: 'Block Library', @@ -698,7 +698,7 @@ class WidgetsScreen { if ( await blockLibrary.isHidden() ) { await this.#page .getByRole( 'toolbar', { name: 'Document tools' } ) - .getByRole( 'button', { name: 'Block Inserter' } ) + .getByRole( 'button', { name: 'Block Inserter', exact: true } ) .click(); } diff --git a/test/performance/specs/post-editor.spec.js b/test/performance/specs/post-editor.spec.js index 7e2071d217726..7dd975727d402 100644 --- a/test/performance/specs/post-editor.spec.js +++ b/test/performance/specs/post-editor.spec.js @@ -370,6 +370,7 @@ test.describe( 'Post Editor Performance', () => { await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Block Inserter', + exact: true, } ); const samples = 10; @@ -426,6 +427,7 @@ test.describe( 'Post Editor Performance', () => { await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Block Inserter', + exact: true, } ); // Open Inserter. await globalInserterToggle.click(); @@ -485,6 +487,7 @@ test.describe( 'Post Editor Performance', () => { const globalInserterToggle = page.getByRole( 'button', { name: 'Block Inserter', + exact: true, } ); const paragraphBlockItem = page.locator( '.block-editor-inserter__menu .editor-block-list-item-paragraph' @@ -537,6 +540,7 @@ test.describe( 'Post Editor Performance', () => { await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Block Inserter', + exact: true, } ); const testPatterns = [ From dd3dab91bce848c297445d06bb17902401fb39ad Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 9 Oct 2024 15:32:18 +0200 Subject: [PATCH 3/4] Try to fix performance test. --- test/performance/specs/post-editor.spec.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/performance/specs/post-editor.spec.js b/test/performance/specs/post-editor.spec.js index 7dd975727d402..7e2071d217726 100644 --- a/test/performance/specs/post-editor.spec.js +++ b/test/performance/specs/post-editor.spec.js @@ -370,7 +370,6 @@ test.describe( 'Post Editor Performance', () => { await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Block Inserter', - exact: true, } ); const samples = 10; @@ -427,7 +426,6 @@ test.describe( 'Post Editor Performance', () => { await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Block Inserter', - exact: true, } ); // Open Inserter. await globalInserterToggle.click(); @@ -487,7 +485,6 @@ test.describe( 'Post Editor Performance', () => { const globalInserterToggle = page.getByRole( 'button', { name: 'Block Inserter', - exact: true, } ); const paragraphBlockItem = page.locator( '.block-editor-inserter__menu .editor-block-list-item-paragraph' @@ -540,7 +537,6 @@ test.describe( 'Post Editor Performance', () => { await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Block Inserter', - exact: true, } ); const testPatterns = [ From b691c1bc786d46e50241a34e322a1866d782e20b Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Thu, 10 Oct 2024 21:28:41 +0900 Subject: [PATCH 4/4] Try to fix perf test --- test/performance/specs/post-editor.spec.js | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/test/performance/specs/post-editor.spec.js b/test/performance/specs/post-editor.spec.js index 7e2071d217726..becbf375eff2a 100644 --- a/test/performance/specs/post-editor.spec.js +++ b/test/performance/specs/post-editor.spec.js @@ -368,9 +368,11 @@ test.describe( 'Post Editor Performance', () => { // Go to the test page. await admin.editPost( draftId ); await perfUtils.disableAutosave(); - const globalInserterToggle = page.getByRole( 'button', { - name: 'Block Inserter', - } ); + const globalInserterToggle = page + .getByRole( 'region', { name: 'Editor top bar' } ) + .getByRole( 'button', { + name: 'Block Inserter', + } ); const samples = 10; const throwaway = 1; @@ -424,9 +426,11 @@ test.describe( 'Post Editor Performance', () => { // Go to the test page. await admin.editPost( draftId ); await perfUtils.disableAutosave(); - const globalInserterToggle = page.getByRole( 'button', { - name: 'Block Inserter', - } ); + const globalInserterToggle = page + .getByRole( 'region', { name: 'Editor top bar' } ) + .getByRole( 'button', { + name: 'Block Inserter', + } ); // Open Inserter. await globalInserterToggle.click(); @@ -483,9 +487,11 @@ test.describe( 'Post Editor Performance', () => { await admin.editPost( draftId ); await perfUtils.disableAutosave(); - const globalInserterToggle = page.getByRole( 'button', { - name: 'Block Inserter', - } ); + const globalInserterToggle = page + .getByRole( 'region', { name: 'Editor top bar' } ) + .getByRole( 'button', { + name: 'Block Inserter', + } ); const paragraphBlockItem = page.locator( '.block-editor-inserter__menu .editor-block-list-item-paragraph' ); @@ -535,9 +541,11 @@ test.describe( 'Post Editor Performance', () => { test( 'Run the test', async ( { page, admin, perfUtils } ) => { await admin.createNewPost(); await perfUtils.disableAutosave(); - const globalInserterToggle = page.getByRole( 'button', { - name: 'Block Inserter', - } ); + const globalInserterToggle = page + .getByRole( 'region', { name: 'Editor top bar' } ) + .getByRole( 'button', { + name: 'Block Inserter', + } ); const testPatterns = [ {