{ __( 'Site Logo' ) }
-Typing in a metabox
"` - ); + /* + * `content` may or may not contain thetags depending on hasWpautop value in this line: + * https://github.com/WordPress/wordpress-develop/blob/2382765afa36e10bf3c74420024ad4e85763a47c/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js#L15 + * + * Now, for the purposes of this e2e test we explicitly set wpautop to true in the test plugin: + * https://github.com/WordPress/gutenberg/blob/3da717b8d0ac7d7821fc6d0475695ccf3ae2829f/packages/e2e-tests/plugins/wp-editor-metabox.php#L36 + * + * If this test randomly fails because of the actual value being wrapped in
like
Typing in a metabox
, it means that + * hasWpautop has been errorneously set to false in the line above. You may want to check: + * * Is window.wp.editor.autop a function? It should be one since https://github.com/WordPress/gutenberg/pull/33228 + * * Is wpautop still true in the second link mentioned in this comment? + * + * For more context, see https://github.com/WordPress/gutenberg/pull/33228/files#r666897885 + */ + expect( content ).toBe( 'Typing in a metabox' ); } ); } ); diff --git a/packages/e2e-tests/specs/editor/various/inserting-blocks.test.js b/packages/e2e-tests/specs/editor/various/inserting-blocks.test.js index cda28f6a511f9c..9e319c5a876a3a 100644 --- a/packages/e2e-tests/specs/editor/various/inserting-blocks.test.js +++ b/packages/e2e-tests/specs/editor/various/inserting-blocks.test.js @@ -57,7 +57,7 @@ describe( 'Inserting blocks', () => { return page.mouse.click( x, y ); } - it( 'Should insert content using the placeholder and the regular inserter', async () => { + it.skip( 'Should insert content using the placeholder and the regular inserter', async () => { // This ensures the editor is loaded in navigation mode. await page.reload(); await page.waitForSelector( '.edit-post-layout' ); diff --git a/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js b/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js index 357b0967197c96..81c4ca42a7cf9e 100644 --- a/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js +++ b/packages/e2e-tests/specs/experiments/multi-entity-saving.test.js @@ -82,7 +82,7 @@ describe( 'Multi-entity save flow', () => { expect( multiSaveButton ).toBeNull(); }; - it( 'Save flow should work as expected.', async () => { + it.skip( 'Save flow should work as expected.', async () => { await createNewPost(); // Edit the page some. await page.click( '.editor-post-title' ); diff --git a/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js b/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js index 5e8d80b1f45c51..cf229daa06a40c 100644 --- a/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js +++ b/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js @@ -145,7 +145,7 @@ describe( 'Post Editor Template mode', () => { ); } ); - it( 'Allow creating custom block templates in classic themes', async () => { + it.skip( 'Allow creating custom block templates in classic themes', async () => { await activateTheme( 'twentytwentyone' ); await createNewPost(); // Create a random post. diff --git a/packages/e2e-tests/specs/widgets/customizing-widgets.test.js b/packages/e2e-tests/specs/widgets/customizing-widgets.test.js index 701ece8f38220b..e61709adf0e834 100644 --- a/packages/e2e-tests/specs/widgets/customizing-widgets.test.js +++ b/packages/e2e-tests/specs/widgets/customizing-widgets.test.js @@ -150,7 +150,7 @@ describe( 'Widgets Customizer', () => { ); } ); - it( 'should open the inspector panel', async () => { + it.skip( 'should open the inspector panel', async () => { const widgetsPanel = await find( { role: 'heading', name: /Widgets/, @@ -700,6 +700,69 @@ describe( 'Widgets Customizer', () => { "The page delivered both an 'X-Frame-Options' header and a 'Content-Security-Policy' header with a 'frame-ancestors' directive. Although the 'X-Frame-Options' header alone would have blocked embedding, it has been ignored." ); } ); + + it( 'should move (inner) blocks to another sidebar', async () => { + const widgetsPanel = await find( { + role: 'heading', + name: /Widgets/, + level: 3, + } ); + await widgetsPanel.click(); + + const footer1Section = await find( { + role: 'heading', + name: /Footer #1/, + level: 3, + } ); + await footer1Section.click(); + + await addBlock( 'Paragraph' ); + await page.keyboard.type( 'First Paragraph' ); + + await showBlockToolbar(); + await clickBlockToolbarButton( 'Options' ); + const groupButton = await find( { + role: 'menuitem', + name: 'Group', + } ); + await groupButton.click(); + + // Refocus the paragraph block. + const paragraphBlock = await find( { + role: 'group', + name: 'Paragraph block', + value: 'First Paragraph', + } ); + await paragraphBlock.focus(); + await showBlockToolbar(); + await clickBlockToolbarButton( 'Move to widget area' ); + + const footer2Option = await find( { + role: 'menuitemradio', + name: 'Footer #2', + } ); + await footer2Option.click(); + + // Should switch to and expand Footer #2. + await expect( { + role: 'heading', + name: 'Customizing ▸ Widgets Footer #2', + } ).toBeFound(); + + // The paragraph block should be moved to the new sidebar and have focus. + const movedParagraphBlockQuery = { + role: 'group', + name: 'Paragraph block', + value: 'First Paragraph', + }; + await expect( movedParagraphBlockQuery ).toBeFound(); + const movedParagraphBlock = await find( movedParagraphBlockQuery ); + await expect( movedParagraphBlock ).toHaveFocus(); + + expect( console ).toHaveWarned( + "The page delivered both an 'X-Frame-Options' header and a 'Content-Security-Policy' header with a 'frame-ancestors' directive. Although the 'X-Frame-Options' header alone would have blocked embedding, it has been ignored." + ); + } ); } ); /** diff --git a/packages/e2e-tests/specs/widgets/editing-widgets.test.js b/packages/e2e-tests/specs/widgets/editing-widgets.test.js index 642af7ee8171b6..2395f444a16373 100644 --- a/packages/e2e-tests/specs/widgets/editing-widgets.test.js +++ b/packages/e2e-tests/specs/widgets/editing-widgets.test.js @@ -252,7 +252,7 @@ describe( 'Widgets screen', () => { ` ); } ); - it( 'Should insert content using the inline inserter', async () => { + it.skip( 'Should insert content using the inline inserter', async () => { const [ firstWidgetArea ] = await findAll( { role: 'group', name: 'Block: Widget Area', diff --git a/packages/widgets/src/blocks/legacy-widget/index.php b/packages/widgets/src/blocks/legacy-widget/index.php index 8a326056816c9d..e827f8f7c53096 100644 --- a/packages/widgets/src/blocks/legacy-widget/index.php +++ b/packages/widgets/src/blocks/legacy-widget/index.php @@ -29,6 +29,13 @@ function render_block_core_legacy_widget( $attributes ) { $widget_key = $wp_widget_factory->get_widget_key( $id_base ); $widget_object = $wp_widget_factory->get_widget_object( $id_base ); } else { + /* + * This file is copied from the published @wordpress/widgets package when WordPress + * Core is built. Because the package is a dependency of both WordPress Core and the + * Gutenberg plugin where the block editor is developed, this fallback condition is + * required until the minimum required version of WordPress for the plugin is raised + * to 5.8. + */ $widget_key = gutenberg_get_widget_key( $id_base ); $widget_object = gutenberg_get_widget_object( $id_base ); } diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 5b9cc20c3233d2..7498e298443493 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -16,6 +16,10 @@ function test_get_settings() { 'color' => array( 'custom' => false, ), + 'layout' => array( + 'contentSize' => 'value', + 'invalid/key' => 'value', + ), 'invalid/key' => 'value', 'blocks' => array( 'core/group' => array( @@ -44,6 +48,9 @@ function test_get_settings() { 'color' => array( 'custom' => false, ), + 'layout' => array( + 'contentSize' => 'value', + ), 'blocks' => array( 'core/group' => array( 'color' => array( @@ -649,6 +656,203 @@ public function test_merge_incoming_data() { $this->assertEqualSetsWithIndex( $expected, $actual ); } + public function test_merge_incoming_data_empty_presets() { + $theme_json = new WP_Theme_JSON_Gutenberg( + array( + 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, + 'settings' => array( + 'color' => array( + 'duotone' => array( + array( + 'slug' => 'value', + 'colors' => array( 'red', 'green' ), + ), + ), + 'gradients' => array( + array( + 'slug' => 'gradient', + 'gradient' => 'gradient', + ), + ), + 'palette' => array( + array( + 'slug' => 'red', + 'color' => 'red', + ), + ), + ), + 'spacing' => array( + 'units' => array( 'px', 'em' ), + ), + 'typography' => array( + 'fontSizes' => array( + array( + 'slug' => 'size', + 'value' => 'size', + ), + ), + ), + ), + ) + ); + + $theme_json->merge( + new WP_Theme_JSON_Gutenberg( + array( + 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, + 'settings' => array( + 'color' => array( + 'duotone' => array(), + 'gradients' => array(), + 'palette' => array(), + ), + 'spacing' => array( + 'units' => array(), + ), + 'typography' => array( + 'fontSizes' => array(), + ), + ), + ) + ) + ); + + $actual = $theme_json->get_raw_data(); + $expected = array( + 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, + 'settings' => array( + 'color' => array( + 'duotone' => array(), + 'gradients' => array( + 'theme' => array(), + ), + 'palette' => array( + 'theme' => array(), + ), + ), + 'spacing' => array( + 'units' => array(), + ), + 'typography' => array( + 'fontSizes' => array( + 'theme' => array(), + ), + ), + ), + ); + + $this->assertEqualSetsWithIndex( $expected, $actual ); + } + + public function test_merge_incoming_data_null_presets() { + $theme_json = new WP_Theme_JSON_Gutenberg( + array( + 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, + 'settings' => array( + 'color' => array( + 'duotone' => array( + array( + 'slug' => 'value', + 'colors' => array( 'red', 'green' ), + ), + ), + 'gradients' => array( + array( + 'slug' => 'gradient', + 'gradient' => 'gradient', + ), + ), + 'palette' => array( + array( + 'slug' => 'red', + 'color' => 'red', + ), + ), + ), + 'spacing' => array( + 'units' => array( 'px', 'em' ), + ), + 'typography' => array( + 'fontSizes' => array( + array( + 'slug' => 'size', + 'value' => 'size', + ), + ), + ), + ), + ) + ); + + $theme_json->merge( + new WP_Theme_JSON_Gutenberg( + array( + 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, + 'settings' => array( + 'color' => array( + 'custom' => false, + ), + 'spacing' => array( + 'customMargin' => false, + ), + 'typography' => array( + 'customLineHeight' => false, + ), + ), + ) + ) + ); + + $actual = $theme_json->get_raw_data(); + $expected = array( + 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA, + 'settings' => array( + 'color' => array( + 'custom' => false, + 'duotone' => array( + array( + 'slug' => 'value', + 'colors' => array( 'red', 'green' ), + ), + ), + 'gradients' => array( + 'theme' => array( + array( + 'slug' => 'gradient', + 'gradient' => 'gradient', + ), + ), + ), + 'palette' => array( + 'theme' => array( + array( + 'slug' => 'red', + 'color' => 'red', + ), + ), + ), + ), + 'spacing' => array( + 'customMargin' => false, + 'units' => array( 'px', 'em' ), + ), + 'typography' => array( + 'customLineHeight' => false, + 'fontSizes' => array( + 'theme' => array( + array( + 'slug' => 'size', + 'value' => 'size', + ), + ), + ), + ), + ), + ); + + $this->assertEqualSetsWithIndex( $expected, $actual ); + } + function test_remove_insecure_properties_removes_unsafe_styles() { $actual = WP_Theme_JSON_Gutenberg::remove_insecure_properties( array(