Skip to content

Commit

Permalink
Add some back compat into disableSiteEditorWelcomeGuide (#39300)
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan authored Mar 9, 2022
1 parent be119ed commit 8721a00
Showing 1 changed file with 50 additions and 18 deletions.
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

0 comments on commit 8721a00

Please sign in to comment.