Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve e2e flakiness #3694

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions tests/e2e/test-data/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@
"label": "Visa ending in 0002",
"error": [
"The card was declined.",
"Your card was declined."
"Your card was declined.",
"The card has been declined.",
"Your card has been declined."
]
},
"declined-funds": {
Expand Down Expand Up @@ -190,7 +192,7 @@
},
"cvc": "626",
"label": "Visa ending in 0069",
"error": [ "The card has expired.", "Your card has expired." ]
"error": [ "The card has expired.", "Your card has expired.", "Your card is expired." ]
},
"declined-cvc": {
"number": "4000000000000127",
Expand All @@ -202,7 +204,8 @@
"label": "Visa ending in 0127",
"error": [
"The card's security code is incorrect.",
"Your card's security code is incorrect."
"Your card's security code is incorrect.",
"Your card.s CVC is incorrect."
]
},
"declined-processing": {
Expand All @@ -215,7 +218,7 @@
"label": "Visa ending in 0119",
"error": [
"An error occurred while processing the card.",
"An error occurred while processing your card. Try again in a little bit."
"An error occurred while processing your card."
]
},
"declined-3ds": {
Expand Down Expand Up @@ -244,6 +247,15 @@
},
"cvc": "11",
"label": "Visa ending in 4242"
},
"no-3ds": {
"number": "378282246310005",
"expires": {
"month": "06",
"year": "29"
},
"cvc": "626",
"label": "3DS not supported"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test( 'customer can checkout with a SCA card @smoke @blocks', async ( {
name: 'stripe-challenge-frame',
} )
.getByRole( 'button', { name: 'Complete' } )
.click();
.dispatchEvent( 'click' );

await page.waitForURL( '**/checkout/order-received/**' );

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/checkout/blocks/subscription-product.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ test( 'customer can purchase a subscription product @smoke @blocks @subscription
};

await setupBlocksCheckout( page, customerData );
await fillCreditCardDetails( page, config.get( 'cards.basic' ) );
await fillCreditCardDetails( page, config.get( 'cards.no-3ds' ) );

await page.locator( 'text=Sign up now' ).click();
await page.waitForNavigation();
await page.waitForURL( '**/checkout/order-received/**' );

await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
'Order received'
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/tests/checkout/shortcode/card-failures.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const testCard = async ( page, cardKey ) => {
const card = config.get( cardKey );

await fillCreditCardDetailsShortcode( page, card );
await page.locator( 'text=Place order' ).click();
await page.locator( 'text=Place order' ).dispatchEvent( 'click' );

expect
.soft( await page.innerText( '.woocommerce-error' ) )
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/tests/checkout/shortcode/normal-card.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test( 'customer can checkout with a normal credit card @smoke', async ( {
config.get( 'addresses.customer.billing' )
);
await fillCreditCardDetailsShortcode( page, config.get( 'cards.basic' ) );
await page.locator( 'text=Place order' ).click();
await page.locator( 'text=Place order' ).dispatchEvent( 'click' );
await page.waitForNavigation();

await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/checkout/shortcode/saved-card.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test( 'customer can checkout with a saved card @smoke', async ( { page } ) => {
// check box to save payment method.
await page.locator( '#wc-stripe-new-payment-method' ).click();

await page.locator( 'text=Place order' ).click();
await page.locator( 'text=Place order' ).dispatchEvent( 'click' );

await page.waitForNavigation();
await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
Expand All @@ -68,7 +68,7 @@ test( 'customer can checkout with a saved card @smoke', async ( { page } ) => {
)
).toHaveCount( 1 );

await page.locator( 'text=Place order' ).click();
await page.locator( 'text=Place order' ).dispatchEvent( 'click' );

await page.waitForNavigation();
await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/tests/checkout/shortcode/sca-card.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test( 'customer can checkout with a SCA card @smoke', async ( { page } ) => {
config.get( 'addresses.customer.billing' )
);
await fillCreditCardDetailsShortcode( page, config.get( 'cards.3ds' ) );
await page.locator( 'text=Place order' ).click();
await page.locator( 'text=Place order' ).dispatchEvent( 'click' );

// Wait until the SCA frame is available
while (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test( 'customer can purchase a subscription product @smoke @subscriptions', asyn
await fillCreditCardDetailsShortcode( page, config.get( 'cards.basic' ) );

await page.locator( 'text=Sign up now' ).click();
await page.waitForNavigation();
await page.waitForURL( '**/checkout/order-received/**' );

await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
'Order received'
Expand Down
16 changes: 16 additions & 0 deletions tests/e2e/tests/default.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,19 @@ setup( 'Disable legacy checkout experience', async ( { browser } ) => {
page.getByTestId( 'legacy-checkout-experience-checkbox' )
).not.toBeChecked();
} );

setup( 'Disable Link by Stripe', async ( { browser } ) => {
const adminContext = await browser.newContext( {
storageState: process.env.ADMINSTATE,
} );
const page = await adminContext.newPage();

await page.goto(
'/wp-admin/admin.php?page=wc-settings&tab=checkout&section=stripe&panel=methods'
);
await page.getByLabel( 'Link by Stripe Input' ).uncheck();
await page.click( 'text=Save changes' );

await expect( page.getByText( 'Settings saved.' ) ).toBeDefined();
await expect( page.getByLabel( 'Link by Stripe Input' ) ).not.toBeChecked();
} );
2 changes: 1 addition & 1 deletion tests/e2e/tests/orders/full-refund.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test( 'merchant can issue a full refund @smoke', async ( { browser } ) => {
userPage,
config.get( 'cards.basic' )
);
await userPage.locator( 'text=Place order' ).click();
await userPage.locator( 'text=Place order' ).dispatchEvent( 'click' );
await userPage.waitForURL( '**/checkout/order-received/**' );

await expect( userPage.locator( 'h1.entry-title' ) ).toHaveText(
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/tests/subscriptions/subscription-renewal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ test( 'customer can renew a subscription @smoke @subscriptions', async ( {
await page.click(
'input[id^="radio-control-wc-payment-method-saved-tokens-"]'
);
await page.click( 'text=Renew subscription' );
await page
.locator( 'text=Renew subscription' )
.dispatchEvent( 'click' );
await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
'Order received'
);
Expand Down
10 changes: 7 additions & 3 deletions tests/e2e/utils/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ export async function setupShortcodeCheckout( page, billingDetails = null ) {

for ( const fieldName of Object.keys( billingDetails ) ) {
if (
[ 'state', 'country', 'state_iso', 'country_iso' ].includes(
fieldName
)
[
'state',
'country',
'state_iso',
'country_iso',
'company',
].includes( fieldName )
) {
continue;
}
Expand Down
Loading