diff --git a/tests/e2e/specs/product-editor/block-integration.test.js b/tests/e2e/specs/product-editor/block-integration.test.js index ed196976c0..a2191dc166 100644 --- a/tests/e2e/specs/product-editor/block-integration.test.js +++ b/tests/e2e/specs/product-editor/block-integration.test.js @@ -529,7 +529,9 @@ test.describe( 'Product Block Editor integration', () => { await input.fill( '-1' ); - await editorUtils.assertUnableSave(); + await editorUtils.assertUnableSave( + 'The minimum value of the field is 0' + ); await expect( help ).toBeVisible(); await expect( help ).toHaveText( await editorUtils.evaluateValidationMessage( input ) diff --git a/tests/e2e/utils/mock-requests.js b/tests/e2e/utils/mock-requests.js index 15c38a34ee..5054c1ad89 100644 --- a/tests/e2e/utils/mock-requests.js +++ b/tests/e2e/utils/mock-requests.js @@ -46,7 +46,7 @@ export default class MockRequests { */ async fulfillWCDefaultCountry( payload ) { await this.fulfillRequest( - /wc-admin\/options\?options=woocommerce_default_country\b/, + /wc-admin\/options\?options=.*woocommerce_default_country\b/, payload ); } diff --git a/tests/e2e/utils/product-editor.js b/tests/e2e/utils/product-editor.js index e18a155a90..f81ee503fd 100644 --- a/tests/e2e/utils/product-editor.js +++ b/tests/e2e/utils/product-editor.js @@ -291,8 +291,8 @@ export function getProductBlockEditorUtils( page ) { const locators = { getTab( tabName ) { return page - .getByRole( 'tablist' ) - .getByRole( 'button', { name: tabName } ); + .locator( '.woocommerce-product-tabs' ) + .getByRole( 'tab', { name: tabName } ); }, getPluginTab() { @@ -507,17 +507,20 @@ export function getProductBlockEditorUtils( page ) { }; const assertions = { - async assertUnableSave() { + async assertUnableSave( message = 'Please enter a valid value.' ) { await this.clickSave(); const failureNotice = page - .getByRole( 'button' ) - .filter( { hasText: 'Failed to save product' } ); + .locator( '.components-snackbar__content' ) + .filter( { hasText: new RegExp( message ) } ); + + const failureNoticeDismissButton = + failureNotice.getByRole( 'button' ); await expect( failureNotice ).toBeVisible(); // Dismiss the notice. - await failureNotice.click(); + await failureNoticeDismissButton.click(); await expect( failureNotice ).toHaveCount( 0 ); }, };