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

Convert shopper applies coupon on cart E2E tests to Playwright #10178

Merged
merged 2 commits into from
Jan 21, 2025
Merged
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
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.

Loading