-
Notifications
You must be signed in to change notification settings - Fork 69
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
E2E Playwright Migration: convert shopper-checkout-failures spec #10105
Open
allie500
wants to merge
12
commits into
develop
Choose a base branch
from
dev/10061-e2e-create-playwright-shopper-checkout-failures-spec
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3c7fd63
Add WIP spec
allie500 44f1adc
Merge branch 'develop' into dev/10061-e2e-create-playwright-shopper-c…
allie500 655cb0d
Fix first test
allie500 274cfd7
Add tests 2 and 3
allie500 4045bd8
Merge branch 'develop' into dev/10061-e2e-create-playwright-shopper-c…
allie500 5bb2782
Add remaining tests
allie500 8d00e8b
Fix last two tests
allie500 5f06112
Remove Puppeteer file
allie500 9066649
Add changelog
allie500 ea488a6
Improve two tests
allie500 0e93bb6
Update beforeEach flow
allie500 c302e19
Merge branch 'develop' into dev/10061-e2e-create-playwright-shopper-c…
allie500 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
changelog/dev-10061-e2e-create-playwright-shopper-checkout-failures-spec
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 | ||
|
||
E2E Playwright Migration: convert shopper-checkout-failures spec to Playwright and remove Puppeteer spec. |
154 changes: 154 additions & 0 deletions
154
tests/e2e-pw/specs/shopper/shopper-checkout-failures.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 |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test, expect, Page } from '@playwright/test'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
|
||
import { config } from '../../config/default'; | ||
import * as shopper from '../../utils/shopper'; | ||
|
||
test.describe( 'Shopper > Checkout > Failures with various cards', () => { | ||
const waitForBanner = async ( page: Page, errorText: string ) => { | ||
await expect( page.getByText( errorText ) ).toBeVisible(); | ||
}; | ||
|
||
test.beforeEach( async ( { page } ) => { | ||
await shopper.addCartProduct( page ); | ||
|
||
await page.goto( '/checkout/' ); | ||
await shopper.fillBillingAddress( | ||
page, | ||
config.addresses.customer.billing | ||
); | ||
} ); | ||
|
||
test( 'should throw an error that the card was simply declined', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( page, config.cards.declined ); | ||
await shopper.placeOrder( page ); | ||
|
||
await waitForBanner( page, 'Error: Your card was declined.' ); | ||
} ); | ||
|
||
test( 'should throw an error that the card expiration date is in the past', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( | ||
page, | ||
config.cards[ 'declined-expired' ] | ||
); | ||
await shopper.placeOrder( page ); | ||
|
||
await waitForBanner( page, 'Error: Your card has expired.' ); | ||
} ); | ||
|
||
test( 'should throw an error that the card CVV number is invalid', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( | ||
page, | ||
config.cards[ 'invalid-cvv-number' ] | ||
); | ||
|
||
await page.keyboard.press( 'Tab' ); | ||
|
||
const frameHandle = await page.waitForSelector( | ||
'#payment .payment_method_woocommerce_payments .wcpay-upe-element iframe' | ||
); | ||
|
||
const stripeFrame = await frameHandle.contentFrame(); | ||
const cvcErrorText = await stripeFrame | ||
.locator( 'p#Field-cvcError' ) | ||
.innerText(); | ||
|
||
expect( cvcErrorText ).toContain( | ||
'Your card’s security code is incomplete.' | ||
); | ||
} ); | ||
|
||
test( 'should throw an error that the card was declined due to insufficient funds', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( page, config.cards[ 'declined-funds' ] ); | ||
await shopper.placeOrder( page ); | ||
|
||
await waitForBanner( page, 'Error: Your card has insufficient funds.' ); | ||
} ); | ||
|
||
test( 'should throw an error that the card was declined due to expired card', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( | ||
page, | ||
config.cards[ 'declined-expired' ] | ||
); | ||
await shopper.placeOrder( page ); | ||
|
||
await waitForBanner( page, 'Error: Your card has expired.' ); | ||
} ); | ||
|
||
test( 'should throw an error that the card was declined due to incorrect CVC number', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( page, config.cards[ 'declined-cvc' ] ); | ||
await shopper.placeOrder( page ); | ||
|
||
await waitForBanner( | ||
page, | ||
"Error: Your card's security code is incorrect." | ||
); | ||
} ); | ||
|
||
test( 'should throw an error that the card was declined due to processing error', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( | ||
page, | ||
config.cards[ 'declined-processing' ] | ||
); | ||
await shopper.placeOrder( page ); | ||
|
||
await waitForBanner( | ||
page, | ||
'Error: An error occurred while processing your card. Try again in a little bit.' | ||
); | ||
} ); | ||
|
||
test( 'should throw an error that the card was declined due to incorrect card number', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( | ||
page, | ||
config.cards[ 'declined-incorrect' ] | ||
); | ||
|
||
const frameHandle = await page.waitForSelector( | ||
'#payment .payment_method_woocommerce_payments .wcpay-upe-element iframe' | ||
); | ||
|
||
const stripeFrame = await frameHandle.contentFrame(); | ||
const numberErrorText = await stripeFrame | ||
.locator( 'p#Field-numberError' ) | ||
.innerText(); | ||
|
||
expect( numberErrorText ).toContain( 'Your card number is invalid.' ); | ||
} ); | ||
|
||
test( 'should throw an error that the card was declined due to invalid 3DS card', async ( { | ||
page, | ||
} ) => { | ||
await shopper.fillCardDetails( page, config.cards[ 'declined-3ds' ] ); | ||
await shopper.placeOrder( page ); | ||
|
||
await shopper.confirmCardAuthentication( page, false ); | ||
|
||
await waitForBanner( | ||
page, | ||
'We are unable to authenticate your payment method. Please choose a different payment method and try again.' | ||
); | ||
} ); | ||
} ); |
132 changes: 0 additions & 132 deletions
132
tests/e2e/specs/wcpay/shopper/shopper-checkout-failures.spec.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest replacing the redirect and billing address autofill with
shopper.setupCheckout()
, which handles those tasks while also performing additional checks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this suggestion, I've added it in 0e93bb6.