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

Commit

Permalink
Update testing cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tarhi-saad committed Aug 18, 2023
1 parent 09ed9de commit f4426e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { test as base, expect } from '@woocommerce/e2e-playwright-utils';
* Internal dependencies
*/
import { CheckoutPage } from './checkout.page';
import { SIMPLE_PHYSICAL_PRODUCT_NAME } from './constants';
import {
SIMPLE_PHYSICAL_PRODUCT_NAME,
FREE_SHIPPING_NAME,
FREE_SHIPPING_PRICE,
} from './constants';

const test = base.extend< { pageObject: CheckoutPage } >( {
pageObject: async ( { page }, use ) => {
Expand All @@ -18,21 +22,14 @@ const test = base.extend< { pageObject: CheckoutPage } >( {
},
} );

test.describe( 'Shopper → Checkout block → Place Order', () => {
const FREE_SHIPPING_NAME = 'Free shipping';
const FREE_SHIPPING_PRICE = '$0.00';
test.describe( 'Shopper → Checkout block → Place Order → customer', () => {
test.use( { storageState: 'playwright/.auth/customer.json' } );

test( 'Guest user can place order', async ( {
pageObject,
frontendUtils,
page,
} ) => {
// We want to logout if we are logged in.
// eslint-disable-next-line playwright/no-conditional-in-test
if ( await frontendUtils.isLoggedIn() ) {
await frontendUtils.logout();
}

await frontendUtils.emptyCart();
await frontendUtils.goToShop();
await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
Expand All @@ -49,13 +46,17 @@ test.describe( 'Shopper → Checkout block → Place Order', () => {
page.getByText( 'Your order has been received.' )
).toBeVisible();
} );
} );

test.describe( 'Shopper → Checkout block → Place Order → guest', () => {
test.use( { storageState: 'playwright/.auth/guest.json' } );

test( 'Logged in user can place an order', async ( {
pageObject,
frontendUtils,
page,
} ) => {
await frontendUtils.login();
// await frontendUtils.login();
await frontendUtils.emptyCart();
await frontendUtils.goToShop();
await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/tests/checkout/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export const SIMPLE_VIRTUAL_PRODUCT_NAME = 'Album';
export const SIMPLE_PHYSICAL_PRODUCT_NAME = 'Beanie';
export const FREE_SHIPPING_NAME = 'Free shipping';
export const FREE_SHIPPING_PRICE = '$0.00';

0 comments on commit f4426e1

Please sign in to comment.