Skip to content

Commit

Permalink
Fix flaky 'Push to Global Styles' e2e test (#51636)
Browse files Browse the repository at this point in the history
* Fix flaky 'Push to Global Styles' e2e test
* Simplify beforeAll
  • Loading branch information
Mamaduka committed Jun 19, 2023
1 parent 635484b commit 783bb9c
Showing 1 changed file with 9 additions and 8 deletions.
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' );
} );

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',
} );
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

1 comment on commit 783bb9c

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 783bb9c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5309650512
📝 Reported issues:

Please sign in to comment.