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

E2E Playwright Migration: convert shopper-checkout-failures spec #10105

Merged
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
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.
147 changes: 147 additions & 0 deletions tests/e2e-pw/specs/shopper/shopper-checkout-failures.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/**
* 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 shopper.setupCheckout( 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' );

await expect( cvcErrorText ).toHaveText(
'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'
);

expect( numberErrorText ).toHaveText( '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 tests/e2e/specs/wcpay/shopper/shopper-checkout-failures.spec.js

This file was deleted.

Loading