Skip to content

Commit

Permalink
Click to pay e2e (#1199)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 authored Oct 31, 2024
1 parent 73bc61b commit 02cb3ab
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
3 changes: 3 additions & 0 deletions tests/playwright/data/paymentData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ export class PaymentData {
username : process.env.AMAZONPAY_USERNAME,
password: process.env.AMAZONPAY_PASSWORD,
}
ClickToPay = {
email : process.env.SFCC_USERNAME,
}
}
18 changes: 18 additions & 0 deletions tests/playwright/fixtures/countriesEUR/NL.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { environments } from '../../data/environments.mjs';
import { ShopperData } from '../../data/shopperData.mjs';
import { RedirectShopper } from '../../paymentFlows/redirectShopper.mjs';
import { PendingPayments } from '../../paymentFlows/pending.mjs';
import { PaymentData } from '../../data/paymentData.mjs';

let checkoutPage;
let redirectShopper;
let pendingPayments;
const paymentData = new PaymentData();
const shopperData = new ShopperData();

for (const environment of environments) {
Expand Down Expand Up @@ -101,4 +103,20 @@ for (const environment of environments) {
await pendingPayments.doGooglePayPayment();
});
});

test.describe.parallel(`${environment.name} EUR NL`, () => {
test.beforeEach(async ({ page }) => {
await page.goto(`${environment.urlExtension}`);
checkoutPage = new environment.CheckoutPage(page);
});
test('Click to Pay renders @quick', async () => {
await checkoutPage.goToCheckoutPageWithFullCart(regionsEnum.EU, 1, paymentData.ClickToPay.email);
await checkoutPage.setShopperDetails(shopperData.NL);
if (environment.name.indexOf('v5') !== -1) {
test.skip();
};
await checkoutPage.expectClickToPay();
});
});
}

2 changes: 1 addition & 1 deletion tests/playwright/pages/CheckoutPageSFRA5.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default class CheckoutPageSFRA5 {
await this.checkoutPageUserEmailInput.fill(email);
// Pressing Tab to simulate component re-rendering and waiting the components to re-mount
await this.page.keyboard.press('Tab');
await new Promise(r => setTimeout(r, 2000));
await new Promise(r => setTimeout(r, 2000));
};

submitShipping = async () => {
Expand Down
18 changes: 12 additions & 6 deletions tests/playwright/pages/CheckoutPageSFRA6.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default class CheckoutPageSFRA {
this.errorMessage = page.locator('.error-message-text');
this.giftCardWarning = page.locator('#giftCardWarningMessage')
this.thankYouMessage = page.locator('.order-thank-you-msg');
this.clickToPayLocator = page.locator('.adyen-checkout-ctp__section');

this.voucherCode = page.locator('#voucherResult');

Expand Down Expand Up @@ -184,12 +185,12 @@ export default class CheckoutPageSFRA {
};

submitPayment = async () => {
await this.page.waitForFunction(() => {
const button = document.querySelector('.submit-payment');
return button && !button.disabled;
});
await this.submitPaymentButton.click();
await this.page.waitForFunction(() => {
const button = document.querySelector('.submit-payment');
return button && !button.disabled;
});
await this.submitPaymentButton.click();
};

placeOrder = async () => {
Expand Down Expand Up @@ -242,6 +243,10 @@ export default class CheckoutPageSFRA {
await expect(this.giftCardWarning).not.toBeEmpty();
};

expectClickToPay = async () => {
await expect(this.clickToPayLocator).toBeVisible();
}

getLocation = async () => {
await this.page.waitForLoadState('load');
return await this.page.url();
Expand All @@ -267,3 +272,4 @@ export default class CheckoutPageSFRA {
);
};
}

0 comments on commit 02cb3ab

Please sign in to comment.