- When you’re ready, submit your work for review, and an Editor will be able to approve it for you.
+ Your work will be reviewed and then approved.
- When you’re ready, submit your work for review, and an Editor will be able to approve it for you.
+ Your work will be reviewed and then approved.
- // @ts-ignore
+ // @ts-expect-error getPostType is not typed with 'wp_template_part' as argument.
select( coreStore ).getPostType( 'wp_template_part' )?.labels
?.add_new_item,
[]
@@ -77,7 +77,6 @@ export default function CreateTemplatePartModal( {
focusOnMount="firstContentElement"
size="medium"
>
- { /* @ts-ignore */ }
);
diff --git a/storybook/stories/foundations/design-language/elevation.mdx b/storybook/stories/foundations/design-language/elevation.mdx
index 11591568b3600c..fcacfd2ee5a8d6 100644
--- a/storybook/stories/foundations/design-language/elevation.mdx
+++ b/storybook/stories/foundations/design-language/elevation.mdx
@@ -1,4 +1,4 @@
-import { Meta, Typeset } from '@storybook/addon-docs/blocks';
+import { Meta, Typeset } from '@storybook/blocks';
import elevation from './static/elevation.svg';
import elevationExamples from './static/elevation-examples.svg';
diff --git a/storybook/stories/foundations/design-language/radius.mdx b/storybook/stories/foundations/design-language/radius.mdx
index 9117bf940d45a2..2cf5b05a92efee 100644
--- a/storybook/stories/foundations/design-language/radius.mdx
+++ b/storybook/stories/foundations/design-language/radius.mdx
@@ -1,4 +1,4 @@
-import { Meta, Typeset } from '@storybook/addon-docs/blocks';
+import { Meta, Typeset } from '@storybook/blocks';
import radius from './static/radius.svg';
import radiusDo from './static/radius-do.svg';
import radiusDont from './static/radius-dont.svg';
@@ -31,25 +31,29 @@ These steps are defined as tokens. To view the values and understand how to use
- Accessibility: Larger radius values can create a more approachable and friendly appearance, especially for larger components like cards and modals that demand more attention from users.
-
- ✅ Do |
- 🚫 Don't |
-
-
-
-
-
- - Scale application of radius with element or container size.
-
- - Use `radius-round` for circles and `radius-full` for pills.
- |
-
-
-
- - Don't nest larger radii inside smaller radii.
-
- - Don't apply the same
- radius value to container and immediate descendent.
- |
-
+
+
+ ✅ Do |
+ 🚫 Don't |
+
+
+
+
+
+
+
+ - Scale application of radius with element or container size.
+
+ - Use `radius-round` for circles and `radius-full` for pills.
+ |
+
+
+
+ - Don't nest larger radii inside smaller radii.
+
+ - Don't apply the same
+ radius value to container and immediate descendent.
+ |
+
+
diff --git a/storybook/stories/tokens/elevation.mdx b/storybook/stories/tokens/elevation.mdx
index 5afb7e75266c4a..b3b0cd1a881b40 100644
--- a/storybook/stories/tokens/elevation.mdx
+++ b/storybook/stories/tokens/elevation.mdx
@@ -1,4 +1,4 @@
-import { Meta } from '@storybook/addon-docs/blocks';
+import { Meta } from '@storybook/blocks';
import { TokensTable } from './components.tsx';
diff --git a/storybook/stories/tokens/typography.mdx b/storybook/stories/tokens/typography.mdx
index c3b49b2865f186..9d0e4aedf8c017 100644
--- a/storybook/stories/tokens/typography.mdx
+++ b/storybook/stories/tokens/typography.mdx
@@ -1,4 +1,4 @@
-import { Meta, Typeset } from '@storybook/addon-docs/blocks';
+import { Meta, Typeset } from '@storybook/blocks';
diff --git a/test/e2e/specs/editor/blocks/columns.spec.js b/test/e2e/specs/editor/blocks/columns.spec.js
index eea6e321aacb11..29262aef810d21 100644
--- a/test/e2e/specs/editor/blocks/columns.spec.js
+++ b/test/e2e/specs/editor/blocks/columns.spec.js
@@ -63,7 +63,7 @@ test.describe( 'Columns', () => {
);
await editor.clickBlockToolbarButton( 'Options' );
await page.click( 'role=menuitem[name="Lock"i]' );
- await page.locator( 'role=checkbox[name="Prevent removal"i]' ).check();
+ await page.locator( 'role=checkbox[name="Lock removal"i]' ).check();
await page.click( 'role=button[name="Apply"i]' );
// Select columns block
diff --git a/test/e2e/specs/editor/various/block-locking.spec.js b/test/e2e/specs/editor/various/block-locking.spec.js
index eafb468902ef92..a8895d282fb956 100644
--- a/test/e2e/specs/editor/various/block-locking.spec.js
+++ b/test/e2e/specs/editor/various/block-locking.spec.js
@@ -16,7 +16,7 @@ test.describe( 'Block Locking', () => {
await editor.clickBlockOptionsMenuItem( 'Lock' );
- await page.click( 'role=checkbox[name="Prevent removal"]' );
+ await page.click( 'role=checkbox[name="Lock removal"]' );
await page.click( 'role=button[name="Apply"]' );
await expect(
@@ -35,7 +35,7 @@ test.describe( 'Block Locking', () => {
await editor.clickBlockOptionsMenuItem( 'Lock' );
- await page.click( 'role=checkbox[name="Disable movement"]' );
+ await page.click( 'role=checkbox[name="Lock movement"]' );
await page.click( 'role=button[name="Apply"]' );
// Hide options.
diff --git a/test/e2e/specs/editor/various/block-switcher.spec.js b/test/e2e/specs/editor/various/block-switcher.spec.js
index 41b0b1ee49c88c..cb95c4d395c664 100644
--- a/test/e2e/specs/editor/various/block-switcher.spec.js
+++ b/test/e2e/specs/editor/various/block-switcher.spec.js
@@ -107,7 +107,7 @@ test.describe( 'Block Switcher', () => {
await expect( button ).toBeEnabled();
await editor.clickBlockOptionsMenuItem( 'Lock' );
- await page.click( 'role=checkbox[name="Prevent removal"]' );
+ await page.click( 'role=checkbox[name="Lock removal"]' );
await page.click( 'role=button[name="Apply"]' );
// Verify the block switcher isn't enabled.
diff --git a/test/e2e/specs/site-editor/preload.spec.js b/test/e2e/specs/site-editor/preload.spec.js
index 2cd61283fbd9e8..e731e932e30523 100644
--- a/test/e2e/specs/site-editor/preload.spec.js
+++ b/test/e2e/specs/site-editor/preload.spec.js
@@ -6,6 +6,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'Preload', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'emptytheme' );
+ await requestUtils.resetPreferences();
} );
test.afterAll( async ( { requestUtils } ) => {
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 04075cbedab308..a730367d841bf8 100644
--- a/test/e2e/specs/site-editor/site-editor-inserter.spec.js
+++ b/test/e2e/specs/site-editor/site-editor-inserter.spec.js
@@ -5,8 +5,9 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'Site Editor Inserter', () => {
test.beforeAll( async ( { requestUtils } ) => {
+ // We need the theme to have a section root so zoom out is enabled
await Promise.all( [
- requestUtils.activateTheme( 'emptytheme' ),
+ requestUtils.activateTheme( 'twentytwentyfour' ),
requestUtils.deleteAllTemplates( 'wp_template' ),
requestUtils.deleteAllTemplates( 'wp_template_part' ),
] );
@@ -21,47 +22,303 @@ test.describe( 'Site Editor Inserter', () => {
await editor.canvas.locator( 'body' ).click();
} );
+ test.use( {
+ InserterUtils: async ( { editor, page }, use ) => {
+ await use( new InserterUtils( { editor, page } ) );
+ },
+ } );
+
+ // eslint-disable-next-line playwright/expect-expect
test( 'inserter toggle button should toggle global inserter', async ( {
- page,
+ InserterUtils,
} ) => {
- 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="Block Inserter"i]' );
- //Hidden State check
- await expect(
- page.locator( 'role=searchbox[name="Search"i]' )
- ).toBeHidden();
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.closeBlockLibrary();
} );
// A test for https://github.com/WordPress/gutenberg/issues/43090.
test( 'should close the inserter when clicking on the toggle button', async ( {
- page,
editor,
+ InserterUtils,
} ) => {
- const inserterButton = page.getByRole( 'button', {
- name: 'Block Inserter',
- exact: true,
- } );
- const blockLibrary = page.getByRole( 'region', {
- name: 'Block Library',
- } );
-
const beforeBlocks = await editor.getBlocks();
- await inserterButton.click();
- await blockLibrary.getByRole( 'tab', { name: 'Blocks' } ).click();
- await blockLibrary.getByRole( 'option', { name: 'Buttons' } ).click();
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await InserterUtils.blockLibrary
+ .getByRole( 'option', { name: 'Buttons' } )
+ .click();
await expect
.poll( editor.getBlocks )
.toMatchObject( [ ...beforeBlocks, { name: 'core/buttons' } ] );
- await inserterButton.click();
+ await InserterUtils.closeBlockLibrary();
+ } );
+
+ test.describe( 'Inserter Zoom Level UX', () => {
+ test.use( {
+ ZoomUtils: async ( { editor, page }, use ) => {
+ await use( new ZoomUtils( { editor, page } ) );
+ },
+ } );
+
+ test( 'should intialize correct active tab based on zoom level', async ( {
+ InserterUtils,
+ ZoomUtils,
+ } ) => {
+ await test.step( 'should open the inserter to blocks tab from default zoom level', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+
+ // Zoom canvas should not be active
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom canvas should not be active
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should open the inserter to patterns tab if zoomed out', async () => {
+ await ZoomUtils.enterZoomOut();
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Patterns' );
+
+ // Zoom canvas should still be active
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // We should still be in Zoom Out
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+ } );
+ } );
+
+ test( 'should set the correct zoom level when changing tabs', async ( {
+ InserterUtils,
+ ZoomUtils,
+ } ) => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await test.step( 'should zoom out when activating patterns tab', async () => {
+ await InserterUtils.activateTab( 'Patterns' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+ } );
+
+ await test.step( 'should reset zoom level when activating blocks tab', async () => {
+ await InserterUtils.activateTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should zoom out when activating media tab', async () => {
+ await InserterUtils.activateTab( 'Media' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+ } );
+ } );
+
+ test( 'should reset the zoom level when closing the inserter if we most recently changed the zoom level', async ( {
+ InserterUtils,
+ ZoomUtils,
+ } ) => {
+ await test.step( 'should reset zoom when closing from patterns tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Patterns' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should be reset
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should preserve default zoom level when closing from blocks tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Media' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await InserterUtils.activateTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should stay at default level
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should preserve default zoom level when closing from blocks tab even if user manually toggled zoom level on previous tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Media' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ // Toggle zoom level manually
+ await ZoomUtils.exitZoomOut();
+
+ await InserterUtils.activateTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should stay at default level
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
- await expect( blockLibrary ).toBeHidden();
+ await test.step( 'should preserve default zoom level when closing from blocks tab even if user manually toggled zoom level on previous tab twice', async () => {
+ // Open inserter
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Media' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ // Toggle zoom level manually twice
+ await ZoomUtils.exitZoomOut();
+ await ZoomUtils.enterZoomOut();
+
+ await InserterUtils.activateTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should stay at default level
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+ } );
+
+ test( 'should keep the zoom level manually set by the user if the user most recently set the zoom level', async ( {
+ InserterUtils,
+ ZoomUtils,
+ } ) => {
+ await test.step( 'should respect manual zoom level set when closing from patterns tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Patterns' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await ZoomUtils.exitZoomOut();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Zoom Level should stay reset
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+ } );
+
+ await test.step( 'should respect manual zoom level set when closing from patterns tab when toggled twice', async () => {
+ await InserterUtils.openBlockLibrary();
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await InserterUtils.activateTab( 'Patterns' );
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ await ZoomUtils.exitZoomOut();
+
+ await ZoomUtils.enterZoomOut();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Should stay zoomed out since it was manually engaged
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+
+ // Reset test
+ await ZoomUtils.exitZoomOut();
+ } );
+
+ await test.step( 'should not reset zoom level if zoom level manually changed from blocks tab', async () => {
+ await InserterUtils.openBlockLibrary();
+ await expect( InserterUtils.blockLibrary ).toBeVisible();
+
+ await InserterUtils.expectActiveTab( 'Blocks' );
+ await expect( ZoomUtils.zoomCanvas ).toBeHidden();
+
+ await ZoomUtils.enterZoomOut();
+
+ await InserterUtils.closeBlockLibrary();
+
+ // Should stay zoomed out since it was manually engaged
+ await expect( ZoomUtils.zoomCanvas ).toBeVisible();
+ } );
+ } );
} );
} );
+
+class InserterUtils {
+ constructor( { editor, page } ) {
+ this.editor = editor;
+ this.page = page;
+ this.blockLibrary = this.page.getByRole( 'region', {
+ name: 'Block Library',
+ } );
+ this.inserterButton = this.page.getByRole( 'button', {
+ name: 'Block Inserter',
+ exact: true,
+ } );
+ }
+
+ // Manually naming as open and close these makes it clearer when reading
+ // through the test instead of using a toggle method with a boolean
+ async openBlockLibrary() {
+ await this.inserterButton.click();
+ await expect( this.blockLibrary ).toBeVisible();
+ }
+
+ async closeBlockLibrary() {
+ await this.inserterButton.click();
+ await expect( this.blockLibrary ).toBeHidden();
+ }
+
+ getBlockLibraryTab( name ) {
+ return this.page.getByRole( 'tab', { name } );
+ }
+
+ async expectActiveTab( name ) {
+ await expect( this.getBlockLibraryTab( name ) ).toHaveAttribute(
+ 'aria-selected',
+ 'true'
+ );
+ }
+
+ async activateTab( name ) {
+ await this.getBlockLibraryTab( name ).click();
+ // For brevity, adding this check here. It should always be done after the tab is clicked
+ await this.expectActiveTab( name );
+ }
+}
+
+class ZoomUtils {
+ constructor( { editor, page } ) {
+ this.editor = editor;
+ this.page = page;
+ this.zoomCanvas = this.page.locator( '.is-zoomed-out' );
+ this.zoomButton = this.page.getByRole( 'button', {
+ name: 'Zoom Out',
+ exact: true,
+ } );
+ }
+
+ // Manually naming as enter and exit these makes it clearer when reading
+ // through the test instead of using a toggle method with a boolean
+ async enterZoomOut() {
+ await this.zoomButton.click();
+ await expect( this.zoomCanvas ).toBeVisible();
+ }
+
+ async exitZoomOut() {
+ await this.zoomButton.click();
+ await expect( this.zoomCanvas ).toBeHidden();
+ }
+}