mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Refactor tests
This commit is contained in:
parent
885d7cab19
commit
825ee0add6
2 changed files with 24 additions and 8 deletions
|
@ -2,6 +2,11 @@ PPCP_E2E_WP_DIR=${ROOT_DIR}/.ddev/wordpress
|
||||||
|
|
||||||
BASEURL="https://woocommerce-paypal-payments.ddev.site"
|
BASEURL="https://woocommerce-paypal-payments.ddev.site"
|
||||||
|
|
||||||
|
CHECKOUT_URL="/checkout"
|
||||||
|
CART_URL="/cart"
|
||||||
|
BLOCK_CHECKOUT_URL="/checkout-block"
|
||||||
|
BLOCK_CART_URL="/cart-block"
|
||||||
|
|
||||||
PRODUCT_URL="/product/prod"
|
PRODUCT_URL="/product/prod"
|
||||||
PRODUCT_ID=123
|
PRODUCT_ID=123
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,10 @@ const {
|
||||||
CREDIT_CARD_CVV,
|
CREDIT_CARD_CVV,
|
||||||
PRODUCT_URL,
|
PRODUCT_URL,
|
||||||
PRODUCT_ID,
|
PRODUCT_ID,
|
||||||
|
CHECKOUT_URL,
|
||||||
|
CART_URL,
|
||||||
|
BLOCK_CHECKOUT_URL,
|
||||||
|
BLOCK_CART_URL,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
async function fillCheckoutForm(page) {
|
async function fillCheckoutForm(page) {
|
||||||
|
@ -63,6 +67,13 @@ async function loginIntoPaypal(popup) {
|
||||||
await popup.locator('#btnLogin').click();
|
await popup.locator('#btnLogin').click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function completePaypalPayment(popup) {
|
||||||
|
await Promise.all([
|
||||||
|
popup.waitForEvent('close', {timeout: 20000}),
|
||||||
|
popup.click('#payment-submit-btn'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
async function expectOrderReceivedPage(page) {
|
async function expectOrderReceivedPage(page) {
|
||||||
const title = await page.locator('.entry-title');
|
const title = await page.locator('.entry-title');
|
||||||
await expect(title).toHaveText('Order received');
|
await expect(title).toHaveText('Order received');
|
||||||
|
@ -88,7 +99,7 @@ test('PayPal button place order from Product page', async ({page}) => {
|
||||||
|
|
||||||
await loginIntoPaypal(popup);
|
await loginIntoPaypal(popup);
|
||||||
|
|
||||||
await popup.locator('#payment-submit-btn').click();
|
await completePaypalPayment(popup);
|
||||||
|
|
||||||
await fillCheckoutForm(page);
|
await fillCheckoutForm(page);
|
||||||
|
|
||||||
|
@ -105,7 +116,7 @@ test('Advanced Credit and Debit Card (ACDC) place order from Checkout page', asy
|
||||||
await page.goto(PRODUCT_URL);
|
await page.goto(PRODUCT_URL);
|
||||||
await page.locator('.single_add_to_cart_button').click();
|
await page.locator('.single_add_to_cart_button').click();
|
||||||
|
|
||||||
await page.goto('/checkout/');
|
await page.goto(CHECKOUT_URL);
|
||||||
await fillCheckoutForm(page);
|
await fillCheckoutForm(page);
|
||||||
|
|
||||||
await page.click("text=Credit Cards");
|
await page.click("text=Credit Cards");
|
||||||
|
@ -127,30 +138,30 @@ test('Advanced Credit and Debit Card (ACDC) place order from Checkout page', asy
|
||||||
await expectOrderReceivedPage(page);
|
await expectOrderReceivedPage(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('PayPal express block', async ({page}) => {
|
test('PayPal express block checkout', async ({page}) => {
|
||||||
|
|
||||||
await page.goto('/cart?add-to-cart=' + PRODUCT_ID);
|
await page.goto('?add-to-cart=' + PRODUCT_ID);
|
||||||
|
|
||||||
await page.goto('/blocks-checkout')
|
await page.goto(BLOCK_CHECKOUT_URL)
|
||||||
|
|
||||||
const popup = await openPaypalPopup(page);
|
const popup = await openPaypalPopup(page);
|
||||||
|
|
||||||
await loginIntoPaypal(popup);
|
await loginIntoPaypal(popup);
|
||||||
|
|
||||||
await popup.locator('#payment-submit-btn').click();
|
await completePaypalPayment(popup);
|
||||||
|
|
||||||
await completeBlockContinuation(page);
|
await completeBlockContinuation(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('PayPal express block cart', async ({page}) => {
|
test('PayPal express block cart', async ({page}) => {
|
||||||
|
|
||||||
await page.goto('/cart-block?add-to-cart=' + PRODUCT_ID)
|
await page.goto(BLOCK_CART_URL + '?add-to-cart=' + PRODUCT_ID)
|
||||||
|
|
||||||
const popup = await openPaypalPopup(page);
|
const popup = await openPaypalPopup(page);
|
||||||
|
|
||||||
await loginIntoPaypal(popup);
|
await loginIntoPaypal(popup);
|
||||||
|
|
||||||
await popup.locator('#payment-submit-btn').click();
|
await completePaypalPayment(popup);
|
||||||
|
|
||||||
await completeBlockContinuation(page);
|
await completeBlockContinuation(page);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue