Fix flaky shopper checkout block creating user with custom password e2e test (#49596)
This commit is contained in:
parent
31b45d79e3
commit
dd411f53e4
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
E2E tests: fix shopper checkout block test
|
|
@ -18,7 +18,12 @@ const {
|
||||||
const { getOrderIdFromUrl } = require( '../../utils/order' );
|
const { getOrderIdFromUrl } = require( '../../utils/order' );
|
||||||
|
|
||||||
const guestEmail = 'checkout-guest@example.com';
|
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 newAccountCustomPassword = 'supersecurepassword123';
|
||||||
|
|
||||||
const simpleProductName = 'Very Simple Product';
|
const simpleProductName = 'Very Simple Product';
|
||||||
|
@ -135,22 +140,6 @@ test.describe(
|
||||||
await api.put( 'payment_gateways/cod', {
|
await api.put( 'payment_gateways/cod', {
|
||||||
enabled: true,
|
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
|
// make sure our customer user has a pre-defined billing/shipping address
|
||||||
await api.put( `customers/2`, {
|
await api.put( `customers/2`, {
|
||||||
shipping: {
|
shipping: {
|
||||||
|
@ -240,7 +229,10 @@ test.describe(
|
||||||
await api.get( 'customers' ).then( async ( response ) => {
|
await api.get( 'customers' ).then( async ( response ) => {
|
||||||
for ( let i = 0; i < response.data.length; i++ ) {
|
for ( let i = 0; i < response.data.length; i++ ) {
|
||||||
if (
|
if (
|
||||||
response.data[ i ].billing.email === newAccountEmail
|
[
|
||||||
|
newAccountEmail,
|
||||||
|
newAccountEmailWithCustomPassword,
|
||||||
|
].includes( response.data[ i ].billing.email )
|
||||||
) {
|
) {
|
||||||
await api.delete(
|
await api.delete(
|
||||||
`customers/${ response.data[ i ].id }`,
|
`customers/${ response.data[ i ].id }`,
|
||||||
|
@ -981,9 +973,11 @@ test.describe(
|
||||||
|
|
||||||
// For flakiness, sometimes the email address is not filled
|
// For flakiness, sometimes the email address is not filled
|
||||||
await page.getByLabel( 'Email address' ).click();
|
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(
|
await expect( page.getByLabel( 'Email address' ) ).toHaveValue(
|
||||||
newAccountEmail
|
newAccountEmailWithCustomPassword
|
||||||
);
|
);
|
||||||
|
|
||||||
// fill shipping address and check cash on delivery method
|
// fill shipping address and check cash on delivery method
|
||||||
|
@ -1020,7 +1014,9 @@ test.describe(
|
||||||
|
|
||||||
// Log in again.
|
// Log in again.
|
||||||
await page.goto( '/my-account/' );
|
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( '#password' ).fill( newAccountCustomPassword );
|
||||||
await page.locator( 'text=Log in' ).click();
|
await page.locator( 'text=Log in' ).click();
|
||||||
await expect(
|
await expect(
|
||||||
|
|
Loading…
Reference in New Issue