Skip to content

Commit

Permalink
feat: click to pay e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 committed Oct 24, 2024
1 parent ad19e9d commit 2b68979
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 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', async () => {
await checkoutPage.goToCheckoutPageWithFullCart(regionsEnum.EU, 1, paymentData.ClickToPay.email);
await checkoutPage.setShopperDetails(shopperData.NL);
if (environment.name.indexOf('v5') !== -1) {
await checkoutPage.setEmail(paymentData.ClickToPay.email);
};
await checkoutPage.expectClickToPay();
});
});
}

4 changes: 4 additions & 0 deletions tests/playwright/pages/CheckoutPageSFRA5.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export default class CheckoutPageSFRA5 {
await expect(this.thankYouMessage).toBeVisible();
};

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

expectNonRedirectSuccess = async () => {
await expect(this.thankYouMessage).toBeVisible();
};
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 2b68979

Please sign in to comment.