Skip to content

Commit

Permalink
E2E maintenance (#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 authored and amihajlovski committed Aug 22, 2023
1 parent 2b93d44 commit b3c5ebd
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 80 deletions.
7 changes: 0 additions & 7 deletions tests/playwright/data/paymentData.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
export class PaymentData {
GiroPay = {
bankName: 'GENODETT488',
sc: '10',
extensionSc: '4000',
customerIban: 'DE36444488881234567890',
customerName: 'Klaus Giro',
};
SepaDirectDebit = {
accountName: 'A. Klaassen',
iban: 'NL13TEST0123456789',
Expand Down
23 changes: 12 additions & 11 deletions tests/playwright/fixtures/countriesEUR/DE.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { regionsEnum } from '../../data/enums.mjs';
import { environments } from '../../data/environments.mjs';
import { RedirectShopper } from '../../paymentFlows/redirectShopper.mjs';
import { ShopperData } from '../../data/shopperData.mjs';
import { PaymentData } from '../../data/paymentData.mjs';
import PaymentMethodsPage from '../../pages/PaymentMethodsPage.mjs';

const paymentData = new PaymentData();
const shopperData = new ShopperData();

let checkoutPage;
Expand All @@ -29,8 +28,7 @@ for (const environment of environments) {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doKlarnaPayment();
await checkoutPage.completeCheckout();
await redirectShopper.completeKlarnaRedirect(true);
await checkoutPage.expectSuccess();
await new PaymentMethodsPage(page).waitForKlarnaLoad();
});

test('Klarna Fail @quick', async ({ page }) => {
Expand All @@ -44,8 +42,7 @@ for (const environment of environments) {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doKlarnaPayNowPayment();
await checkoutPage.completeCheckout();
await redirectShopper.completeKlarnaPayNowRedirect(true);
await checkoutPage.expectSuccess();
await new PaymentMethodsPage(page).waitForKlarnaLoad();
});

test('Klarna Pay now Fail', async ({ page }) => {
Expand All @@ -59,8 +56,7 @@ for (const environment of environments) {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doKlarnaAccountPayment();
await checkoutPage.completeCheckout();
await redirectShopper.completeKlarnaAccountRedirect(true);
await checkoutPage.expectSuccess();
await new PaymentMethodsPage(page).waitForKlarnaLoad();
});

test('Klarna Account Fail', async ({ page }) => {
Expand All @@ -75,15 +71,20 @@ for (const environment of environments) {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doGiropayPayment();
await checkoutPage.completeCheckout();
await redirectShopper.completeGiropayRedirect(paymentData.GiroPay, true);
await checkoutPage.expectNonRedirectSuccess();
await redirectShopper.completeGiropayRedirect(true);
const popupPromise = page.waitForEvent('popup');
const popup = await popupPromise;
await popup.waitForNavigation({
url: /Order-Confirm/,
timeout: 15000,
});
});

test('Giropay Fail', async ({ page }) => {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doGiropayPayment(page);
await checkoutPage.completeCheckout();
await redirectShopper.completeGiropayRedirect(paymentData.GiroPay, false);
await redirectShopper.completeGiropayRedirect(false);
await checkoutPage.expectRefusal();
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/playwright/pages/CheckoutPageSFRA6.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ export default class CheckoutPageSFRA {
};

submitPayment = async () => {
await this.page.waitForLoadState('networkidle', { timeout: 15000 });
await this.page.waitForLoadState('load', { timeout: 15000 });
await this.submitPaymentButton.click();
};
placeOrder = async () => {
await this.page.waitForLoadState('networkidle', { timeout: 15000 });
await this.page.waitForLoadState('load', { timeout: 15000 });
await this.placeOrderButton.click();
};

Expand Down
108 changes: 52 additions & 56 deletions tests/playwright/pages/PaymentMethodsPage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -337,49 +337,37 @@ export default class PaymentMethodsPage {
});
};

async continueOnKlarna() {
async continueOnKlarna(skipModal) {
await this.waitForKlarnaLoad();
await this.page.waitForLoadState('networkidle', { timeout: 15000 });
this.klarnaIframe = this.page.frameLocator(
'#klarna-hpp-instance-fullscreen',
'#klarna-apf-iframe',
);

this.klarnaBuyButton = this.page.locator('#buy-button');
this.klarnaContinueButton = this.klarnaIframe.locator('#onContinue');
this.klarnaVerificationCodeInput = this.klarnaIframe.locator('#otp_field');
this.klarnaSelectPlanButton = this.klarnaIframe.locator("button[data-testid='pick-plan']");
this.klarnaBuyButton = this.klarnaIframe.locator("button[data-testid='confirm-and-pay']");
this.klarnaDirectDebitPlan = this.klarnaIframe.locator("div[id='directdebit.0-ui']"); // used for Klarna Pay Now

await this.klarnaBuyButton.waitFor({
state: 'visible',
timeout: 15000,
});
await this.klarnaBuyButton.click();

/* Commenting out this section since the phone number comes
prefilled nowadays
await this.klarnaPhoneInput.waitFor({
state: "visible",
timeout: 15000,
});
await this.klarnaPhoneInput.fill(); */

await this.klarnaContinueButton.waitFor({
state: 'visible',
timeout: 15000,
});
await this.klarnaContinueButton.click();
await this.klarnaVerificationCodeInput.waitFor({
state: 'visible',
timeout: 15000,
});
await this.klarnaVerificationCodeInput.fill('123456');
if (this.klarnaSelectPlanButton.isVisible() && !skipModal) {
await this.klarnaDirectDebitPlan.click();
await this.klarnaSelectPlanButton.click();
}
await this.klarnaBuyButton.waitFor({
state: 'visible',
timeout: 15000,
});
await this.klarnaBuyButton.click();
}

confirmKlarnaPayNowPayment = async () => {
await this.continueOnKlarna();
await this.page
.frameLocator('#klarna-hpp-instance-fullscreen')
.locator('#dd-confirmation-dialog__bottom button')
.click();
};

confirmKlarnaAccountPayment = async () => {
Expand All @@ -395,12 +383,8 @@ export default class PaymentMethodsPage {
.click();
};

confirmKlarnaPayment = async () => {
await this.continueOnKlarna();
await this.page
.frameLocator('#klarna-hpp-instance-fullscreen')
.locator('#invoice_kp-purchase-review-continue-button')
.click();
confirmKlarnaPayment = async (skipModal) => {
await this.continueOnKlarna(skipModal);
};

cancelKlarnaDirectEBankingPayment = async () => {
Expand Down Expand Up @@ -439,39 +423,51 @@ export default class PaymentMethodsPage {

cancelKlarnaPayment = async () => {
await this.waitForKlarnaLoad();
await this.page.click('#back-button');
await this.page.waitForLoadState('networkidle', { timeout: 15000 });
this.klarnaIframe = this.page.frameLocator(
'#klarna-apf-iframe',
);
this.firstCancelButton = this.klarnaIframe.locator('#newCollectPhone__navbar__right-icon__icon-wrapper');
this.secondCancelButton = this.klarnaIframe.locator("button[title='Close']");
await this.firstCancelButton.waitFor({
state: 'visible',
timeout: 15000,
});
await this.firstCancelButton.click();
await this.secondCancelButton.first().click();
await this.page.click("button[id='payment-cancel-dialog-express__confirm']");
};

confirmGiropayPayment = async (giroPayData) => {
confirmGiropayPayment = async () => {
await this.page.waitForLoadState('networkidle', { timeout: 15000 });

const giroBank = this.page.locator('#ui-id-1 li a');
const giroBankDropdown = this.page.locator('#tags');
const rejectCookies = this.page.locator('.rds-cookies-overlay__allow-essential-cookies-btn');
const giroBankDropdown = this.page.locator('#bankSearch');
const giroBankUl = this.page.getByTestId('bank-group-list').getByRole('button').first();
const confirmChoice = this.page.getByTestId('bank-result-list').getByRole('button').first();
const payNow = this.page.locator("button[name='claimCheckoutButton']");
const confirmPayment = this.page.locator("button[id='submitButton']");

await rejectCookies.click();
await giroBankDropdown.waitFor({ state: 'visible', timeout: 15000 });
await giroBankDropdown.type(giroPayData.bankName, { delay: 50 });
await this.page.waitForLoadState('networkidle', { timeout: 15000 });

await giroBank.waitFor({ state: 'visible', timeout: 15000 });
await giroBank.click();
await this.page.click('input[name="continueBtn"]');
await this.page.click('#yes');
await this.page.locator('input[name="sc"]').type(giroPayData.sc);
await this.page
.locator('input[name="extensionSc"]')
.type(giroPayData.extensionSc);
await this.page
.locator('input[name="customerName1"]')
.type(giroPayData.customerName);
await this.page
.locator('input[name="customerIBAN"]')
.type(giroPayData.customerIban);
await this.page.click('input[value="Absenden"]');
await giroBankUl.click();
await confirmChoice.click();
await payNow.first().click();
await confirmPayment.waitFor({
state: 'visible',
timeout: 15000,
});
await confirmPayment.click();
};

cancelGiropayPayment = async () => {
await this.page.click('#backUrl');
await this.page.click('.modal-dialog #yes');
const rejectCookies = this.page.locator('.rds-cookies-overlay__allow-essential-cookies-btn');
const giroBankDropdown = this.page.locator('#bankSearch');
const backButton = this.page.locator("button[name='backLink']");

await rejectCookies.click();
await giroBankDropdown.waitFor({ state: 'visible', timeout: 15000 });
await backButton.click();
};

initiateEPSPayment = async () => {
Expand Down
8 changes: 4 additions & 4 deletions tests/playwright/paymentFlows/redirectShopper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export class RedirectShopper {
await this.paymentMethodsPage.initiateKlarnaPayment(undefined);
};

completeKlarnaRedirect = async (success) => {
completeKlarnaRedirect = async (success, skipModal) => {
if (success) {
await this.paymentMethodsPage.confirmKlarnaPayment();
await this.paymentMethodsPage.confirmKlarnaPayment(skipModal);
} else {
await this.paymentMethodsPage.cancelKlarnaPayment();
}
Expand Down Expand Up @@ -93,9 +93,9 @@ export class RedirectShopper {
await this.page.click('#rb_giropay');
};

completeGiropayRedirect = async (paymentData, success) => {
completeGiropayRedirect = async (success) => {
if (success) {
await this.paymentMethodsPage.confirmGiropayPayment(paymentData);
await this.paymentMethodsPage.confirmGiropayPayment();
} else {
await this.paymentMethodsPage.cancelGiropayPayment();
}
Expand Down

0 comments on commit b3c5ebd

Please sign in to comment.