Skip to content

Commit e40174b

Browse files
Update the flow for clicking on the place order button for WC blocks
1 parent b1db512 commit e40174b

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

tests/e2e-pw/specs/wcpay/shopper/shopper-wc-blocks-checkout-failures.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ describeif( shouldRunWCBlocksTests )(
9797
for ( const { card, error, auth } of failures ) {
9898
test( `Should show error – ${ error }`, async () => {
9999
await shopper.fillCardDetailsWCB( shopperPage, card );
100-
await shopperPage
101-
.getByRole( 'button', { name: 'Place Order' } )
102-
.click();
100+
await shopper.placeOrderWCB( shopperPage, false );
101+
103102
if ( auth ) {
104103
await shopper.confirmCardAuthentication( shopperPage );
105104
}

tests/e2e-pw/utils/shopper.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,30 @@ export const placeOrder = async ( page: Page ) => {
139139
}
140140
};
141141

142-
export const placeOrderWCB = async ( page: Page ) => {
143-
const placeOrderButton = page.getByRole( 'button', {
144-
name: 'Place Order',
145-
} );
142+
export const placeOrderWCB = async (
143+
page: Page,
144+
confirmOrderReceived = true
145+
) => {
146+
const placeOrderButton = page.locator(
147+
'.wc-block-components-checkout-place-order-button'
148+
);
146149

147150
await placeOrderButton.focus();
148151
await waitForUiRefresh( page );
149152

150153
await placeOrderButton.click();
151154

152-
await page.waitForURL( /\/order-received\// );
153-
await expect(
154-
page.getByRole( 'heading', { name: 'Order received' } )
155-
).toBeVisible();
155+
await expect( placeOrderButton ).toBeDisabled();
156+
await expect( placeOrderButton ).toHaveClass(
157+
/wc-block-components-button--loading/
158+
);
159+
160+
if ( confirmOrderReceived ) {
161+
await page.waitForURL( /\/order-received\// );
162+
await expect(
163+
page.getByRole( 'heading', { name: 'Order received' } )
164+
).toBeVisible();
165+
}
156166
};
157167

158168
const ensureSavedCardNotSelected = async ( page: Page ) => {
@@ -248,7 +258,7 @@ export const confirmCardAuthentication = async (
248258
authorize = true
249259
) => {
250260
// Wait for the Stripe modal to appear.
251-
await page.waitForTimeout( 3000 );
261+
await page.waitForTimeout( 5000 );
252262

253263
// Stripe card input also uses __privateStripeFrame as a prefix, so need to make sure we wait for an iframe that
254264
// appears at the top of the DOM.

0 commit comments

Comments
 (0)