From 3a2a812e1d6290137b7ed5ae7a7c79b23a9abeb2 Mon Sep 17 00:00:00 2001 From: Ivan Stojadinov Date: Thu, 29 Aug 2024 21:05:30 +0200 Subject: [PATCH] [e2e tests] External sites - update /merchant tests, part 1 (#51014) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Dismiss "Choose a pattern" if present * Cover "New in store" for PRessable * Handle error for `api.delete( coupons/ )` * Check if `Select an option…` is available * Expand Pressable suite * Add changefile(s) from automation for the following project(s): woocommerce * Missed one spec, adding it now * Handle "Choose a pattern" popup * Use `closeChoosePatternModal` instead * Remove comments * Add missing `throw` error * Revert to check `Browse store` link, after updating template on Pressable --------- Co-authored-by: github-actions --- ...4-e2e-external-sites-update-merchant-tests-pt1 | 4 ++++ .../envs/default-pressable/playwright.config.js | 5 +++++ .../tests/merchant/create-cart-block.spec.js | 3 +++ .../tests/merchant/create-checkout-block.spec.js | 3 +++ .../e2e-pw/tests/merchant/create-coupon.spec.js | 10 +++++++++- .../e2e-pw/tests/merchant/create-order.spec.js | 15 +++++++++++---- 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 plugins/woocommerce/changelog/51014-e2e-external-sites-update-merchant-tests-pt1 diff --git a/plugins/woocommerce/changelog/51014-e2e-external-sites-update-merchant-tests-pt1 b/plugins/woocommerce/changelog/51014-e2e-external-sites-update-merchant-tests-pt1 new file mode 100644 index 00000000000..180673a625b --- /dev/null +++ b/plugins/woocommerce/changelog/51014-e2e-external-sites-update-merchant-tests-pt1 @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Update /merchant tests (first five files), so they are passing against Pressable env. \ No newline at end of file diff --git a/plugins/woocommerce/tests/e2e-pw/envs/default-pressable/playwright.config.js b/plugins/woocommerce/tests/e2e-pw/envs/default-pressable/playwright.config.js index 988e4d3bbea..b0747f37c30 100644 --- a/plugins/woocommerce/tests/e2e-pw/envs/default-pressable/playwright.config.js +++ b/plugins/woocommerce/tests/e2e-pw/envs/default-pressable/playwright.config.js @@ -16,6 +16,11 @@ config = { '**/admin-marketing/**/*.spec.js', '**/admin-tasks/**/*.spec.js', '**/customize-store/**/*.spec.js', + '**/merchant/command-palette.spec.js', + '**/merchant/create-cart-block.spec.js', + '**/merchant/create-checkout-block.spec.js', + '**/merchant/create-coupon.spec.js', + '**/merchant/create-order.spec.js', ], grepInvert: /@skip-on-default-pressable/, }, diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-cart-block.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-cart-block.spec.js index b262e740846..1f612946ce5 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-cart-block.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-cart-block.spec.js @@ -5,6 +5,7 @@ const { insertBlock, transformIntoBlocks, publishPage, + closeChoosePatternModal, } = require( '../../utils/editor' ); const { getInstalledWordPressVersion } = require( '../../utils/wordpress' ); @@ -23,6 +24,8 @@ test.describe( } ) => { await goToPageEditor( { page } ); + await closeChoosePatternModal( { page } ); + await fillPageTitle( page, testPage.title ); const wordPressVersion = await getInstalledWordPressVersion(); await insertBlock( page, 'Classic Cart', wordPressVersion ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-checkout-block.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-checkout-block.spec.js index 23317b1a834..53479325a1b 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-checkout-block.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-checkout-block.spec.js @@ -7,6 +7,7 @@ const { transformIntoBlocks, publishPage, openEditorSettings, + closeChoosePatternModal, } = require( '../../utils/editor' ); const { getInstalledWordPressVersion } = require( '../../utils/wordpress' ); @@ -74,6 +75,8 @@ test.describe( } ) => { await goToPageEditor( { page } ); + await closeChoosePatternModal( { page } ); + await fillPageTitle( page, testPage.title ); const wordPressVersion = await getInstalledWordPressVersion(); await insertBlock( page, 'Classic Checkout', wordPressVersion ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js index 2630674a42b..785f5c0d6b3 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js @@ -35,7 +35,15 @@ const test = baseTest.extend( { coupon: async ( { api }, use ) => { const coupon = {}; await use( coupon ); - await api.delete( `coupons/${ coupon.id }`, { force: true } ); + await api + .delete( `coupons/${ coupon.id }`, { force: true } ) + .then( ( response ) => { + console.log( 'Delete successful:', response.data ); + } ) + .catch( ( error ) => { + console.log( 'Error response data:', error.response.data ); + throw new Error( error.response.data ); + } ); }, } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js index aa33c49f167..087e95556b7 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js @@ -299,10 +299,17 @@ test.describe( await page .getByRole( 'textbox', { name: 'Postcode' } ) .fill( '12345' ); - await page - .getByRole( 'textbox', { name: 'Select an option…' } ) - .click(); - await page.getByRole( 'option', { name: 'Florida' } ).click(); + // eslint-disable-next-line playwright/no-conditional-in-test + if ( + await page + .getByRole( 'textbox', { name: 'Select an option…' } ) + .isVisible() + ) { + await page + .getByRole( 'textbox', { name: 'Select an option…' } ) + .click(); + await page.getByRole( 'option', { name: 'Florida' } ).click(); + } await page .getByRole( 'textbox', { name: 'Email address' } ) .fill( 'elbarto@example.com' );