diff --git a/tests/playwright/utils/paypal-popup.js b/tests/playwright/utils/paypal-popup.js index a39e06759..1d4ceac35 100644 --- a/tests/playwright/utils/paypal-popup.js +++ b/tests/playwright/utils/paypal-popup.js @@ -8,16 +8,24 @@ const { /** * Opens the PayPal popup by pressing the button, and returns the popup object. * @param page + * @param {{timeout: ?int, fundingSource: ?string}} options * @param {boolean} retry Retries the button click if the popup did not appear after timeout. - * @param {int} timeout */ -export const openPaypalPopup = async (page, retry = true, timeout = 5000) => { +export const openPaypalPopup = async (page, options = {}, retry = true) => { + options = { + ...{ + timeout: 5000, + fundingSource: 'paypal', + }, + ...options + }; + try { await page.locator('.component-frame').scrollIntoViewIfNeeded(); const [popup] = await Promise.all([ - page.waitForEvent('popup', {timeout}), - page.frameLocator('.component-frame').locator('[data-funding-source="paypal"]').click(), + page.waitForEvent('popup', {timeout: options.timeout}), + page.frameLocator('.component-frame').locator(`[data-funding-source="${options.fundingSource}"]`).click(), ]); await popup.waitForLoadState(); @@ -41,7 +49,7 @@ export const openPaypalPopup = async (page, retry = true, timeout = 5000) => { } if (retry) { - return openPaypalPopup(page, false); + return openPaypalPopup(page, options, false); } throw err; }