diff --git a/backport-changelog/6.8/8212.md b/backport-changelog/6.8/8212.md index 30483af9e7b71..2a0019eae2809 100644 --- a/backport-changelog/6.8/8212.md +++ b/backport-changelog/6.8/8212.md @@ -2,3 +2,4 @@ https://github.com/WordPress/wordpress-develop/pull/8212 * https://github.com/WordPress/gutenberg/pull/68926 * https://github.com/WordPress/gutenberg/pull/69142 +* https://github.com/WordPress/gutenberg/pull/69241 diff --git a/backport-changelog/6.8/8261.md b/backport-changelog/6.8/8261.md new file mode 100644 index 0000000000000..d125d122cb3a4 --- /dev/null +++ b/backport-changelog/6.8/8261.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/8261 + +* https://github.com/WordPress/gutenberg/pull/68521 diff --git a/backport-changelog/6.8/8274.md b/backport-changelog/6.8/8274.md new file mode 100644 index 0000000000000..f841a6f010d6d --- /dev/null +++ b/backport-changelog/6.8/8274.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/8274 + +* https://github.com/WordPress/gutenberg/pull/69096 diff --git a/changelog.txt b/changelog.txt index 3a8e2bafd9567..68e13890ff280 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,191 +1,14 @@ == Changelog == -= 20.3.0-rc.2 = - -## Changelog - -### Enhancements - -- Disable hover animation on preview frame for classic themes. ([68976](https://github.com/WordPress/gutenberg/pull/68976)) - -#### Block Library -- Added discord in social links. ([68848](https://github.com/WordPress/gutenberg/pull/68848)) -- Featured Image block: Use resolution tool component. ([68471](https://github.com/WordPress/gutenberg/pull/68471)) -- Query block: Add option to ignore sticky posts behavior. ([69057](https://github.com/WordPress/gutenberg/pull/69057)) -- RSS: Border & Spacing support. ([66411](https://github.com/WordPress/gutenberg/pull/66411)) - -#### Global Styles -- Disable Clear button if there's no shadow. ([69092](https://github.com/WordPress/gutenberg/pull/69092)) -- Duotone Settings: Add `reset` button and improve toggle rendering in FiltersPanel. ([68672](https://github.com/WordPress/gutenberg/pull/68672)) -- Shadow Panel: Add reset button. ([68981](https://github.com/WordPress/gutenberg/pull/68981)) - -#### Post Editor -- Editor: Add loading state to the 'PageAttributesParent' component. ([69062](https://github.com/WordPress/gutenberg/pull/69062)) -- Editor: Add loading state to the 'PostAuthorCombobox' component. ([68991](https://github.com/WordPress/gutenberg/pull/68991)) -- Editor: Display error message when loading current post fails. ([68999](https://github.com/WordPress/gutenberg/pull/68999)) - -#### Block Editor -- Quick Inserter: Restore pattern search and insertion. ([69028](https://github.com/WordPress/gutenberg/pull/69028)) -- Update keyboard shortcuts to use `primaryShift+backspace` for block deletion. ([69074](https://github.com/WordPress/gutenberg/pull/69074)) - -#### Design Tools -- Archives: Add Color Support. ([68685](https://github.com/WordPress/gutenberg/pull/68685)) -- Categories: Add Color Support. ([68686](https://github.com/WordPress/gutenberg/pull/68686)) - -#### Components -- ComboboxControl: Add an `isLoading` prop to show a loading spinner. ([68990](https://github.com/WordPress/gutenberg/pull/68990)) - += 20.0.2 = ### Bug Fixes -- Exclude Iterator helpers from polyfills. ([69070](https://github.com/WordPress/gutenberg/pull/69070)) -- Fix Dependabot ignore statements. ([69144](https://github.com/WordPress/gutenberg/pull/69144)) - #### Block Editor -- Block popover: Fix scrolling over. ([68075](https://github.com/WordPress/gutenberg/pull/68075)) -- Display root appender when default block is disabled. ([68951](https://github.com/WordPress/gutenberg/pull/68951)) -- Fix regression for root appender logic. ([68994](https://github.com/WordPress/gutenberg/pull/68994)) -- Inserter: Remove block default icon from no results message. ([68693](https://github.com/WordPress/gutenberg/pull/68693)) -- Rename `aspect` property to `ratio` to carry the `defaultAspect` in `AspectRatioDropdown`. ([69085](https://github.com/WordPress/gutenberg/pull/69085)) -- Writing Flow: Restore early return for no block selection in tab nav hook. ([69079](https://github.com/WordPress/gutenberg/pull/69079)) - -#### Site Editor -- Edit Site: Fix Fields package private APIs error. ([68964](https://github.com/WordPress/gutenberg/pull/68964)) -- Fix: Site Editor should display a 404 message. ([69009](https://github.com/WordPress/gutenberg/pull/69009)) -- Use the same editor component for all routes. ([69093](https://github.com/WordPress/gutenberg/pull/69093)) +- Fix 'isBlockVisibleInTheInserter' selector helper performance ([68898](https://github.com/WordPress/gutenberg/pull/68898)) -#### Global Styles -- Fix: Additional CSS button not working after back navigation. ([68954](https://github.com/WordPress/gutenberg/pull/68954)) -- Fix: Missing 'No blocks found.' message for block search in editor. ([69036](https://github.com/WordPress/gutenberg/pull/69036)) - -#### Block Library -- Query Block: Fix 'parents' argument validation. ([68983](https://github.com/WordPress/gutenberg/pull/68983)) -- Social Links: Fix appender size in non-iframe editor. ([68215](https://github.com/WordPress/gutenberg/pull/68215)) - -#### REST API -- Add support for the 'ignore_sticky_posts' argument. ([68970](https://github.com/WordPress/gutenberg/pull/68970)) -- Fix: Prevent Errors in Header Processing and Encode URLs Properly. ([67780](https://github.com/WordPress/gutenberg/pull/67780)) - -#### Icons -- Fix the background, arrowUpLeft, keyboardReturn and square icons. ([69076](https://github.com/WordPress/gutenberg/pull/69076)) - -#### Font Library -- Refactor font variant components to use useId for checkbox IDs. ([69050](https://github.com/WordPress/gutenberg/pull/69050)) - -#### Block Directory -- Remove block icon from InstalledBlocksPrePublishPanel. ([69046](https://github.com/WordPress/gutenberg/pull/69046)) - -#### DataViews -- Fixed: Empty Pattern Overlap in Pattern Title in Dataviews Table Layout. ([68997](https://github.com/WordPress/gutenberg/pull/68997)) - -#### Media -- Add optional chain to sizes indexing of media details in edit-site. ([68995](https://github.com/WordPress/gutenberg/pull/68995)) - -#### CSS & Styling -- Enabled Full height in Additional CSS. ([68993](https://github.com/WordPress/gutenberg/pull/68993)) - -#### Block hooks -- Fix truncation of post content. ([68926](https://github.com/WordPress/gutenberg/pull/68926)) - -#### Interactivity API -- iAPI Router: Fix CSS rule order in some constructed style sheets. ([68923](https://github.com/WordPress/gutenberg/pull/68923)) -- iAPI Router: Revert "Handle styles assets on region-based navigation" ([69222](https://github.com/WordPress/gutenberg/pull/69222)) - - -### Accessibility - -#### Components -- Font Size Picker: Remove Custom option from FontSizePickerSelect dropdown. ([69038](https://github.com/WordPress/gutenberg/pull/69038)) - -#### Global Styles -- Add missing list role to the list of blocks in the global Styles. ([69027](https://github.com/WordPress/gutenberg/pull/69027)) - -#### Block API -- Block support: Preserve aria-label value in comment delimiter. ([69002](https://github.com/WordPress/gutenberg/pull/69002)) - -#### Block Editor -- [Block Editor]: A11y - Add and Update missing reduce-motion mixing. ([68417](https://github.com/WordPress/gutenberg/pull/68417)) - - -### Performance - -#### Post Editor -- Editor: Don't use selector shortcuts for the taxonomy queries. ([68998](https://github.com/WordPress/gutenberg/pull/68998)) -- Editor: Optimize 'PostAuthorCheck' component data selection. ([69105](https://github.com/WordPress/gutenberg/pull/69105)) - -#### Style Book -- Improve StyleBook resize responsiveness for Classic Theme. ([68980](https://github.com/WordPress/gutenberg/pull/68980)) - - -### Documentation - -- Added Missing Global Documentation. ([69104](https://github.com/WordPress/gutenberg/pull/69104)) -- Changed Inline Document Order. ([68992](https://github.com/WordPress/gutenberg/pull/68992)) -- wp-env: Add lifecycleScripts to the schema. ([68724](https://github.com/WordPress/gutenberg/pull/68724)) - - -### Code Quality - -- Core Data: Add type for term entity. ([69151](https://github.com/WordPress/gutenberg/pull/69151)) -- iAPI Router: Add missing changelog entry for #68923. ([68945](https://github.com/WordPress/gutenberg/pull/68945)) - -#### Block Library -- E2E: Add regression test for spacer block in themes without spacing units. ([68913](https://github.com/WordPress/gutenberg/pull/68913)) -- Navigation Link Block: Use stable variable for underline color styling. ([68953](https://github.com/WordPress/gutenberg/pull/68953)) -- Regenerate block fixtures. ([68982](https://github.com/WordPress/gutenberg/pull/68982)) -- Social Links: Remove redundant reduce-motion mixin. ([69000](https://github.com/WordPress/gutenberg/pull/69000)) - -#### Site Editor -- Fast follow: Redirections of deprecated site editor URLs. ([68971](https://github.com/WordPress/gutenberg/pull/68971)) -- Quality: Remove unused props and styles from SidebarNavigationScreen. ([68972](https://github.com/WordPress/gutenberg/pull/68972)) - -#### Block Editor -- Inserter: Remove unused no-results-icon styles. ([69018](https://github.com/WordPress/gutenberg/pull/69018)) - - -### Tools - -- PR Template: Suggest linking the issue. ([68924](https://github.com/WordPress/gutenberg/pull/68924)) -- Relocate changelog file for WP#6910 to 6.9 backports. ([69068](https://github.com/WordPress/gutenberg/pull/69068)) - -#### Build Tooling -- Fix installing svn during deploys. ([69047](https://github.com/WordPress/gutenberg/pull/69047)) -- Remove `react-native` dependabot group. ([69118](https://github.com/WordPress/gutenberg/pull/69118)) - -#### Testing -- e2e: Fix "add new" selector. ([69111](https://github.com/WordPress/gutenberg/pull/69111)) - - -### Various - -- Remove react-native dependabot group - Take 2. ([69122](https://github.com/WordPress/gutenberg/pull/69122)) - -#### Plugin -- Code Quality: Delete unused function from PHP Sync Issue generation script. ([68947](https://github.com/WordPress/gutenberg/pull/68947)) -- npm scripts: Use `node -p` instead of `echo`. ([68946](https://github.com/WordPress/gutenberg/pull/68946)) - - -## First-time contributors - -The following PRs were merged by first-time contributors: - -- @benazeer-ben: RSS: Border & Spacing support. ([66411](https://github.com/WordPress/gutenberg/pull/66411)) -- @grgar: Add optional chain to sizes indexing of media details in edit-site. ([68995](https://github.com/WordPress/gutenberg/pull/68995)) -- @Gulamdastgir-Momin: Added discord in social links. ([68848](https://github.com/WordPress/gutenberg/pull/68848)) -- @Juzar10: Fix: Prevent Errors in Header Processing and Encode URLs Properly. ([67780](https://github.com/WordPress/gutenberg/pull/67780)) -- @singhakanshu00: Disable hover animation on preview frame for classic themes. ([68976](https://github.com/WordPress/gutenberg/pull/68976)) -- @srtfisher: wp-env: Add lifecycleScripts to the schema. ([68724](https://github.com/WordPress/gutenberg/pull/68724)) - - -## Contributors - -The following contributors merged PRs in this release: - -@adamsilverstein @afercia @akasunil @benazeer-ben @carolinan @DAreRodz @desrosj @ellatrix @grgar @Gulamdastgir-Momin @himanshupathak95 @Infinite-Null @joemcgill @Juzar10 @Mamaduka @Mayank-Tripathi32 @ockham @peterwilsoncc @Rishit30G @SainathPoojary @shail-mehta @shimotmk @singhakanshu00 @srtfisher @swissspidy @t-hamano @torounit @yogeshbhutkar - - -= 20.3.0-rc.1 = += 20.3.0 = ## Changelog @@ -274,6 +97,7 @@ The following contributors merged PRs in this release: #### Interactivity API - iAPI Router: Fix CSS rule order in some constructed style sheets. ([68923](https://github.com/WordPress/gutenberg/pull/68923)) +- iAPI Router: Revert "Handle styles assets on region-based navigation" ([69222](https://github.com/WordPress/gutenberg/pull/69222)) ### Accessibility diff --git a/docs/getting-started/README.md b/docs/getting-started/README.md index f1b5999ae3147..f37316e3dcc52 100644 --- a/docs/getting-started/README.md +++ b/docs/getting-started/README.md @@ -29,7 +29,7 @@ The WordPress project, and Gutenberg in particular, iterates quickly. Staying up ## Additional resources -For more resources on block development and extending the Block Editor, review the additional sections here in the Block Editor Handbook. Further practical examples are also available in the [block-development-examples](https://github.com/wptrainingteam/block-development-examples) GitHub repository. +For more resources on block development and extending the Block Editor, review the additional sections here in the Block Editor Handbook. Further practical examples are also available in the [block-development-examples](https://github.com/WordPress/block-development-examples) GitHub repository. If you are looking for more educational content, check out [Learn WordPress](https://learn.wordpress.org/), where you can find [tutorials](https://learn.wordpress.org/tutorials/), [courses](https://learn.wordpress.org/courses/), and [online workshops](https://learn.wordpress.org/online-workshops/). Here is a selection of current offerings: diff --git a/docs/getting-started/fundamentals/javascript-in-the-block-editor.md b/docs/getting-started/fundamentals/javascript-in-the-block-editor.md index 4cd7c0b36fe86..717626af5437e 100644 --- a/docs/getting-started/fundamentals/javascript-in-the-block-editor.md +++ b/docs/getting-started/fundamentals/javascript-in-the-block-editor.md @@ -75,7 +75,7 @@ wp.blocks.registerBlockVariation( For scripts that need to run in the Block Editor, make sure you use the [`enqueue_block_editor_assets`](https://developer.wordpress.org/reference/hooks/enqueue_block_editor_assets/) hook coupled with the standard [`wp_enqueue_script`](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) function. -Refer to [Enqueueing assets in the Editor](/docs/how-to-guides/enqueueing-assets-in-the-editor.md) for more information. You can also visit the [block-development-example](https://github.com/wptrainingteam/block-theme-examples/blob/master/example-block-variation/functions.php) GitHub repository for more practical examples. +Refer to [Enqueueing assets in the Editor](/docs/how-to-guides/enqueueing-assets-in-the-editor.md) for more information.
wp.data.select('core/editor').getBlocks()
in the console when editing a post or when using the Site Editor. This command will return all available blocks.
diff --git a/docs/how-to-guides/plugin-sidebar-0.md b/docs/how-to-guides/plugin-sidebar-0.md
index 76ef54bb9d308..495aa0a1d6b8b 100644
--- a/docs/how-to-guides/plugin-sidebar-0.md
+++ b/docs/how-to-guides/plugin-sidebar-0.md
@@ -42,7 +42,7 @@ Add the following code to a JavaScript file called `plugin-sidebar.js` and save
} )( window.wp, window.React );
```
-For this code to work, those utilities need to be available in the browser, so you must specify `wp-plugins`, `wp-edit-post`, and `react` as dependencies of your script.
+For this code to work, those utilities need to be available in the browser, so you must specify `wp-plugins`, `wp-editor`, and `react` as dependencies of your script.
Here is the PHP code to register your script and specify the dependencies:
diff --git a/docs/how-to-guides/themes/global-settings-and-styles.md b/docs/how-to-guides/themes/global-settings-and-styles.md
index 359b36b4ad205..e0b7653321413 100644
--- a/docs/how-to-guides/themes/global-settings-and-styles.md
+++ b/docs/how-to-guides/themes/global-settings-and-styles.md
@@ -1034,7 +1034,7 @@ h3 {
{% end %}
##### Element pseudo selectors
-Pseudo selectors `:hover`, `:focus`, `:visited`, `:active`, `:link`, `:any-link` are supported by Gutenberg.
+Pseudo selectors `:hover`, `:focus`, `:focus-visible`, `:visited`, `:active`, `:link`, `:any-link` are supported by Gutenberg.
```json
"elements": {
diff --git a/docs/reference-guides/block-api/block-variations.md b/docs/reference-guides/block-api/block-variations.md
index 8a0c6b1dd5bd6..8c223e54eea29 100644
--- a/docs/reference-guides/block-api/block-variations.md
+++ b/docs/reference-guides/block-api/block-variations.md
@@ -60,6 +60,44 @@ wp.blocks.registerBlockVariation( 'core/embed', {
} );
```
+## Registering block variations in PHP
+
+Block variations can also be registered from PHP using the `get_block_type_variations` filter hook. This approach is particularly useful when you need to dynamically generate variations based on registered post types, taxonomies, or other WordPress data.
+
+Here's an example of how to register a custom variation for the `core/image` block:
+
+```php
+function my_custom_image_variation( $variations, $block_type ) {
+ // Only modify variations for the image block
+ if ( 'core/image' !== $block_type->name ) {
+ return $variations;
+ }
+
+ // Add a custom variation
+ $variations[] = array(
+ 'name' => 'wide-image',
+ 'title' => __( 'Wide image', 'textdomain' ),
+ 'description' => __( 'A wide image', 'textdomain' ),
+ 'scope' => array( 'inserter' ),
+ 'isDefault' => false,
+ 'attributes' => array(
+ 'align' => 'wide', // Identifies the link type as custom
+ ),
+ );
+
+ return $variations;
+}
+add_filter( 'get_block_type_variations', 'my_custom_image_variation', 10, 2 );
+```
+
+The `get_block_type_variations` filter is called when variations are requested for a block type. It receives two parameters:
+- `$variations`: An array of currently registered variations for the block type
+- `$block_type`: The full block type object
+
+Note that variations registered through PHP will be merged with any variations registered through JavaScript using `registerBlockVariation()`.
+
++
- { __( '404 (Not Found)' ) } -
+This is a dummy paragraph.
`; +const dummyClassicContent = + 'This is a dummy paragraph.
'; const getHookedBlockClassName = ( relativePosition, anchorBlock ) => `hooked-block-${ relativePosition }-${ anchorBlock.replace( @@ -34,13 +36,13 @@ test.describe( 'Block Hooks API', () => { createMethod: 'createBlock', }, ].forEach( ( { name, postType, blockType, createMethod } ) => { - test.describe( `Hooked blocks in ${ name }`, () => { + test.describe( `Hooked blocks in ${ name } (blocks)`, () => { let postObject, containerPost; test.beforeAll( async ( { requestUtils } ) => { postObject = await requestUtils[ createMethod ]( { title: name, status: 'publish', - content: dummyBlockContent, + content: dummyBlocksContent, } ); await requestUtils.activatePlugin( @@ -162,6 +164,119 @@ test.describe( 'Block Hooks API', () => { ] ); } ); } ); + + test.describe( `Hooked blocks in ${ name } (classic)`, () => { + let postObject, containerPost; + test.beforeAll( async ( { requestUtils } ) => { + postObject = await requestUtils[ createMethod ]( { + title: name, + status: 'publish', + content: dummyClassicContent, + } ); + + await requestUtils.activatePlugin( + 'gutenberg-test-block-hooks' + ); + + if ( postType !== 'post' ) { + // We need a container post to hold our block instance. + containerPost = await requestUtils.createPost( { + title: `Block Hooks in ${ name }`, + status: 'publish', + content: ``, + meta: { + // Prevent Block Hooks from injecting blocks into the container + // post content so they won't distract from the ones injected + // into the block instance. + _wp_ignored_hooked_blocks: '["core/paragraph"]', + }, + } ); + } else { + containerPost = postObject; + } + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.deactivatePlugin( + 'gutenberg-test-block-hooks' + ); + + await requestUtils.deleteAllPosts(); + await requestUtils.deleteAllBlocks(); + } ); + + test( `should insert hooked blocks into ${ name } on frontend`, async ( { + page, + } ) => { + await page.goto( `/?p=${ containerPost.id }` ); + await expect( + page.locator( '.entry-content > *' ) + ).toHaveClass( [ + 'dummy-heading', + 'dummy-paragraph', + getHookedBlockClassName( 'last_child', blockType ), + ] ); + } ); + + test( `should insert hooked blocks into ${ name } in editor and respect changes made there`, async ( { + admin, + editor, + page, + } ) => { + const expectedHookedBlockLastChild = { + name: 'core/paragraph', + attributes: { + className: getHookedBlockClassName( + 'last_child', + blockType + ), + }, + }; + + await admin.editPost( postObject.id ); + await expect + .poll( editor.getBlocks ) + .toMatchObject( [ + { name: 'core/freeform' }, + expectedHookedBlockLastChild, + ] ); + + const hookedBlock = editor.canvas.getByText( + getHookedBlockContent( 'last_child', blockType ) + ); + await editor.selectBlocks( hookedBlock ); + await editor.clickBlockToolbarButton( 'Move up' ); + + // Save updated post. + const saveButton = page + .getByRole( 'region', { name: 'Editor top bar' } ) + .getByRole( 'button', { name: 'Save', exact: true } ); + await saveButton.click(); + await page + .getByRole( 'button', { name: 'Dismiss this notice' } ) + .filter( { hasText: 'updated' } ) + .waitFor(); + + // Reload and verify that the new position of the hooked block has been persisted. + await page.reload(); + await expect + .poll( editor.getBlocks ) + .toMatchObject( [ + expectedHookedBlockLastChild, + { name: 'core/freeform' }, + ] ); + + // Verify that the frontend reflects the changes made in the editor. + await page.goto( `/?p=${ containerPost.id }` ); + await expect( + page.locator( '.entry-content > *' ) + ).toHaveClass( [ + getHookedBlockClassName( 'last_child', blockType ), + 'dummy-heading', + 'dummy-paragraph', + ] ); + } ); + } ); } ); test.describe( 'Hooked blocks in Navigation Menu', () => { diff --git a/test/e2e/specs/editor/various/block-editor-dark-background.spec.js b/test/e2e/specs/editor/various/block-editor-dark-background.spec.js new file mode 100644 index 0000000000000..dc333f31c7ed9 --- /dev/null +++ b/test/e2e/specs/editor/various/block-editor-dark-background.spec.js @@ -0,0 +1,52 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +test.describe( 'Block editor with dark background theme', () => { + test.beforeAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'darktheme' ); + } ); + + test.beforeEach( async ( { admin } ) => { + await admin.createNewPost(); + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'twentytwentyone' ); + } ); + + test.describe( 'Block editor iframe body', () => { + test( 'Should have the is-dark-theme CSS class', async ( { + editor, + } ) => { + const canvasBody = editor.canvas.locator( 'body' ); + + await expect( canvasBody ).toHaveClass( /is-dark-theme/ ); + } ); + } ); +} ); + +test.describe( 'Block editor with light background theme', () => { + test.beforeAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'twentytwentyfour' ); + } ); + + test.beforeEach( async ( { admin } ) => { + await admin.createNewPost(); + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'twentytwentyone' ); + } ); + + test.describe( 'Block editor iframe body', () => { + test( 'Should not have the is-dark-theme CSS class', async ( { + editor, + } ) => { + const canvasBody = editor.canvas.locator( 'body' ); + + await expect( canvasBody ).not.toHaveClass( /is-dark-theme/ ); + } ); + } ); +} ); diff --git a/test/e2e/specs/editor/various/list-view.spec.js b/test/e2e/specs/editor/various/list-view.spec.js index 988683c8d11aa..98dfe5e304f80 100644 --- a/test/e2e/specs/editor/various/list-view.spec.js +++ b/test/e2e/specs/editor/various/list-view.spec.js @@ -162,10 +162,10 @@ test.describe( 'List View', () => { // make the inner blocks appear. await editor.canvas .getByRole( 'document', { name: 'Block: Cover' } ) - .getByRole( 'listbox', { - name: 'Custom color picker.', + .getByRole( 'group', { + name: 'Overlay color', } ) - .getByRole( 'option' ) + .getByRole( 'button' ) .first() .click(); diff --git a/test/e2e/specs/site-editor/navigation.spec.js b/test/e2e/specs/site-editor/navigation.spec.js index 18eb6c9904b44..2a886c2048f88 100644 --- a/test/e2e/specs/site-editor/navigation.spec.js +++ b/test/e2e/specs/site-editor/navigation.spec.js @@ -106,6 +106,23 @@ test.describe( 'Site editor navigation', () => { // We should have our editor canvas button back await expect( editorCanvasButton ).toBeVisible(); } ); + + test( 'Should show 404 page when navigating to non-existent template', async ( { + admin, + page, + } ) => { + // Navigate to a non-existent template. + await admin.visitAdminPage( 'site-editor.php', 'p=/template-foo-bar' ); + + // Verify the 404 error notice is displayed with the correct message. + await expect( + page.locator( + '.edit-site-layout__area .components-notice__content' + ) + ).toHaveText( + 'The requested page could not be found. Please check the URL.' + ); + } ); } ); class EditorNavigationUtils { diff --git a/test/e2e/specs/site-editor/site-editor-dark-background.spec.js b/test/e2e/specs/site-editor/site-editor-dark-background.spec.js new file mode 100644 index 0000000000000..1bf49c196bdfc --- /dev/null +++ b/test/e2e/specs/site-editor/site-editor-dark-background.spec.js @@ -0,0 +1,75 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +test.describe( 'Site editor with dark background theme', () => { + test.beforeAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'darktheme' ); + } ); + + test.beforeEach( async ( { admin } ) => { + await admin.visitSiteEditor(); + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'twentytwentyone' ); + } ); + + test.describe( 'Site editor iframe body', () => { + test( 'Should have the is-dark-theme CSS class', async ( { + editor, + } ) => { + const canvasBody = editor.canvas.locator( 'body' ); + + await expect( canvasBody ).toHaveClass( /is-dark-theme/ ); + } ); + } ); +} ); + +test.describe( 'Site editor with light background theme and theme variations', () => { + test.beforeAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'twentytwentyfour' ); + } ); + + test.beforeEach( async ( { admin } ) => { + await admin.visitSiteEditor(); + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'twentytwentyone' ); + } ); + + test.describe( 'Site editor iframe body', () => { + test( 'Should not have the is-dark-theme CSS class', async ( { + editor, + } ) => { + const canvasBody = editor.canvas.locator( 'body' ); + + await expect( canvasBody ).not.toHaveClass( /is-dark-theme/ ); + } ); + + test( 'Should add and remove the is-dark-theme CSS class with dark and light theme variation', async ( { + page, + editor, + } ) => { + // Click "Styles" + await page.getByRole( 'button', { name: 'Styles' } ).click(); + + // Click "Browse styles" + await page.getByRole( 'button', { name: 'Browse styles' } ).click(); + + const canvasBody = editor.canvas.locator( 'body' ); + + // Activate "Maelstrom" Theme Variation. + await page.getByRole( 'button', { name: 'Maelstrom' } ).click(); + + await expect( canvasBody ).toHaveClass( /is-dark-theme/ ); + + // Activate "Ember" Theme Variation. + await page.getByRole( 'button', { name: 'Ember' } ).click(); + + await expect( canvasBody ).not.toHaveClass( /is-dark-theme/ ); + } ); + } ); +} ); diff --git a/test/gutenberg-test-themes/darktheme/block-templates/index.html b/test/gutenberg-test-themes/darktheme/block-templates/index.html new file mode 100644 index 0000000000000..0283daeb54c6f --- /dev/null +++ b/test/gutenberg-test-themes/darktheme/block-templates/index.html @@ -0,0 +1,11 @@ + +My awesome paragraph
+ diff --git a/test/gutenberg-test-themes/darktheme/block-templates/singular.html b/test/gutenberg-test-themes/darktheme/block-templates/singular.html new file mode 100644 index 0000000000000..cd05d5fe917fe --- /dev/null +++ b/test/gutenberg-test-themes/darktheme/block-templates/singular.html @@ -0,0 +1,2 @@ + + diff --git a/test/gutenberg-test-themes/darktheme/index.php b/test/gutenberg-test-themes/darktheme/index.php new file mode 100644 index 0000000000000..0c6530acc1aaf --- /dev/null +++ b/test/gutenberg-test-themes/darktheme/index.php @@ -0,0 +1,9 @@ +