From d12433f3e7c80d51d30f9206cf8e25a6f22e0bf7 Mon Sep 17 00:00:00 2001 From: Ian Yu-Hsun Lin Date: Mon, 8 Jul 2024 15:22:40 +0800 Subject: [PATCH 1/4] Fix e2e test for GL&A tab in product editor block Because of the change in https://github.com/woocommerce/woocommerce/pull/47860 --- tests/e2e/utils/product-editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/utils/product-editor.js b/tests/e2e/utils/product-editor.js index e18a155a90..04bf272a71 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() { From fad9f34c4be25c6c0c7f899ed678975dad1d62a3 Mon Sep 17 00:00:00 2001 From: Ian Yu-Hsun Lin Date: Mon, 8 Jul 2024 15:57:20 +0800 Subject: [PATCH 2/4] Fix e2e test for GL&A tab in product edit block Because of the change https://github.com/woocommerce/woocommerce/pull/48192 --- .../specs/product-editor/block-integration.test.js | 2 +- tests/e2e/utils/product-editor.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/e2e/specs/product-editor/block-integration.test.js b/tests/e2e/specs/product-editor/block-integration.test.js index ed196976c0..26928e5708 100644 --- a/tests/e2e/specs/product-editor/block-integration.test.js +++ b/tests/e2e/specs/product-editor/block-integration.test.js @@ -529,7 +529,7 @@ 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/product-editor.js b/tests/e2e/utils/product-editor.js index 04bf272a71..30b2169c5a 100644 --- a/tests/e2e/utils/product-editor.js +++ b/tests/e2e/utils/product-editor.js @@ -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 ); }, }; From e36ed4d3955ca44fe0738bad6728951e7fc6fb19 Mon Sep 17 00:00:00 2001 From: Ian Yu-Hsun Lin Date: Mon, 8 Jul 2024 17:32:04 +0800 Subject: [PATCH 3/4] Fix e2e test when fulfilling /wc-admin/options endpoint There were more options added in `options` query parameter, so adding a `.*` for the URL matching pattern --- tests/e2e/utils/mock-requests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ); } From ddc4c23341ca29cde516603452c49a11949dddd0 Mon Sep 17 00:00:00 2001 From: Ian Yu-Hsun Lin Date: Tue, 9 Jul 2024 12:26:18 +0800 Subject: [PATCH 4/4] Fix JS lint --- tests/e2e/specs/product-editor/block-integration.test.js | 4 +++- tests/e2e/utils/product-editor.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/e2e/specs/product-editor/block-integration.test.js b/tests/e2e/specs/product-editor/block-integration.test.js index 26928e5708..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( 'The minimum value of the field is 0' ); + 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/product-editor.js b/tests/e2e/utils/product-editor.js index 30b2169c5a..f81ee503fd 100644 --- a/tests/e2e/utils/product-editor.js +++ b/tests/e2e/utils/product-editor.js @@ -514,8 +514,8 @@ export function getProductBlockEditorUtils( page ) { .locator( '.components-snackbar__content' ) .filter( { hasText: new RegExp( message ) } ); - const failureNoticeDismissButton = failureNotice - .getByRole( 'button' ); + const failureNoticeDismissButton = + failureNotice.getByRole( 'button' ); await expect( failureNotice ).toBeVisible();