Skip to content

Commit

Permalink
Template Mode: Don't display snackbar with the Welcome Guide (#32076)
Browse files Browse the repository at this point in the history
* Fix e2e tests
  • Loading branch information
Mamaduka committed May 28, 2021
1 parent 2cb5a33 commit e4a2ea5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const disableTemplateWelcomeGuide = async () => {
};

const switchToTemplateMode = async () => {
await disableTemplateWelcomeGuide();

// Switch to template mode.
await openDocumentSettingsSidebar();
await openSidebarPanelWithTitle( 'Template' );
Expand All @@ -52,11 +54,11 @@ const switchToTemplateMode = async () => {
( el ) => el.innerText
);
expect( title ).toContain( 'About\n' );

await disableTemplateWelcomeGuide();
};

const createNewTemplate = async ( templateName ) => {
await disableTemplateWelcomeGuide();

// Create a new custom template.
await openDocumentSettingsSidebar();
await openSidebarPanelWithTitle( 'Template' );
Expand All @@ -76,8 +78,6 @@ const createNewTemplate = async ( templateName ) => {
await page.waitForXPath(
'//*[contains(@class, "components-snackbar")]/*[text()="Custom template created. You\'re in template mode now."]'
);

await disableTemplateWelcomeGuide();
};

describe( 'Post Editor Template mode', () => {
Expand Down
24 changes: 16 additions & 8 deletions packages/edit-post/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,20 @@ export function* __unstableSwitchToTemplateMode( template ) {

yield setIsEditingTemplate( true );

const message = !! template
? __( "Custom template created. You're in template mode now." )
: __(
'Editing template. Changes made here affect all posts and pages that use the template.'
);
yield controls.dispatch( noticesStore, 'createSuccessNotice', message, {
type: 'snackbar',
} );
const isWelcomeGuideActive = yield controls.select(
'core/edit-post',
'isFeatureActive',
'welcomeGuideTemplate'
);

if ( ! isWelcomeGuideActive ) {
const message = !! template
? __( "Custom template created. You're in template mode now." )
: __(
'Editing template. Changes made here affect all posts and pages that use the template.'
);
yield controls.dispatch( noticesStore, 'createSuccessNotice', message, {
type: 'snackbar',
} );
}
}

0 comments on commit e4a2ea5

Please sign in to comment.