Skip to content

Commit 93b9163

Browse files
authored
E2E Playwright Migration: convert shopper-checkout-failures spec (#10105)
1 parent 4345d63 commit 93b9163

File tree

3 files changed

+151
-132
lines changed

3 files changed

+151
-132
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: dev
3+
4+
E2E Playwright Migration: convert shopper-checkout-failures spec to Playwright and remove Puppeteer spec.
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { test, expect, Page } from '@playwright/test';
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
10+
import { config } from '../../config/default';
11+
import * as shopper from '../../utils/shopper';
12+
13+
test.describe( 'Shopper > Checkout > Failures with various cards', () => {
14+
const waitForBanner = async ( page: Page, errorText: string ) => {
15+
await expect( page.getByText( errorText ) ).toBeVisible();
16+
};
17+
18+
test.beforeEach( async ( { page } ) => {
19+
await shopper.addCartProduct( page );
20+
await shopper.setupCheckout( page, config.addresses.customer.billing );
21+
} );
22+
23+
test( 'should throw an error that the card was simply declined', async ( {
24+
page,
25+
} ) => {
26+
await shopper.fillCardDetails( page, config.cards.declined );
27+
await shopper.placeOrder( page );
28+
29+
await waitForBanner( page, 'Error: Your card was declined.' );
30+
} );
31+
32+
test( 'should throw an error that the card expiration date is in the past', async ( {
33+
page,
34+
} ) => {
35+
await shopper.fillCardDetails(
36+
page,
37+
config.cards[ 'declined-expired' ]
38+
);
39+
await shopper.placeOrder( page );
40+
41+
await waitForBanner( page, 'Error: Your card has expired.' );
42+
} );
43+
44+
test( 'should throw an error that the card CVV number is invalid', async ( {
45+
page,
46+
} ) => {
47+
await shopper.fillCardDetails(
48+
page,
49+
config.cards[ 'invalid-cvv-number' ]
50+
);
51+
52+
await page.keyboard.press( 'Tab' );
53+
54+
const frameHandle = await page.waitForSelector(
55+
'#payment .payment_method_woocommerce_payments .wcpay-upe-element iframe'
56+
);
57+
58+
const stripeFrame = await frameHandle.contentFrame();
59+
const cvcErrorText = await stripeFrame.locator( 'p#Field-cvcError' );
60+
61+
await expect( cvcErrorText ).toHaveText(
62+
'Your card’s security code is incomplete.'
63+
);
64+
} );
65+
66+
test( 'should throw an error that the card was declined due to insufficient funds', async ( {
67+
page,
68+
} ) => {
69+
await shopper.fillCardDetails( page, config.cards[ 'declined-funds' ] );
70+
await shopper.placeOrder( page );
71+
72+
await waitForBanner( page, 'Error: Your card has insufficient funds.' );
73+
} );
74+
75+
test( 'should throw an error that the card was declined due to expired card', async ( {
76+
page,
77+
} ) => {
78+
await shopper.fillCardDetails(
79+
page,
80+
config.cards[ 'declined-expired' ]
81+
);
82+
await shopper.placeOrder( page );
83+
84+
await waitForBanner( page, 'Error: Your card has expired.' );
85+
} );
86+
87+
test( 'should throw an error that the card was declined due to incorrect CVC number', async ( {
88+
page,
89+
} ) => {
90+
await shopper.fillCardDetails( page, config.cards[ 'declined-cvc' ] );
91+
await shopper.placeOrder( page );
92+
93+
await waitForBanner(
94+
page,
95+
"Error: Your card's security code is incorrect."
96+
);
97+
} );
98+
99+
test( 'should throw an error that the card was declined due to processing error', async ( {
100+
page,
101+
} ) => {
102+
await shopper.fillCardDetails(
103+
page,
104+
config.cards[ 'declined-processing' ]
105+
);
106+
await shopper.placeOrder( page );
107+
108+
await waitForBanner(
109+
page,
110+
'Error: An error occurred while processing your card. Try again in a little bit.'
111+
);
112+
} );
113+
114+
test( 'should throw an error that the card was declined due to incorrect card number', async ( {
115+
page,
116+
} ) => {
117+
await shopper.fillCardDetails(
118+
page,
119+
config.cards[ 'declined-incorrect' ]
120+
);
121+
122+
const frameHandle = await page.waitForSelector(
123+
'#payment .payment_method_woocommerce_payments .wcpay-upe-element iframe'
124+
);
125+
126+
const stripeFrame = await frameHandle.contentFrame();
127+
const numberErrorText = await stripeFrame.locator(
128+
'p#Field-numberError'
129+
);
130+
131+
expect( numberErrorText ).toHaveText( 'Your card number is invalid.' );
132+
} );
133+
134+
test( 'should throw an error that the card was declined due to invalid 3DS card', async ( {
135+
page,
136+
} ) => {
137+
await shopper.fillCardDetails( page, config.cards[ 'declined-3ds' ] );
138+
await shopper.placeOrder( page );
139+
140+
await shopper.confirmCardAuthentication( page, false );
141+
142+
await waitForBanner(
143+
page,
144+
'We are unable to authenticate your payment method. Please choose a different payment method and try again.'
145+
);
146+
} );
147+
} );

tests/e2e/specs/wcpay/shopper/shopper-checkout-failures.spec.js

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)