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 Checkout Purchase spec to Playwright #10198

Merged
merged 5 commits into from
Jan 22, 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
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.

Loading