Skip to content

Commit

Permalink
linting and formatting of the e2e test files (#1129)
Browse files Browse the repository at this point in the history
* fix: linting and formatting of the e2e test files

* fix: format usd tests

* Update FR.spec.mjs
  • Loading branch information
amihajlovski authored Jul 25, 2024
1 parent ae4aad6 commit 3bdc0b8
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 124 deletions.
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/BRL.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/DKK.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/INR.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/JPY.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/NOK.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/SEK.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
210 changes: 104 additions & 106 deletions tests/playwright/fixtures/USD.spec.mjs
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -78,73 +78,73 @@ 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();
});
});

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);
Expand All @@ -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);
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
});
}
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/countriesEUR/AT.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/countriesEUR/BE.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/countriesEUR/DE.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
Loading

0 comments on commit 3bdc0b8

Please sign in to comment.