Skip to content

Commit

Permalink
Fix flaky Site Editor URL navigation e2e test (#60675)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: andrewserong <[email protected]>
Co-authored-by: kevin940726 <[email protected]>
Co-authored-by: WunderBart <[email protected]>
  • Loading branch information
5 people authored Apr 12, 2024
1 parent 6ea845e commit e06e7ea
Showing 1 changed file with 52 additions and 53 deletions.
105 changes: 52 additions & 53 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,59 +12,58 @@ 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',
} );
await admin.visitSiteEditor();
await page.click( 'role=button[name="Templates"]' );
await page.click( 'role=button[name="Add New Template"i]' );
await page
.getByRole( 'button', {
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="Patterns"i]' );
await page.click( 'role=button[name="Create pattern"i]' );
await page
.getByRole( 'menu', { name: 'Create pattern' } )
.getByRole( 'menuitem', { name: 'Create template part' } )
.click();
// 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.beforeEach( 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',
content: 'Hello there!',
status: 'publish',
} );

await admin.visitSiteEditor();
await page.click( 'role=button[name="Templates"]' );
await page.click( 'role=button[name="Add New Template"i]' );
await page
.getByRole( 'button', {
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="Patterns"i]' );
await page.click( 'role=button[name="Create pattern"i]' );
await page
.getByRole( 'menu', { name: 'Create pattern' } )
.getByRole( 'menuitem', { name: 'Create template part' } )
.click();
// 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 e06e7ea

Please sign in to comment.