From 56ee3790e8621b56f1468f72cd14eae1c1b4ce81 Mon Sep 17 00:00:00 2001 From: Zenit Shkreli <69572953+zenit2001@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:34:10 +0200 Subject: [PATCH 1/6] feat: e2e tests for riverty --- .../cartridge/config/countries.json | 4 ++ tests/playwright/data/enums.mjs | 1 + tests/playwright/data/shopperData.mjs | 17 +++++++ .../fixtures/countriesEUR/DE.spec.mjs | 45 +++++++++++++++++++ tests/playwright/pages/CheckoutPageSFRA5.mjs | 4 +- tests/playwright/pages/CheckoutPageSFRA6.mjs | 8 ++-- .../paymentFlows/redirectShopper.mjs | 7 +++ 7 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/cartridges/app_adyen_SFRA/cartridge/config/countries.json b/src/cartridges/app_adyen_SFRA/cartridge/config/countries.json index d9ad44311..c68d6015b 100644 --- a/src/cartridges/app_adyen_SFRA/cartridge/config/countries.json +++ b/src/cartridges/app_adyen_SFRA/cartridge/config/countries.json @@ -34,4 +34,8 @@ }, { "id": "ja_JP", "currencyCode": "JPY" +}, +{ + "id": "de_DE", + "currencyCode": "EUR" }] \ No newline at end of file diff --git a/tests/playwright/data/enums.mjs b/tests/playwright/data/enums.mjs index c9d96bfcb..eabc0ae7e 100644 --- a/tests/playwright/data/enums.mjs +++ b/tests/playwright/data/enums.mjs @@ -7,4 +7,5 @@ export const regionsEnum = { SE: 'sv_SE', IN: 'hi_IN', JP: 'ja_JP', + DE: 'de_DE', }; diff --git a/tests/playwright/data/shopperData.mjs b/tests/playwright/data/shopperData.mjs index 2926594ec..ce920d64f 100644 --- a/tests/playwright/data/shopperData.mjs +++ b/tests/playwright/data/shopperData.mjs @@ -233,4 +233,21 @@ export class ShopperData { houseNumberOrName: '37', }, }; + DERiverty = { + shopperName: { + firstName: 'John', + lastName: 'Doe', + }, + telephone: '0513744112', + successShopperEmail: 'test@example.com', + refusalShopperEmail: 'rejection@riverty.com', + address: { + city: 'Verl', + country: 'DE', + stateOrProvince: '', + postalCode: '33415', + street: 'Gütersloher Str.', + houseNumberOrName: '123', + }, + }; } diff --git a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs index 7f932114f..23857881b 100644 --- a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs @@ -84,4 +84,49 @@ for (const environment of environments) { await checkoutPage.expectRefusal() || test.skip(); }); }); + + test.describe.parallel(`${environment.name} EUR DE Riverty`, () => { + test.beforeEach(async ({ page }) => { + await page.goto(`${environment.urlExtension}`); + checkoutPage = new environment.CheckoutPage(page); + }); + + async function rivertyCheckoutFlow({ page, email, shopperDetails, expectSuccess = true }) { + await checkoutPage.goToCheckoutPageWithFullCart(regionsEnum.DE, 1, email); + await checkoutPage.setShopperDetails(shopperDetails); + + if (environment.name.includes('v5')) { + await checkoutPage.setEmail(email); + } + + redirectShopper = new RedirectShopper(page); + await redirectShopper.doRivertyPayment(page); + await checkoutPage.completeCheckout(); + + if (expectSuccess) { + await checkoutPage.expectSuccess(); + } else { + await checkoutPage.expectRefusal(); + } + } + + test('Riverty Success @quick', async ({ page }) => { + await rivertyCheckoutFlow({ + page, + email: shopperData.DERiverty.successShopperEmail, + shopperDetails: shopperData.DERiverty, + expectSuccess: true, + }); + }); + + test('Riverty Failure @quick', async ({ page }) => { + await rivertyCheckoutFlow({ + page, + email: shopperData.DERiverty.refusalShopperEmail, + shopperDetails: shopperData.DERiverty, + expectSuccess: false, + }); + }); + }); + } diff --git a/tests/playwright/pages/CheckoutPageSFRA5.mjs b/tests/playwright/pages/CheckoutPageSFRA5.mjs index 629df8de3..f4a132c1a 100644 --- a/tests/playwright/pages/CheckoutPageSFRA5.mjs +++ b/tests/playwright/pages/CheckoutPageSFRA5.mjs @@ -157,9 +157,9 @@ export default class CheckoutPageSFRA5 { await this.submitShipping(); }; - setEmail = async () => { + setEmail = async (email = 'test@adyenTest.com') => { await this.checkoutPageUserEmailInput.fill(''); - await this.checkoutPageUserEmailInput.fill('test@adyenTest.com'); + 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)); diff --git a/tests/playwright/pages/CheckoutPageSFRA6.mjs b/tests/playwright/pages/CheckoutPageSFRA6.mjs index d6fbd98d4..d85b0df5f 100644 --- a/tests/playwright/pages/CheckoutPageSFRA6.mjs +++ b/tests/playwright/pages/CheckoutPageSFRA6.mjs @@ -100,12 +100,12 @@ export default class CheckoutPageSFRA { await this.page.goto(this.getCartUrl(locale)); } - goToCheckoutPageWithFullCart = async (locale, itemCount = 1) => { + goToCheckoutPageWithFullCart = async (locale, itemCount = 1, email) => { await this.addProductToCart(locale, itemCount); await this.successMessage.waitFor({ visible: true, timeout: 20000 }); await this.navigateToCheckout(locale); - await this.setEmail(); + await this.setEmail(email); await this.checkoutGuest.click(); }; @@ -165,13 +165,13 @@ export default class CheckoutPageSFRA { await this.submitShipping(); }; - setEmail = async () => { + setEmail = async (email = 'test@adyenTest.com') => { /* After filling the shopper details, clicking "Next" has an autoscroll feature, which leads the email field to be missed, hence the flakiness. Waiting until the full page load prevents this situation */ await this.page.waitForLoadState('networkidle'); await this.checkoutPageUserEmailInput.fill(''); - await this.checkoutPageUserEmailInput.fill('test@adyenTest.com'); + await this.checkoutPageUserEmailInput.fill(email); }; submitShipping = async () => { diff --git a/tests/playwright/paymentFlows/redirectShopper.mjs b/tests/playwright/paymentFlows/redirectShopper.mjs index 7b8c84caf..e0f8b93fa 100644 --- a/tests/playwright/paymentFlows/redirectShopper.mjs +++ b/tests/playwright/paymentFlows/redirectShopper.mjs @@ -93,6 +93,13 @@ export class RedirectShopper { await this.page.click('#rb_giropay'); }; + doRivertyPayment = async () => { + await this.page.click('#rb_riverty'); + await this.page.fill('input[name="dateOfBirth"]', '1980-01-11'); + // There is no static locator to click the checkbox + await this.page.locator('label:has-text("Ich stimme den")').click(); +}; + completeGiropayRedirect = async (success) => { if (success) { await this.paymentMethodsPage.confirmGiropayPayment(); From d5bdb84661abe872eb88d1ef41507eef0b1987c9 Mon Sep 17 00:00:00 2001 From: Zenit Shkreli <69572953+zenit2001@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:04:16 +0200 Subject: [PATCH 2/6] chore: linting DE.spec.mjs --- .../fixtures/countriesEUR/DE.spec.mjs | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs index 23857881b..857916e25 100644 --- a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs @@ -85,48 +85,47 @@ for (const environment of environments) { }); }); - test.describe.parallel(`${environment.name} EUR DE Riverty`, () => { - test.beforeEach(async ({ page }) => { - await page.goto(`${environment.urlExtension}`); - checkoutPage = new environment.CheckoutPage(page); - }); - - async function rivertyCheckoutFlow({ page, email, shopperDetails, expectSuccess = true }) { - await checkoutPage.goToCheckoutPageWithFullCart(regionsEnum.DE, 1, email); - await checkoutPage.setShopperDetails(shopperDetails); - - if (environment.name.includes('v5')) { - await checkoutPage.setEmail(email); - } - - redirectShopper = new RedirectShopper(page); - await redirectShopper.doRivertyPayment(page); - await checkoutPage.completeCheckout(); - - if (expectSuccess) { - await checkoutPage.expectSuccess(); - } else { - await checkoutPage.expectRefusal(); - } - } - - test('Riverty Success @quick', async ({ page }) => { - await rivertyCheckoutFlow({ - page, - email: shopperData.DERiverty.successShopperEmail, - shopperDetails: shopperData.DERiverty, - expectSuccess: true, - }); - }); - - test('Riverty Failure @quick', async ({ page }) => { - await rivertyCheckoutFlow({ - page, - email: shopperData.DERiverty.refusalShopperEmail, - shopperDetails: shopperData.DERiverty, - expectSuccess: false, - }); - }); - }); + test.describe.parallel(`${environment.name} Riverty EUR DE`, () => { + test.beforeEach(async ({ page }) => { + await page.goto(`${environment.urlExtension}`); + checkoutPage = new environment.CheckoutPage(page); + }); + async function rivertyCheckoutFlow({ page, email, shopperDetails, expectSuccess = true }) { + await checkoutPage.goToCheckoutPageWithFullCart(regionsEnum.DE, 1, email); + await checkoutPage.setShopperDetails(shopperDetails); + + // SFRA 5 email setting flow is different + if (environment.name.indexOf('v5') !== -1) { + await checkoutPage.setEmail(); + } + redirectShopper = new RedirectShopper(page); + await redirectShopper.doRivertyPayment(page); + await checkoutPage.completeCheckout(); + + if (expectSuccess) { + await checkoutPage.expectSuccess(); + } else { + await checkoutPage.expectRefusal(); + } + } + + test('Riverty Success @quick', async ({ page }) => { + await rivertyCheckoutFlow({ + page, + email: shopperData.DERiverty.successShopperEmail, + shopperDetails: shopperData.DERiverty, + expectSuccess: true, + }); + }); + + test('Riverty Success @quick', async ({ page }) => { + await rivertyCheckoutFlow({ + page, + email: shopperData.DERiverty.refusalShopperEmail, + shopperDetails: shopperData.DERiverty, + expectSuccess: false, + }); + }); + }); } From c5d95da4f85b76a7b3a9e677f25868eeae5c0a87 Mon Sep 17 00:00:00 2001 From: Zenit Shkreli <69572953+zenit2001@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:10:05 +0200 Subject: [PATCH 3/6] chore: changing test name and linting --- tests/playwright/fixtures/countriesEUR/DE.spec.mjs | 2 +- tests/playwright/paymentFlows/redirectShopper.mjs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs index 857916e25..a0e4e4433 100644 --- a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs @@ -119,7 +119,7 @@ for (const environment of environments) { }); }); - test('Riverty Success @quick', async ({ page }) => { + test('Riverty Failure @quick', async ({ page }) => { await rivertyCheckoutFlow({ page, email: shopperData.DERiverty.refusalShopperEmail, diff --git a/tests/playwright/paymentFlows/redirectShopper.mjs b/tests/playwright/paymentFlows/redirectShopper.mjs index e0f8b93fa..74e41aeaa 100644 --- a/tests/playwright/paymentFlows/redirectShopper.mjs +++ b/tests/playwright/paymentFlows/redirectShopper.mjs @@ -95,9 +95,9 @@ export class RedirectShopper { doRivertyPayment = async () => { await this.page.click('#rb_riverty'); - await this.page.fill('input[name="dateOfBirth"]', '1980-01-11'); - // There is no static locator to click the checkbox - await this.page.locator('label:has-text("Ich stimme den")').click(); + await this.page.fill('input[name="dateOfBirth"]', '1980-01-11'); + // There is no static locator to click the checkbox + await this.page.locator('label:has-text("Ich stimme den")').click(); }; completeGiropayRedirect = async (success) => { From 8adda0a55beacf7a1fcff1c3e765f1227e0c44d3 Mon Sep 17 00:00:00 2001 From: Zenit Shkreli <69572953+zenit2001@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:11:56 +0200 Subject: [PATCH 4/6] fix: fixing the tests for sfra5 --- tests/playwright/fixtures/countriesEUR/DE.spec.mjs | 6 +++--- tests/playwright/paymentFlows/redirectShopper.mjs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs index a0e4e4433..93cb0645a 100644 --- a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs @@ -97,10 +97,10 @@ for (const environment of environments) { // SFRA 5 email setting flow is different if (environment.name.indexOf('v5') !== -1) { - await checkoutPage.setEmail(); + await checkoutPage.setEmail(email); } redirectShopper = new RedirectShopper(page); - await redirectShopper.doRivertyPayment(page); + await redirectShopper.doRivertyPayment(email); await checkoutPage.completeCheckout(); if (expectSuccess) { @@ -119,7 +119,7 @@ for (const environment of environments) { }); }); - test('Riverty Failure @quick', async ({ page }) => { + test.only('Riverty Failure @quick', async ({ page }) => { await rivertyCheckoutFlow({ page, email: shopperData.DERiverty.refusalShopperEmail, diff --git a/tests/playwright/paymentFlows/redirectShopper.mjs b/tests/playwright/paymentFlows/redirectShopper.mjs index 74e41aeaa..09530b209 100644 --- a/tests/playwright/paymentFlows/redirectShopper.mjs +++ b/tests/playwright/paymentFlows/redirectShopper.mjs @@ -93,9 +93,10 @@ export class RedirectShopper { await this.page.click('#rb_giropay'); }; - doRivertyPayment = async () => { + doRivertyPayment = async (email) => { await this.page.click('#rb_riverty'); await this.page.fill('input[name="dateOfBirth"]', '1980-01-11'); + await this.page.fill('input[name="shopperEmail"]', email); // There is no static locator to click the checkbox await this.page.locator('label:has-text("Ich stimme den")').click(); }; From 4f0110304d9c4003b7a4672f450b38e968b39b47 Mon Sep 17 00:00:00 2001 From: Zenit Shkreli <69572953+zenit2001@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:19:51 +0200 Subject: [PATCH 5/6] chore: removing test.only --- tests/playwright/fixtures/countriesEUR/DE.spec.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs index 93cb0645a..915f000d7 100644 --- a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs @@ -119,7 +119,7 @@ for (const environment of environments) { }); }); - test.only('Riverty Failure @quick', async ({ page }) => { + test('Riverty Failure @quick', async ({ page }) => { await rivertyCheckoutFlow({ page, email: shopperData.DERiverty.refusalShopperEmail, From bbde62c9c3b1fa7e40d01e09977f91652020bb48 Mon Sep 17 00:00:00 2001 From: Zenit Shkreli <69572953+zenit2001@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:36:47 +0200 Subject: [PATCH 6/6] fix: fixing locator for klarna tests --- tests/playwright/pages/PaymentMethodsPage.mjs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/playwright/pages/PaymentMethodsPage.mjs b/tests/playwright/pages/PaymentMethodsPage.mjs index f006363f8..e46a18044 100644 --- a/tests/playwright/pages/PaymentMethodsPage.mjs +++ b/tests/playwright/pages/PaymentMethodsPage.mjs @@ -453,14 +453,8 @@ export default class PaymentMethodsPage { cancelKlarnaPayment = async () => { await this.waitForKlarnaLoad(); await this.page.waitForLoadState('networkidle', { timeout: 20000 }); - this.firstCancelButton = this.page.locator('#collectPhonePurchaseFlow__nav-bar__right-icon-wrapper'); - this.secondCancelButton = this.page.locator("button[title='Close']"); - await this.firstCancelButton.waitFor({ - state: 'visible', - timeout: 25000, - }); - await this.firstCancelButton.click(); - await this.secondCancelButton.first().click(); + this.cancelButton = this.page.locator("button[title='Close']"); + await this.cancelButton.click(); await this.page.click("button[id='payment-cancel-dialog-express__confirm']"); };