Skip to content

Commit

Permalink
Convert Shopper Checkout Purchase spec to Playwright (#10198)
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaeldcom authored Jan 22, 2025
1 parent cd2fbc2 commit 7e2db04
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 112 deletions.
4 changes: 4 additions & 0 deletions changelog/dev-10177-convert-shopper-checkout-purchase-spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Convert shopper-checkout-purchase spec from Puppeteer to Playwright
89 changes: 60 additions & 29 deletions tests/e2e-pw/specs/shopper/shopper-checkout-purchase.spec.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,73 @@
/**
* External dependencies
*/
import { test, expect } from '@playwright/test';
import { test, expect, Page } from '@playwright/test';

/**
* Internal dependencies
*/

import { config } from '../../config/default';
import * as shopper from '../../utils/shopper';
import * as devtools from '../../utils/devtools';
import { getMerchant, getShopper } from '../../utils/helpers';

test.describe( 'Successful purchase', () => {
test.beforeEach( async ( { page } ) => {
await shopper.addCartProduct( page );

await page.goto( '/checkout/' );
await shopper.fillBillingAddress(
page,
config.addresses.customer.billing
);
} );

test( 'using a basic card', async ( { page } ) => {
await shopper.fillCardDetails( page );
await shopper.placeOrder( page );

await expect(
page.getByText( 'Order received' ).first()
).toBeVisible();
} );

test( 'using a 3DS card', async ( { page } ) => {
await shopper.fillCardDetails( page, config.cards[ '3ds' ] );
await shopper.placeOrder( page );
await shopper.confirmCardAuthentication( page );

await expect(
page.getByText( 'Order received' ).first()
).toBeVisible();
} );
let merchantPage: Page;
let shopperPage: Page;

for ( const ctpEnabled of [ false, true ] ) {
test.describe( `Carding protection ${ ctpEnabled }`, () => {
test.beforeAll( async ( { browser } ) => {
shopperPage = ( await getShopper( browser ) ).shopperPage;
merchantPage = ( await getMerchant( browser ) ).merchantPage;
if ( ctpEnabled ) {
await devtools.enableCardTestingProtection( merchantPage );
}
} );

test.afterAll( async () => {
if ( ctpEnabled ) {
await devtools.disableCardTestingProtection( merchantPage );
}
} );

test.beforeEach( async () => {
await shopper.addCartProduct( shopperPage );
await shopper.setupCheckout(
shopperPage,
config.addresses.customer.billing
);
await shopper.expectFraudPreventionToken(
shopperPage,
ctpEnabled
);
} );

test( 'using a basic card', async () => {
await shopper.fillCardDetails( shopperPage );
await shopper.placeOrder( shopperPage );

await expect(
shopperPage.getByRole( 'heading', {
name: 'Order received',
} )
).toBeVisible();
} );

test( 'using a 3DS card', async () => {
await shopper.fillCardDetails(
shopperPage,
config.cards[ '3ds' ]
);
await shopper.placeOrder( shopperPage );
await shopper.confirmCardAuthentication( shopperPage );
await expect(
shopperPage.getByRole( 'heading', {
name: 'Order received',
} )
).toBeVisible();
} );
} );
}
} );
83 changes: 0 additions & 83 deletions tests/e2e/specs/wcpay/shopper/shopper-checkout-purchase.spec.js

This file was deleted.

0 comments on commit 7e2db04

Please sign in to comment.