Skip to content

Commit

Permalink
Convert shopper applies coupon on cart E2E tests to Playwright (#10178)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpaksu authored Jan 21, 2025
1 parent a77413a commit 5e82528
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Convert shopper free coupon checkout E2E test to Playwright
75 changes: 75 additions & 0 deletions tests/e2e-pw/specs/shopper/shopper-checkout-cart-coupon.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* External dependencies
*/
import test, { expect } from '@playwright/test';

/**
* Internal dependencies
*/
import { config } from '../../config/default';
import {
goToCart,
goToCheckout,
goToShop,
} from '../../utils/shopper-navigation';
import { useShopper } from '../../utils/helpers';
import {
addToCartFromShopPage,
emptyCart,
fillBillingAddress,
fillCardDetails,
placeOrder,
setupCheckout,
} from '../../utils/shopper';

const productName = config.products.simple.name;

test.describe(
'Checkout with free coupon & after modifying cart on Checkout page',
() => {
// All tests will use the shopper only.
useShopper();

test.beforeEach( async ( { page } ) => {
await goToShop( page );
await addToCartFromShopPage( page, productName );
await goToCart( page );
await page.getByPlaceholder( 'Coupon code' ).fill( 'free' );
await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
} );

test.afterEach( async ( { page } ) => {
await emptyCart( page );
} );

test( 'Checkout with a free coupon', async ( { page } ) => {
await goToCheckout( page );
await fillBillingAddress( page, config.addresses.customer.billing );
await placeOrder( page );
await page.waitForURL( /\/order-received\//, {
waitUntil: 'load',
} );
await expect(
page.getByRole( 'heading', {
name: 'Order received',
} )
).toBeVisible();
} );

test( 'Remove free coupon, then checkout', async ( { page } ) => {
await goToCheckout( page );
await page.getByRole( 'link', { name: '[Remove]' } ).click();
await setupCheckout( page, config.addresses.customer.billing );
await fillCardDetails( page, config.cards.basic );
await placeOrder( page );
await page.waitForURL( /\/order-received\//, {
waitUntil: 'load',
} );
await expect(
page.getByRole( 'heading', {
name: 'Order received',
} )
).toBeVisible();
} );
}
);
4 changes: 2 additions & 2 deletions tests/e2e-pw/utils/shopper-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export const goToProductPageBySlug = async (

export const goToCart = async ( page: Page ) => {
await page.goto( '/cart/', { waitUntil: 'load' } );
isUIUnblocked( page );
await isUIUnblocked( page );
};

export const goToCheckout = async ( page: Page ) => {
await page.goto( '/checkout/', { waitUntil: 'load' } );
isUIUnblocked( page );
await isUIUnblocked( page );
};

export const goToOrders = async ( page: Page ) => {
Expand Down
80 changes: 0 additions & 80 deletions tests/e2e/specs/wcpay/shopper/shopper-checkout-free-cart.spec.js

This file was deleted.

0 comments on commit 5e82528

Please sign in to comment.