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 Jul 6, 2023
1 parent d72aad0 commit 5977e3d
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 @@ -19,7 +19,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 @@ -98,15 +98,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

1 comment on commit 5977e3d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 5977e3d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5480342531
📝 Reported issues:

Please sign in to comment.