Skip to content

Commit

Permalink
Merge pull request #2457 from woocommerce/fix/2453-e2e-test-failed-wi…
Browse files Browse the repository at this point in the history
…th-wc-9.1

Fix e2e tests failed with WC 9.1
  • Loading branch information
ianlin authored Jul 12, 2024
2 parents fbbdc47 + ddc4c23 commit 5069f65
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion tests/e2e/specs/product-editor/block-integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/mock-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
15 changes: 9 additions & 6 deletions tests/e2e/utils/product-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 );
},
};
Expand Down

0 comments on commit 5069f65

Please sign in to comment.