Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky 'Push to Global Styles' e2e test #51636

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions test/e2e/specs/site-editor/push-to-global-styles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Push to Global Styles button', () => {
test.beforeAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.activateTheme( 'emptytheme' ),
requestUtils.deleteAllTemplates( 'wp_template' ),
requestUtils.deleteAllTemplates( 'wp_template_part' ),
] );
await requestUtils.activateTheme( 'emptytheme' );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small clean-up. The test doesn't create any templates or template parts, so there is no need to delete them.

} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );

test.beforeEach( async ( { admin, editor } ) => {
await admin.visitSiteEditor();
await admin.visitSiteEditor( {
postId: 'emptytheme//index',
postType: 'wp_template',
Comment on lines +17 to +18
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, it's better to specify a template or template part in test setups.

} );
await editor.canvas.click( 'body' );
} );

Expand All @@ -29,8 +28,10 @@ test.describe( 'Push to Global Styles button', () => {
await editor.insertBlock( { name: 'core/heading' } );
await page.keyboard.type( 'A heading' );

const topBar = page.getByRole( 'region', { name: 'Editor top bar' } );

// Navigate to Styles -> Blocks -> Heading -> Typography
await page.getByRole( 'button', { name: 'Styles' } ).click();
await topBar.getByRole( 'button', { name: 'Styles' } ).click();
await page.getByRole( 'button', { name: 'Blocks styles' } ).click();
await page
.getByRole( 'button', { name: 'Heading block styles' } )
Expand All @@ -42,7 +43,7 @@ test.describe( 'Push to Global Styles button', () => {
).toHaveAttribute( 'aria-pressed', 'false' );

// Go to block settings and open the Advanced panel
await page.getByRole( 'button', { name: 'Settings' } ).click();
await topBar.getByRole( 'button', { name: 'Settings' } ).click();
await page.getByRole( 'button', { name: 'Advanced' } ).click();

// Push button should be disabled
Expand Down