Add APM tests in pw

This commit is contained in:
Alex P 2023-06-23 10:56:21 +03:00
parent e0a39b1c4e
commit a088c9cabb
No known key found for this signature in database
GPG key ID: 54487A734A204D71
4 changed files with 64 additions and 4 deletions

View file

@ -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', () => {