Skip to content

Commit

Permalink
Playwright Utils: Simplify editor preference updates in createNewPost (
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Jun 16, 2023
1 parent 7e962bb commit ece6f8c
Showing 1 changed file with 7 additions and 30 deletions.
37 changes: 7 additions & 30 deletions packages/e2e-test-utils-playwright/src/admin/create-new-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,15 @@ export async function createNewPost( {
} ).slice( 1 );

await this.visitAdminPage( 'post-new.php', query );

await this.page.waitForSelector( '.edit-post-layout' );

const isWelcomeGuideActive = await this.page.evaluate( () =>
window.wp.data
.select( 'core/edit-post' )
.isFeatureActive( 'welcomeGuide' )
);
const isFullscreenMode = await this.page.evaluate( () =>
await this.page.evaluate( ( welcomeGuide ) => {
window.wp.data
.select( 'core/edit-post' )
.isFeatureActive( 'fullscreenMode' )
);

if ( showWelcomeGuide !== isWelcomeGuideActive ) {
await this.page.evaluate( () =>
window.wp.data
.dispatch( 'core/edit-post' )
.toggleFeature( 'welcomeGuide' )
);
.dispatch( 'core/preferences' )
.set( 'core/edit-post', 'welcomeGuide', welcomeGuide );

await this.page.reload();
await this.page.waitForSelector( '.edit-post-layout' );
}

if ( isFullscreenMode ) {
await this.page.evaluate( () =>
window.wp.data
.dispatch( 'core/edit-post' )
.toggleFeature( 'fullscreenMode' )
);

await this.page.waitForSelector( 'body:not(.is-fullscreen-mode)' );
}
window.wp.data
.dispatch( 'core/preferences' )
.set( 'core/edit-post', 'fullscreenMode', false );
}, showWelcomeGuide );
}

1 comment on commit ece6f8c

@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 ece6f8c.
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/5288096595
📝 Reported issues:

Please sign in to comment.