Skip to content

Commit

Permalink
Patterns: stop endless snackbars appearing (#52012)
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz authored and tellthemachines committed Jul 7, 2023
1 parent e36aae1 commit 089d7fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/e2e-test-utils/src/create-reusable-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const createReusableBlock = async ( content, title ) => {

// Wait for creation to finish
await page.waitForXPath(
'//*[contains(@class, "components-snackbar")]/*[text()="Synced Pattern created."]'
'//*[contains(@class, "components-snackbar")]/*[contains(text(),"Pattern created:")]'
);

// Check that we have a reusable block on the page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe( 'Reusable blocks', () => {

// Wait for creation to finish.
await page.waitForXPath(
'//*[contains(@class, "components-snackbar")]/*[text()="Synced Pattern created."]'
'//*[contains(@class, "components-snackbar")]/*[contains(text(),"Pattern created:")]'
);

await clearAllBlocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@wordpress/components';
import { symbol } from '@wordpress/icons';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import { store as noticesStore } from '@wordpress/notices';
import { store as coreStore } from '@wordpress/core-data';

Expand Down Expand Up @@ -97,15 +97,25 @@ export default function ReusableBlockConvertButton( {
);
createSuccessNotice(
syncType === 'fully'
? __( 'Synced Pattern created.' )
: __( 'Unsynced Pattern created.' ),
? sprintf(
// translators: %s: the name the user has given to the pattern.
__( 'Synced Pattern created: %s' ),
reusableBlockTitle
)
: sprintf(
// translators: %s: the name the user has given to the pattern.
__( 'Unsynced Pattern created: %s' ),
reusableBlockTitle
),
{
type: 'snackbar',
id: 'convert-to-reusable-block-success',
}
);
} catch ( error ) {
createErrorNotice( error.message, {
type: 'snackbar',
id: 'convert-to-reusable-block-error',
} );
}
},
Expand Down

0 comments on commit 089d7fd

Please sign in to comment.