Skip to content

Commit

Permalink
Release: Fix CI checks on the 'wp/6.2' branch (#50464)
Browse files Browse the repository at this point in the history
Co-authored-by: André <[email protected]>
Co-authored-by: Andrew Serong <[email protected]>
  • Loading branch information
3 people authored May 9, 2023
1 parent 7eb2a4e commit 9e7bbd6
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 62 deletions.
15 changes: 15 additions & 0 deletions lib/compat/wordpress-6.2/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@
*/
add_action( 'start_previewing_theme', '_gutenberg_clean_theme_json_caches' );
add_action( 'switch_theme', '_gutenberg_clean_theme_json_caches' );

/**
* This is a temporary fix to ensure that the block editor styles are enqueued
* in the order the iframe expects.
*
* The wp_enqueue_registered_block_scripts_and_styles callback has been removed in core
* as of https://github.com/WordPress/wordpress-develop/pull/4356.
*
* However, Gutenberg supports WordPress 6.1 and 6.2, which still have this callback.
* Hence, why we remove it first and then re-add it.
*
* This way we make sure it still works the same in WordPress trunk, 6.1 and 6.2.
*/
remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_and_styles', 1 );
127 changes: 65 additions & 62 deletions test/e2e/specs/site-editor/site-editor-url-navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,70 @@ test.describe( 'Site editor url navigation', () => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );

test.describe( 'Redirection after template and template part creation', () => {
test.afterEach( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.deleteAllPosts(),
requestUtils.deleteAllTemplates( 'wp_template' ),
requestUtils.deleteAllTemplates( 'wp_template_part' ),
] );
} );
test( 'Redirection after template creation', async ( {
admin,
page,
requestUtils,
} ) => {
await requestUtils.createPost( {
title: 'Demo',
status: 'publish',
test.describe(
'Redirection after template and template part creation',
() => {
test.afterEach( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.deleteAllPosts(),
requestUtils.deleteAllTemplates( 'wp_template' ),
requestUtils.deleteAllTemplates( 'wp_template_part' ),
] );
} );
await admin.visitSiteEditor();
// We need to wait the response from the `posts` request in order to click the augmented menu item,
// that includes the options for creating templates for specific posts.
await Promise.all( [
page.waitForResponse(
( resp ) =>
resp
.url()
.includes(
'/index.php?rest_route=%2Fwp%2Fv2%2Fposts&context=view'
) && resp.status() === 200
),
page.click( 'role=button[name="Templates"]' ),
] );
await page.click( 'role=button[name="Add New Template"i]' );
await page
.getByRole( 'menuitem', {
name: 'Single item: Post',
} )
.click();
await page
.getByRole( 'button', { name: 'For a specific item' } )
.click();
await page.getByRole( 'option', { name: 'Demo' } ).click();
await expect( page ).toHaveURL(
'/wp-admin/site-editor.php?postId=emptytheme%2F%2Fsingle-post-demo&postType=wp_template&canvas=edit'
);
} );
test( 'Redirection after template part creation', async ( {
admin,
page,
} ) => {
await admin.visitSiteEditor();
await page.click( 'role=button[name="Template Parts"i]' );
await page.click( 'role=button[name="Add New"i]' );
// Fill in a name in the dialog that pops up.
await page.type(
'role=dialog >> role=textbox[name="Name"i]',
'Demo'
);
await page.keyboard.press( 'Enter' );
await expect( page ).toHaveURL(
'/wp-admin/site-editor.php?postId=emptytheme%2F%2Fdemo&postType=wp_template_part&canvas=edit'
);
} );
} );
test( 'Redirection after template creation', async ( {
admin,
page,
requestUtils,
} ) => {
await requestUtils.createPost( {
title: 'Demo',
status: 'publish',
} );
await admin.visitSiteEditor();
// We need to wait the response from the `posts` request in order to click the augmented menu item,
// that includes the options for creating templates for specific posts.
await Promise.all( [
page.waitForResponse(
( resp ) =>
resp
.url()
.includes(
'/index.php?rest_route=%2Fwp%2Fv2%2Fposts&context=view'
) && resp.status() === 200
),
page.click( 'role=button[name="Templates"]' ),
] );
await page.click( 'role=button[name="Add New Template"i]' );
await page
.getByRole( 'menuitem', {
name: 'Single item: Post',
} )
.click();
await page
.getByRole( 'button', { name: 'For a specific item' } )
.click();
await page.getByRole( 'option', { name: 'Demo' } ).click();
await expect( page ).toHaveURL(
'/wp-admin/site-editor.php?postId=emptytheme%2F%2Fsingle-post-demo&postType=wp_template&canvas=edit'
);
} );
test( 'Redirection after template part creation', async ( {
admin,
page,
} ) => {
await admin.visitSiteEditor();
await page.click( 'role=button[name="Template Parts"i]' );
await page.click( 'role=button[name="Add New"i]' );
// Fill in a name in the dialog that pops up.
await page.type(
'role=dialog >> role=textbox[name="Name"i]',
'Demo'
);
await page.keyboard.press( 'Enter' );
await expect( page ).toHaveURL(
'/wp-admin/site-editor.php?postId=emptytheme%2F%2Fdemo&postType=wp_template_part&canvas=edit'
);
} );
}
);
} );

0 comments on commit 9e7bbd6

Please sign in to comment.