Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Convert checkout place order E2E tests to Playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
tarhi-saad committed Aug 15, 2023
1 parent 911056a commit 9243cbd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 25 deletions.
25 changes: 0 additions & 25 deletions tests/e2e-jest/specs/shopper/cart-checkout/checkout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,31 +333,6 @@ describe( 'Shopper → Checkout', () => {
} );
} );

describe( 'Place Order', () => {
it( 'Guest user can place order', async () => {
if ( await shopper.isLoggedIn() ) {
await shopper.logout();
}
await shopper.block.goToShop();
await shopper.addToCartFromShopPage( SIMPLE_VIRTUAL_PRODUCT_NAME );
await shopper.block.goToCheckout();
await shopper.block.fillBillingDetails( BILLING_DETAILS );
await shopper.block.placeOrder();
await expect( page ).toMatch( 'Your order has been received.' );
} );

it( 'Logged in user can place an order', async () => {
await shopper.login();
await shopper.block.goToShop();
await shopper.addToCartFromShopPage( SIMPLE_VIRTUAL_PRODUCT_NAME );
await shopper.block.goToCheckout();
await shopper.block.fillBillingDetails( BILLING_DETAILS );
await shopper.block.placeOrder();
await expect( page ).toMatch( 'Your order has been received.' );
await shopper.logout();
} );
} );

describe( `Shipping`, () => {
afterEach( async () => {
await merchant.login();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* External dependencies
*/
import { test as base, expect } from '@woocommerce/e2e-playwright-utils';

/**
* Internal dependencies
*/
import { CheckoutPage } from './checkout.page';
import { SIMPLE_VIRTUAL_PRODUCT_NAME } from './constants';

const test = base.extend< { pageObject: CheckoutPage } >( {
pageObject: async ( { page }, use ) => {
const pageObject = new CheckoutPage( {
page,
} );
await use( pageObject );
},
} );

test.describe( 'Shopper → Checkout block → Place Order', () => {
test.beforeEach( async ( { frontendUtils } ) => {
await frontendUtils.emptyCart();
await frontendUtils.goToShop();
await frontendUtils.addToCart( SIMPLE_VIRTUAL_PRODUCT_NAME );
await frontendUtils.goToCheckout();
} );

test( 'Guest user can place order', async ( { pageObject, page } ) => {
await pageObject.fillInCheckoutWithTestData();
await pageObject.placeOrder();
await expect(
page.getByText( 'Your order has been received.' )
).toBeVisible();
} );

test( 'Logged in user can place an order', async ( {
pageObject,
page,
} ) => {
await pageObject.fillInCheckoutWithTestData();
await pageObject.placeOrder();
await expect(
page.getByText( 'Your order has been received.' )
).toBeVisible();
} );
} );
1 change: 1 addition & 0 deletions tests/e2e/tests/checkout/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SIMPLE_VIRTUAL_PRODUCT_NAME = 'Album';

0 comments on commit 9243cbd

Please sign in to comment.