mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Add APM tests in pw
This commit is contained in:
parent
e0a39b1c4e
commit
a088c9cabb
4 changed files with 64 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
const {test, expect} = require('@playwright/test');
|
||||
const {serverExec} = require("./utils/server");
|
||||
const {fillCheckoutForm, expectOrderReceivedPage} = require("./utils/checkout");
|
||||
const {fillCheckoutForm, expectOrderReceivedPage, acceptTerms} = require("./utils/checkout");
|
||||
const {openPaypalPopup, loginIntoPaypal, waitForPaypalShippingList, completePaypalPayment} = require("./utils/paypal-popup");
|
||||
|
||||
const {
|
||||
|
@ -11,9 +11,11 @@ const {
|
|||
PRODUCT_ID,
|
||||
CHECKOUT_URL,
|
||||
CHECKOUT_PAGE_ID,
|
||||
CART_URL,
|
||||
BLOCK_CHECKOUT_URL,
|
||||
BLOCK_CHECKOUT_PAGE_ID,
|
||||
BLOCK_CART_URL,
|
||||
APM_ID,
|
||||
} = process.env;
|
||||
|
||||
async function completeBlockContinuation(page) {
|
||||
|
@ -88,6 +90,47 @@ test.describe('Classic checkout', () => {
|
|||
|
||||
await expectOrderReceivedPage(page);
|
||||
});
|
||||
|
||||
test('PayPal APM button place order', async ({page}) => {
|
||||
await page.goto(CART_URL + '?add-to-cart=' + PRODUCT_ID);
|
||||
|
||||
await page.goto(CHECKOUT_URL);
|
||||
|
||||
await fillCheckoutForm(page);
|
||||
|
||||
const popup = await openPaypalPopup(page, {fundingSource: APM_ID});
|
||||
|
||||
await popup.getByText('Continue', { exact: true }).click();
|
||||
await completePaypalPayment(popup, {selector: '[name="Successful"]'});
|
||||
|
||||
await expectOrderReceivedPage(page);
|
||||
});
|
||||
|
||||
test('PayPal APM button place order when redirect fails', async ({page}) => {
|
||||
await page.goto(CART_URL + '?add-to-cart=' + PRODUCT_ID);
|
||||
|
||||
await page.goto(CHECKOUT_URL);
|
||||
|
||||
await fillCheckoutForm(page);
|
||||
|
||||
await page.evaluate('PayPalCommerceGateway.ajax.approve_order = null');
|
||||
|
||||
const popup = await openPaypalPopup(page, {fundingSource: APM_ID});
|
||||
|
||||
await popup.getByText('Continue', { exact: true }).click();
|
||||
await completePaypalPayment(popup, {selector: '[name="Successful"]'});
|
||||
|
||||
await expect(page.locator('.woocommerce-error')).toBeVisible();
|
||||
|
||||
await page.reload();
|
||||
await expectContinuation(page);
|
||||
|
||||
await acceptTerms(page);
|
||||
|
||||
await completeContinuation(page);
|
||||
|
||||
await expectOrderReceivedPage(page);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Block checkout', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue