-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Shopper Checkout Purchase spec to Playwright (#10198)
- Loading branch information
1 parent
cd2fbc2
commit 7e2db04
Showing
3 changed files
with
64 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
89
tests/e2e-pw/specs/shopper/shopper-checkout-purchase.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
83
tests/e2e/specs/wcpay/shopper/shopper-checkout-purchase.spec.js
This file was deleted.
Oops, something went wrong.