Skip to content

Commit

Permalink
feat: added e2e tests for google pay
Browse files Browse the repository at this point in the history
  • Loading branch information
amihajlovski committed Dec 6, 2024
1 parent 8b772ac commit cdfa3a4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/playwright/data/paymentData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
15 changes: 15 additions & 0 deletions tests/playwright/fixtures/USD.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
}
14 changes: 14 additions & 0 deletions tests/playwright/pages/PaymentMethodsPage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/playwright/paymentFlows/redirectShopper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit cdfa3a4

Please sign in to comment.