From dd411f53e46e6d336cd69c24e70aa49826f321ff Mon Sep 17 00:00:00 2001 From: "Veljko V." Date: Wed, 17 Jul 2024 12:37:32 +0200 Subject: [PATCH] Fix flaky shopper checkout block creating user with custom password e2e test (#49596) --- .../changelog/e2e-fix-shopper-checkout-block | 4 ++ .../tests/shopper/checkout-block.spec.js | 38 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 plugins/woocommerce/changelog/e2e-fix-shopper-checkout-block diff --git a/plugins/woocommerce/changelog/e2e-fix-shopper-checkout-block b/plugins/woocommerce/changelog/e2e-fix-shopper-checkout-block new file mode 100644 index 00000000000..a77126c82a2 --- /dev/null +++ b/plugins/woocommerce/changelog/e2e-fix-shopper-checkout-block @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +E2E tests: fix shopper checkout block test \ No newline at end of file diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-block.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-block.spec.js index 61b625c3596..26b7e7f4b22 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-block.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-block.spec.js @@ -18,7 +18,12 @@ const { const { getOrderIdFromUrl } = require( '../../utils/order' ); const guestEmail = 'checkout-guest@example.com'; -const newAccountEmail = 'marge-test-account@example.com'; +const newAccountEmail = `marge-${ new Date() + .getTime() + .toString() }@woocommercecoree2etestsuite.com`; +const newAccountEmailWithCustomPassword = `homer-${ new Date() + .getTime() + .toString() }@woocommercecoree2etestsuite.com`; const newAccountCustomPassword = 'supersecurepassword123'; const simpleProductName = 'Very Simple Product'; @@ -135,22 +140,6 @@ test.describe( await api.put( 'payment_gateways/cod', { enabled: true, } ); - // make sure there's no pre-existing customer that has the same email we're going to use for account creation - const { data: customersList } = await api.get( 'customers', { - email: newAccountEmail, - } ); - - if ( customersList && customersList.length ) { - const customerId = customersList[ 0 ].id; - - console.log( - `Customer with email ${ newAccountEmail } exists! Deleting it before starting test...` - ); - - await api.delete( `customers/${ customerId }`, { - force: true, - } ); - } // make sure our customer user has a pre-defined billing/shipping address await api.put( `customers/2`, { shipping: { @@ -240,7 +229,10 @@ test.describe( await api.get( 'customers' ).then( async ( response ) => { for ( let i = 0; i < response.data.length; i++ ) { if ( - response.data[ i ].billing.email === newAccountEmail + [ + newAccountEmail, + newAccountEmailWithCustomPassword, + ].includes( response.data[ i ].billing.email ) ) { await api.delete( `customers/${ response.data[ i ].id }`, @@ -981,9 +973,11 @@ test.describe( // For flakiness, sometimes the email address is not filled await page.getByLabel( 'Email address' ).click(); - await page.getByLabel( 'Email address' ).fill( newAccountEmail ); + await page + .getByLabel( 'Email address' ) + .fill( newAccountEmailWithCustomPassword ); await expect( page.getByLabel( 'Email address' ) ).toHaveValue( - newAccountEmail + newAccountEmailWithCustomPassword ); // fill shipping address and check cash on delivery method @@ -1020,7 +1014,9 @@ test.describe( // Log in again. await page.goto( '/my-account/' ); - await page.locator( '#username' ).fill( newAccountEmail ); + await page + .locator( '#username' ) + .fill( newAccountEmailWithCustomPassword ); await page.locator( '#password' ).fill( newAccountCustomPassword ); await page.locator( 'text=Log in' ).click(); await expect(