Skip to content
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
68 changes: 50 additions & 18 deletions packages/e2e-test-utils/src/site-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,65 @@ export async function closeSiteEditorNavigationPanel() {
* Skips the welcome guide popping up to first time users of the site editor
*/
export async function disableSiteEditorWelcomeGuide() {
const isWelcomeGuideActive = await page.evaluate(
() =>
!! wp.data
.select( 'core/preferences' )
.get( 'core/edit-site', 'welcomeGuide' )
);
const isWelcomeGuideStyesActive = await page.evaluate(
() =>
!! wp.data
.select( 'core/preferences' )
.get( 'core/edit-site', 'welcomeGuideStyles' )
);
// This code prioritizes using the preferences store. However, performance
// tests run on older versions of the codebase where the preferences store
// doesn't exist. Some backwards compatibility has been built-in so that
// those tests continue to work there. This can be removed once WordPress
// 6.0 is released, as the older version used by the performance tests will
// then include the preferences store.
// See https://github.com/WordPress/gutenberg/pull/39300.
const isWelcomeGuideActive = await page.evaluate( () => {
// TODO - remove if statement after WordPress 6.0 is released.
if ( ! wp.data.select( 'core/preferences' ) ) {
return wp.data
.select( 'core/edit-site' )
.isFeatureActive( 'welcomeGuide' );
}

return !! wp.data
.select( 'core/preferences' )
?.get( 'core/edit-site', 'welcomeGuide' );
} );
const isWelcomeGuideStyesActive = await page.evaluate( () => {
// TODO - remove if statement after WordPress 6.0 is released.
if ( ! wp.data.select( 'core/preferences' ) ) {
return wp.data
.select( 'core/edit-site' )
.isFeatureActive( 'welcomeGuideStyles' );
}

return !! wp.data
.select( 'core/preferences' )
?.get( 'core/edit-site', 'welcomeGuideStyles' );
} );

if ( isWelcomeGuideActive ) {
await page.evaluate( () =>
await page.evaluate( () => {
// TODO - remove if statement after WordPress 6.0 is released.
if ( ! wp.data.dispatch( 'core/preferences' ) ) {
wp.data
.dispatch( 'core/edit-site' )
.toggleFeature( 'welcomeGuide' );
}

wp.data
.dispatch( 'core/preferences' )
.toggle( 'core/edit-site', 'welcomeGuide' )
);
.toggle( 'core/edit-site', 'welcomeGuide' );
} );
}

if ( isWelcomeGuideStyesActive ) {
await page.evaluate( () =>
await page.evaluate( () => {
// TODO - remove if statement after WordPress 6.0 is released.
if ( ! wp.data.dispatch( 'core/preferences' ) ) {
wp.data
.dispatch( 'core/edit-site' )
.toggleFeature( 'welcomeGuideStyles' );
}
wp.data
.dispatch( 'core/preferences' )
.toggle( 'core/edit-site', 'welcomeGuideStyles' )
);
.toggle( 'core/edit-site', 'welcomeGuideStyles' );
} );
}
}

Expand Down