mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Refactor playwright test
This commit is contained in:
parent
b388d2320c
commit
f2ee714880
1 changed files with 16 additions and 4 deletions
|
@ -30,22 +30,34 @@ async function fillCheckoutForm(page) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test('PayPal button place order from Product page', async ({page}) => {
|
async function openPaypalPopup(page) {
|
||||||
|
|
||||||
await page.goto(PRODUCT_URL);
|
|
||||||
|
|
||||||
await page.locator('.component-frame').scrollIntoViewIfNeeded();
|
await page.locator('.component-frame').scrollIntoViewIfNeeded();
|
||||||
|
|
||||||
const [popup] = await Promise.all([
|
const [popup] = await Promise.all([
|
||||||
page.waitForEvent('popup'),
|
page.waitForEvent('popup'),
|
||||||
page.frameLocator('.component-frame').locator('[data-funding-source="paypal"]').click(),
|
page.frameLocator('.component-frame').locator('[data-funding-source="paypal"]').click(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await popup.waitForLoadState();
|
await popup.waitForLoadState();
|
||||||
|
|
||||||
|
return popup;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loginIntoPaypal(popup) {
|
||||||
await popup.click("text=Log in");
|
await popup.click("text=Log in");
|
||||||
await popup.fill('[name="login_email"]', CUSTOMER_EMAIL);
|
await popup.fill('[name="login_email"]', CUSTOMER_EMAIL);
|
||||||
await popup.locator('#btnNext').click();
|
await popup.locator('#btnNext').click();
|
||||||
await popup.fill('[name="login_password"]', CUSTOMER_PASSWORD);
|
await popup.fill('[name="login_password"]', CUSTOMER_PASSWORD);
|
||||||
await popup.locator('#btnLogin').click();
|
await popup.locator('#btnLogin').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
test('PayPal button place order from Product page', async ({page}) => {
|
||||||
|
|
||||||
|
await page.goto(PRODUCT_URL);
|
||||||
|
|
||||||
|
const popup = await openPaypalPopup(page);
|
||||||
|
|
||||||
|
await loginIntoPaypal(popup);
|
||||||
|
|
||||||
await popup.locator('#payment-submit-btn').click();
|
await popup.locator('#payment-submit-btn').click();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue