Skip to content

Commit 5e82528

Browse files
authored
Convert shopper applies coupon on cart E2E tests to Playwright (#10178)
1 parent a77413a commit 5e82528

File tree

4 files changed

+81
-82
lines changed

4 files changed

+81
-82
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+
Convert shopper free coupon checkout E2E test to Playwright
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import test, { expect } from '@playwright/test';
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
import { config } from '../../config/default';
10+
import {
11+
goToCart,
12+
goToCheckout,
13+
goToShop,
14+
} from '../../utils/shopper-navigation';
15+
import { useShopper } from '../../utils/helpers';
16+
import {
17+
addToCartFromShopPage,
18+
emptyCart,
19+
fillBillingAddress,
20+
fillCardDetails,
21+
placeOrder,
22+
setupCheckout,
23+
} from '../../utils/shopper';
24+
25+
const productName = config.products.simple.name;
26+
27+
test.describe(
28+
'Checkout with free coupon & after modifying cart on Checkout page',
29+
() => {
30+
// All tests will use the shopper only.
31+
useShopper();
32+
33+
test.beforeEach( async ( { page } ) => {
34+
await goToShop( page );
35+
await addToCartFromShopPage( page, productName );
36+
await goToCart( page );
37+
await page.getByPlaceholder( 'Coupon code' ).fill( 'free' );
38+
await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
39+
} );
40+
41+
test.afterEach( async ( { page } ) => {
42+
await emptyCart( page );
43+
} );
44+
45+
test( 'Checkout with a free coupon', async ( { page } ) => {
46+
await goToCheckout( page );
47+
await fillBillingAddress( page, config.addresses.customer.billing );
48+
await placeOrder( page );
49+
await page.waitForURL( /\/order-received\//, {
50+
waitUntil: 'load',
51+
} );
52+
await expect(
53+
page.getByRole( 'heading', {
54+
name: 'Order received',
55+
} )
56+
).toBeVisible();
57+
} );
58+
59+
test( 'Remove free coupon, then checkout', async ( { page } ) => {
60+
await goToCheckout( page );
61+
await page.getByRole( 'link', { name: '[Remove]' } ).click();
62+
await setupCheckout( page, config.addresses.customer.billing );
63+
await fillCardDetails( page, config.cards.basic );
64+
await placeOrder( page );
65+
await page.waitForURL( /\/order-received\//, {
66+
waitUntil: 'load',
67+
} );
68+
await expect(
69+
page.getByRole( 'heading', {
70+
name: 'Order received',
71+
} )
72+
).toBeVisible();
73+
} );
74+
}
75+
);

tests/e2e-pw/utils/shopper-navigation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ export const goToProductPageBySlug = async (
2828

2929
export const goToCart = async ( page: Page ) => {
3030
await page.goto( '/cart/', { waitUntil: 'load' } );
31-
isUIUnblocked( page );
31+
await isUIUnblocked( page );
3232
};
3333

3434
export const goToCheckout = async ( page: Page ) => {
3535
await page.goto( '/checkout/', { waitUntil: 'load' } );
36-
isUIUnblocked( page );
36+
await isUIUnblocked( page );
3737
};
3838

3939
export const goToOrders = async ( page: Page ) => {

tests/e2e/specs/wcpay/shopper/shopper-checkout-free-cart.spec.js

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

0 commit comments

Comments
 (0)