From cdfa3a402369662b491ab599179b4ecdfa881337 Mon Sep 17 00:00:00 2001 From: aleksandarm Date: Fri, 6 Dec 2024 13:52:52 +0100 Subject: [PATCH] feat: added e2e tests for google pay --- tests/playwright/data/paymentData.mjs | 10 +++++++--- tests/playwright/fixtures/USD.spec.mjs | 15 +++++++++++++++ tests/playwright/pages/PaymentMethodsPage.mjs | 14 ++++++++++++++ tests/playwright/paymentFlows/redirectShopper.mjs | 4 ++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/tests/playwright/data/paymentData.mjs b/tests/playwright/data/paymentData.mjs index b1ef8e358..a7f71bc6a 100644 --- a/tests/playwright/data/paymentData.mjs +++ b/tests/playwright/data/paymentData.mjs @@ -11,8 +11,12 @@ export class PaymentData { AmazonPay = { username : process.env.AMAZONPAY_USERNAME, password: process.env.AMAZONPAY_PASSWORD, - } + }; + GooglePay = { + username : process.env.GOOGLEPAY_USERNAME, + password: process.env.GOOGLEPAY_PASSWORD, + }; ClickToPay = { - email : process.env.SFCC_USERNAME, - } + email : process.env.SFCC_USERNAME, + }; } diff --git a/tests/playwright/fixtures/USD.spec.mjs b/tests/playwright/fixtures/USD.spec.mjs index 7f8c31ca7..0fdad9aa5 100644 --- a/tests/playwright/fixtures/USD.spec.mjs +++ b/tests/playwright/fixtures/USD.spec.mjs @@ -307,5 +307,20 @@ for (const environment of environments) { } await expect(page.locator('.tax-total')).toContainText('$5.98'); }); + + test('Google Pay Express @quick', async ({page}) => { + checkoutPage = new environment.CheckoutPage(page); + await checkoutPage.addProductToCart(); + await checkoutPage.navigateToCart(regionsEnum.US); + redirectShopper = new RedirectShopper(page); + await redirectShopper.doGooglePayExpressPayment(); + }); + + test('Google Pay Express PDP @quick', async ({page}) => { + checkoutPage = new environment.CheckoutPage(page); + await checkoutPage.addProductToCart(regionsEnum.US); + redirectShopper = new RedirectShopper(page); + await redirectShopper.doGooglePayExpressPayment(); + }); }); } diff --git a/tests/playwright/pages/PaymentMethodsPage.mjs b/tests/playwright/pages/PaymentMethodsPage.mjs index f8021665d..92e0706b7 100644 --- a/tests/playwright/pages/PaymentMethodsPage.mjs +++ b/tests/playwright/pages/PaymentMethodsPage.mjs @@ -32,6 +32,20 @@ export default class PaymentMethodsPage { await iDealInput.click(); }; + initiateGooglePayExpressPayment = async () => { + const googlePayButton = this.page.locator('#gpay-button-online-api-id'); + + const [popup] = await Promise.all([ + this.page.waitForEvent('popup'), + googlePayButton.click(), + ]); + + await popup.waitForLoadState(); + + const googlePayEmailInput = popup.locator('input[type="email"]'); + expect(googlePayEmailInput).toBeVisible(); + } + initiatePayPalPayment = async (expressFlow, shippingChange, success, taxation) => { // Paypal button locator on payment methods page const payPalButton = this.page diff --git a/tests/playwright/paymentFlows/redirectShopper.mjs b/tests/playwright/paymentFlows/redirectShopper.mjs index 73c42e7da..d666d2bb6 100644 --- a/tests/playwright/paymentFlows/redirectShopper.mjs +++ b/tests/playwright/paymentFlows/redirectShopper.mjs @@ -33,6 +33,10 @@ export class RedirectShopper { await this.paymentMethodsPage.initiatePayPalPayment(expressFlow, shippingChange, success, taxation); }; + doGooglePayExpressPayment = async () => { + await this.paymentMethodsPage.initiateGooglePayExpressPayment(); + }; + doAmazonPayment = async (normalFlow, selectedCard, success) => { await this.paymentMethodsPage.initiateAmazonPayment(normalFlow, selectedCard, success); }