From 3bdc0b8ec114a4f6d9eb048e761046d74e02687f Mon Sep 17 00:00:00 2001 From: Aleksandar Mihajlovski Date: Thu, 25 Jul 2024 15:15:12 +0200 Subject: [PATCH] linting and formatting of the e2e test files (#1129) * fix: linting and formatting of the e2e test files * fix: format usd tests * Update FR.spec.mjs --- tests/playwright/fixtures/BRL.spec.mjs | 2 +- tests/playwright/fixtures/DKK.spec.mjs | 2 +- tests/playwright/fixtures/INR.spec.mjs | 2 +- tests/playwright/fixtures/JPY.spec.mjs | 2 +- tests/playwright/fixtures/NOK.spec.mjs | 2 +- tests/playwright/fixtures/SEK.spec.mjs | 2 +- tests/playwright/fixtures/USD.spec.mjs | 210 +++++++++--------- .../fixtures/countriesEUR/AT.spec.mjs | 2 +- .../fixtures/countriesEUR/BE.spec.mjs | 2 +- .../fixtures/countriesEUR/DE.spec.mjs | 2 +- .../fixtures/countriesEUR/FR.spec.mjs | 20 +- .../fixtures/countriesEUR/NL.spec.mjs | 4 +- .../fixtures/countriesEUR/PT.spec.mjs | 2 +- 13 files changed, 130 insertions(+), 124 deletions(-) diff --git a/tests/playwright/fixtures/BRL.spec.mjs b/tests/playwright/fixtures/BRL.spec.mjs index 813d0efbd..5d90b9717 100644 --- a/tests/playwright/fixtures/BRL.spec.mjs +++ b/tests/playwright/fixtures/BRL.spec.mjs @@ -26,7 +26,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.BR); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('Card payment 3DS2 installments success @quick', async () => { diff --git a/tests/playwright/fixtures/DKK.spec.mjs b/tests/playwright/fixtures/DKK.spec.mjs index e24b70422..984da3441 100644 --- a/tests/playwright/fixtures/DKK.spec.mjs +++ b/tests/playwright/fixtures/DKK.spec.mjs @@ -19,7 +19,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.DK); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('MobilePay', async ({ page }) => { diff --git a/tests/playwright/fixtures/INR.spec.mjs b/tests/playwright/fixtures/INR.spec.mjs index b8cdb4371..c93be8e8d 100644 --- a/tests/playwright/fixtures/INR.spec.mjs +++ b/tests/playwright/fixtures/INR.spec.mjs @@ -19,7 +19,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.IN); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('UPI Success', async ({ page }) => { diff --git a/tests/playwright/fixtures/JPY.spec.mjs b/tests/playwright/fixtures/JPY.spec.mjs index abd8dad8e..5bf7350ef 100644 --- a/tests/playwright/fixtures/JPY.spec.mjs +++ b/tests/playwright/fixtures/JPY.spec.mjs @@ -18,7 +18,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.JP); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('konbini Success', async ({ page }) => { diff --git a/tests/playwright/fixtures/NOK.spec.mjs b/tests/playwright/fixtures/NOK.spec.mjs index 65f9c7c7a..4efa26a5b 100644 --- a/tests/playwright/fixtures/NOK.spec.mjs +++ b/tests/playwright/fixtures/NOK.spec.mjs @@ -19,7 +19,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.NO); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('Vipps Success', async ({ page }) => { diff --git a/tests/playwright/fixtures/SEK.spec.mjs b/tests/playwright/fixtures/SEK.spec.mjs index 60a48c0c0..7e8cf4be6 100644 --- a/tests/playwright/fixtures/SEK.spec.mjs +++ b/tests/playwright/fixtures/SEK.spec.mjs @@ -22,7 +22,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.SE); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('Swish success', async ({ page }) => { pendingPaymentsPage = new PendingPayments(page); diff --git a/tests/playwright/fixtures/USD.spec.mjs b/tests/playwright/fixtures/USD.spec.mjs index 41e3a262b..3a51a9de0 100644 --- a/tests/playwright/fixtures/USD.spec.mjs +++ b/tests/playwright/fixtures/USD.spec.mjs @@ -1,10 +1,10 @@ -import { test } from '@playwright/test'; -import { regionsEnum } from '../data/enums.mjs'; -import { environments } from '../data/environments.mjs'; -import { RedirectShopper } from '../paymentFlows/redirectShopper.mjs'; -import { Cards } from '../paymentFlows/cards.mjs'; -import { ShopperData } from '../data/shopperData.mjs'; -import { CardData } from '../data/cardData.mjs'; +import {test} from '@playwright/test'; +import {regionsEnum} from '../data/enums.mjs'; +import {environments} from '../data/environments.mjs'; +import {RedirectShopper} from '../paymentFlows/redirectShopper.mjs'; +import {Cards} from '../paymentFlows/cards.mjs'; +import {ShopperData} from '../data/shopperData.mjs'; +import {CardData} from '../data/cardData.mjs'; import PaymentMethodsPage from '../pages/PaymentMethodsPage.mjs'; const shopperData = new ShopperData(); @@ -29,7 +29,7 @@ const goToBillingWithFullCartLoggedInUser = async () => { for (const environment of environments) { test.describe.parallel(`${environment.name} USD`, () => { - test.beforeEach(async ({ page }) => { + test.beforeEach(async ({page}) => { checkoutPage = new environment.CheckoutPage(page); accountPage = new environment.AccountPage(page); cards = new Cards(page); @@ -78,7 +78,7 @@ for (const environment of environments) { await checkoutPage.expectRefusal(); }); - test('PayPal Success @quick', async ({ page }) => { + test('PayPal Success @quick', async ({page}) => { redirectShopper = new RedirectShopper(page); await redirectShopper.doPayPalPayment(false, false, true); await checkoutPage.expectSuccess(); @@ -86,65 +86,65 @@ for (const environment of environments) { }); test.describe.parallel(`${environment.name} USD`, () => { - test.beforeEach(async ({ page }) => { - checkoutPage = new environment.CheckoutPage(page); - accountPage = new environment.AccountPage(page); - cards = new Cards(page); - await page.goto(`${environment.urlExtension}`); - }); - - test('GiftCard Only Success @quick', async () => { - await goToBillingWithFullCartGuestUser(); - if (environment.name.indexOf('v5') !== -1) { - await checkoutPage.setEmail(); - }; - await cards.doGiftCardPayment(cardData.giftCard); - await checkoutPage.placeOrder(); - await checkoutPage.expectSuccess(); - }); - - test('GiftCard & Card Success @quick', async () => { - await goToBillingWithFullCartGuestUser(3); - if (environment.name.indexOf('v5') !== -1) { - await checkoutPage.setEmail(); - }; - await cards.doGiftCardPayment(cardData.giftCard); - await cards.doCardPayment(cardData.noThreeDs); - await checkoutPage.completeCheckout(); - await checkoutPage.expectSuccess(); - }); - - test('Remove Gift Card', async ({ page }) => { - await goToBillingWithFullCartGuestUser(3); - if (environment.name.indexOf('v5') !== -1) { - await checkoutPage.setEmail(); - } - await cards.doGiftCardPayment(cardData.giftCard); - await page.locator('#giftCardCancelButton').click(); - // Wait for components to re-render after cancelling the giftcard - await new Promise(r => setTimeout(r, 2000)); - - await cards.doCardPayment(cardData.noThreeDs); - await checkoutPage.completeCheckout(); - await checkoutPage.expectSuccess(); - }); - - test('Gift Card Fail', async ({ page, locale }) => { - await goToBillingWithFullCartGuestUser(3); - await cards.doGiftCardPayment(cardData.giftCard); - await page.goto(`/s/RefArch/25720033M.html?lang=${locale}`); - await page.locator('.add-to-cart').click(); - await checkoutPage.navigateToCheckout(regionsEnum.US); - if (environment.name.indexOf('v5') !== -1) { - await checkoutPage.checkoutGuest.click(); - } - await checkoutPage.submitShipping(); - await checkoutPage.expectGiftCardWarning(); - }); + test.beforeEach(async ({page}) => { + checkoutPage = new environment.CheckoutPage(page); + accountPage = new environment.AccountPage(page); + cards = new Cards(page); + await page.goto(`${environment.urlExtension}`); + }); + + test('GiftCard Only Success @quick', async () => { + await goToBillingWithFullCartGuestUser(); + if (environment.name.indexOf('v5') !== -1) { + await checkoutPage.setEmail(); + } + await cards.doGiftCardPayment(cardData.giftCard); + await checkoutPage.placeOrder(); + await checkoutPage.expectSuccess(); + }); + + test('GiftCard & Card Success @quick', async () => { + await goToBillingWithFullCartGuestUser(3); + if (environment.name.indexOf('v5') !== -1) { + await checkoutPage.setEmail(); + } + await cards.doGiftCardPayment(cardData.giftCard); + await cards.doCardPayment(cardData.noThreeDs); + await checkoutPage.completeCheckout(); + await checkoutPage.expectSuccess(); + }); + + test('Remove Gift Card', async ({page}) => { + await goToBillingWithFullCartGuestUser(3); + if (environment.name.indexOf('v5') !== -1) { + await checkoutPage.setEmail(); + } + await cards.doGiftCardPayment(cardData.giftCard); + await page.locator('#giftCardCancelButton').click(); + // Wait for components to re-render after cancelling the giftcard + await new Promise(r => setTimeout(r, 2000)); + + await cards.doCardPayment(cardData.noThreeDs); + await checkoutPage.completeCheckout(); + await checkoutPage.expectSuccess(); + }); + + test('Gift Card Fail', async ({page, locale}) => { + await goToBillingWithFullCartGuestUser(3); + await cards.doGiftCardPayment(cardData.giftCard); + await page.goto(`/s/RefArch/25720033M.html?lang=${locale}`); + await page.locator('.add-to-cart').click(); + await checkoutPage.navigateToCheckout(regionsEnum.US); + if (environment.name.indexOf('v5') !== -1) { + await checkoutPage.checkoutGuest.click(); + } + await checkoutPage.submitShipping(); + await checkoutPage.expectGiftCardWarning(); + }); }); test.describe.parallel(`${environment.name} USD`, () => { - test.beforeEach(async ({ page }) => { + test.beforeEach(async ({page}) => { checkoutPage = new environment.CheckoutPage(page); accountPage = new environment.AccountPage(page); cards = new Cards(page); @@ -153,27 +153,27 @@ for (const environment of environments) { await goToBillingWithFullCartGuestUser(5); }); - test('Affirm Fail', async ({ page }) => { + test('Affirm Fail', async ({page}) => { redirectShopper = new RedirectShopper(page); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } await redirectShopper.doAffirmPayment(shopperData.US); await checkoutPage.completeCheckout(); await redirectShopper.completeAffirmRedirect(false); await checkoutPage.expectRefusal(); }); - test.skip('CashApp Renders', async ({ page }) => { + test.skip('CashApp Renders', async ({page}) => { if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } await new PaymentMethodsPage(page).initiateCashAppPayment(); }); }); test.describe(`${environment.name} USD Card logged in user `, () => { - test.beforeEach(async ({ page }) => { + test.beforeEach(async ({page}) => { await page.goto(`${environment.urlExtension}`); checkoutPage = new environment.CheckoutPage(page); @@ -182,7 +182,7 @@ for (const environment of environments) { await goToBillingWithFullCartLoggedInUser(); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('3DS2 oneClick test success @quick', async () => { @@ -210,7 +210,7 @@ for (const environment of environments) { }); test.describe(`${environment.name} USD`, () => { - test.beforeEach(async ({ page }) => { + test.beforeEach(async ({page}) => { await page.goto(`${environment.urlExtension}`); checkoutPage = new environment.CheckoutPage(page); @@ -253,46 +253,44 @@ for (const environment of environments) { }); test.describe.parallel(`${environment.name} USD`, () => { - test.beforeEach(async ({ page }) => { - await page.goto(`${environment.urlExtension}`); + test.beforeEach(async ({page}) => { + await page.goto(`${environment.urlExtension}`); }); - test('PayPal Express @quick', async ({ page }) => { - checkoutPage = new environment.CheckoutPage(page); - await checkoutPage.addProductToCart(); - await checkoutPage.navigateToCart(regionsEnum.US); - redirectShopper = new RedirectShopper(page); - await redirectShopper.doPayPalPayment(true, false, true); - if (environment.name.indexOf('v5') !== -1) { - await page.locator("button[value='place-order']").click(); - await page.locator(".order-thank-you-msg").isVisible({ timeout: 20000 }); - } - else { - await checkoutPage.expectSuccess(); - } + test('PayPal Express @quick', async ({page}) => { + checkoutPage = new environment.CheckoutPage(page); + await checkoutPage.addProductToCart(); + await checkoutPage.navigateToCart(regionsEnum.US); + redirectShopper = new RedirectShopper(page); + await redirectShopper.doPayPalPayment(true, false, true); + if (environment.name.indexOf('v5') !== -1) { + await page.locator("button[value='place-order']").click(); + await page.locator(".order-thank-you-msg").isVisible({timeout: 20000}); + } else { + await checkoutPage.expectSuccess(); + } }); - test('PayPal Express shipping change @quick', async ({ page }) => { - checkoutPage = new environment.CheckoutPage(page); - await checkoutPage.addProductToCart(); - await checkoutPage.navigateToCart(regionsEnum.US); - redirectShopper = new RedirectShopper(page); - await redirectShopper.doPayPalPayment(true, true, true); - if (environment.name.indexOf('v5') !== -1) { - await page.locator("button[value='place-order']").click(); - await page.locator(".order-thank-you-msg").isVisible({ timeout: 20000 }); - } - else { - await checkoutPage.expectSuccess(); - } + test('PayPal Express shipping change @quick', async ({page}) => { + checkoutPage = new environment.CheckoutPage(page); + await checkoutPage.addProductToCart(); + await checkoutPage.navigateToCart(regionsEnum.US); + redirectShopper = new RedirectShopper(page); + await redirectShopper.doPayPalPayment(true, true, true); + if (environment.name.indexOf('v5') !== -1) { + await page.locator("button[value='place-order']").click(); + await page.locator(".order-thank-you-msg").isVisible({timeout: 20000}); + } else { + await checkoutPage.expectSuccess(); + } }); - test('PayPal Express Cancellation @quick', async ({ page }) => { - checkoutPage = new environment.CheckoutPage(page); - await checkoutPage.addProductToCart(); - await checkoutPage.navigateToCart(regionsEnum.US); - redirectShopper = new RedirectShopper(page); - await redirectShopper.doPayPalPayment(true, false, false); + test('PayPal Express Cancellation @quick', async ({page}) => { + checkoutPage = new environment.CheckoutPage(page); + await checkoutPage.addProductToCart(); + await checkoutPage.navigateToCart(regionsEnum.US); + redirectShopper = new RedirectShopper(page); + await redirectShopper.doPayPalPayment(true, false, false); }); }); } diff --git a/tests/playwright/fixtures/countriesEUR/AT.spec.mjs b/tests/playwright/fixtures/countriesEUR/AT.spec.mjs index 2527fc5ac..d46c694eb 100644 --- a/tests/playwright/fixtures/countriesEUR/AT.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/AT.spec.mjs @@ -19,7 +19,7 @@ for (const environment of environments) { // SFRA 5 email setting flow is different if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('EPS Success', async ({ page }) => { redirectShopper = new RedirectShopper(page); diff --git a/tests/playwright/fixtures/countriesEUR/BE.spec.mjs b/tests/playwright/fixtures/countriesEUR/BE.spec.mjs index f6ab2ce97..33e506df0 100644 --- a/tests/playwright/fixtures/countriesEUR/BE.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/BE.spec.mjs @@ -24,7 +24,7 @@ for (const environment of environments) { // SFRA 5 email setting flow is different if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('bcmc mobile renders @quick', async ({ page }) => { pendingPayments = new PendingPayments(page); diff --git a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs index 1100ce836..7f932114f 100644 --- a/tests/playwright/fixtures/countriesEUR/DE.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/DE.spec.mjs @@ -21,7 +21,7 @@ for (const environment of environments) { // SFRA 5 email setting flow is different if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('Klarna Success @quick', async ({ page }) => { diff --git a/tests/playwright/fixtures/countriesEUR/FR.spec.mjs b/tests/playwright/fixtures/countriesEUR/FR.spec.mjs index ee2be5245..976c932ea 100644 --- a/tests/playwright/fixtures/countriesEUR/FR.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/FR.spec.mjs @@ -37,7 +37,7 @@ for (const environment of environments) { // SFRA 5 email setting flow is different if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } redirectShopper = new RedirectShopper(page); await redirectShopper.doOneyPayment(shopperData.FR); await checkoutPage.completeCheckout(); @@ -60,7 +60,9 @@ test.describe.parallel(`${environment.name} EUR FR`, () => { } redirectShopper = new RedirectShopper(page); const result = await redirectShopper.doAmazonPayment(); - if(result != true){test.skip()}; + if (!result) { + test.skip(); + } await checkoutPage.expectSuccess(); }); @@ -72,7 +74,9 @@ test.describe.parallel(`${environment.name} EUR FR`, () => { } redirectShopper = new RedirectShopper(page); const result = await redirectShopper.doAmazonPayment(true, true, '3ds2_card'); - if(result != true){test.skip()}; + if (!result) { + test.skip(); + } await cards.do3Ds2Verification(); await checkoutPage.expectSuccess(); }); @@ -83,7 +87,9 @@ test.describe.parallel(`${environment.name} EUR FR`, () => { await checkoutPage.navigateToCart(regionsEnum.EU); await redirectShopper.doAmazonPayment(false); const result = await redirectShopper.doAmazonExpressPayment(); - if(result != true){test.skip()}; + if (!result) { + test.skip(); + } await checkoutPage.expectSuccess(); }); @@ -95,9 +101,11 @@ test.describe.parallel(`${environment.name} EUR FR`, () => { } redirectShopper = new RedirectShopper(page); const result = await redirectShopper.doAmazonPayment(true, false); - if(result != true){test.skip()}; + if (!result) { + test.skip(); + } await checkoutPage.expectRefusal(); }); }); -} \ No newline at end of file +} diff --git a/tests/playwright/fixtures/countriesEUR/NL.spec.mjs b/tests/playwright/fixtures/countriesEUR/NL.spec.mjs index 13f07f79d..bb22aef1a 100644 --- a/tests/playwright/fixtures/countriesEUR/NL.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/NL.spec.mjs @@ -20,7 +20,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.NL); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('iDeal Success @quick', async ({ page }) => { @@ -61,7 +61,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.NL); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('iDeal with restored cart Fail', async ({ page, context }) => { redirectShopper = new RedirectShopper(page); diff --git a/tests/playwright/fixtures/countriesEUR/PT.spec.mjs b/tests/playwright/fixtures/countriesEUR/PT.spec.mjs index f0711cb7e..0137610e9 100644 --- a/tests/playwright/fixtures/countriesEUR/PT.spec.mjs +++ b/tests/playwright/fixtures/countriesEUR/PT.spec.mjs @@ -20,7 +20,7 @@ for (const environment of environments) { await checkoutPage.setShopperDetails(shopperData.PT); if (environment.name.indexOf('v5') !== -1) { await checkoutPage.setEmail(); - }; + } }); test('MultiBanco Success', async ({ page }) => {