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 and sethrubenstein committed Jul 13, 2023
1 parent e8d2fc3 commit a1a58eb
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 );
}

0 comments on commit a1a58eb

Please sign in to comment.