Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance tests by adding backwards compatibility to welcome guide utility #39300

Merged
merged 1 commit into from
Mar 9, 2022
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