Fix flaky shopper checkout block creating user with custom password e2e test (#49596)

This commit is contained in:
Veljko V. 2024-07-17 12:37:32 +02:00 committed by GitHub
parent 31b45d79e3
commit dd411f53e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 21 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
E2E tests: fix shopper checkout block test

View File

@ -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(