Skip to content

Commit

Permalink
E2E Maintenance (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 authored Oct 10, 2024
1 parent 3b8c818 commit 8017d91
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 102 deletions.
12 changes: 6 additions & 6 deletions tests/playwright/fixtures/USD.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ for (const environment of environments) {
await checkoutPage.expectRefusal();
});

test.skip('PayPal Success @quick', async ({page}) => {
test('PayPal Success @quick', async ({page}) => {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doPayPalPayment(false, false, true);
await checkoutPage.expectSuccess();
Expand All @@ -93,7 +93,7 @@ for (const environment of environments) {
await page.goto(`${environment.urlExtension}`);
});

test.skip('GiftCard Only Success @quick', async () => {
test('GiftCard Only Success @quick', async () => {
await goToBillingWithFullCartGuestUser();
if (environment.name.indexOf('v5') !== -1) {
await checkoutPage.setEmail();
Expand All @@ -103,7 +103,7 @@ for (const environment of environments) {
await checkoutPage.expectSuccess();
});

test.skip('GiftCard & Card Success @quick', async () => {
test('GiftCard & Card Success @quick', async () => {
await goToBillingWithFullCartGuestUser(3);
if (environment.name.indexOf('v5') !== -1) {
await checkoutPage.setEmail();
Expand Down Expand Up @@ -164,7 +164,7 @@ for (const environment of environments) {
await checkoutPage.expectRefusal();
});

test.skip('CashApp Renders', async ({page}) => {
test('CashApp Renders', async ({page}) => {
if (environment.name.indexOf('v5') !== -1) {
await checkoutPage.setEmail();
}
Expand Down Expand Up @@ -265,7 +265,7 @@ for (const environment of environments) {
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});
await page.locator(".order-thank-you-msg").isVisible();
} else {
await checkoutPage.expectSuccess();
}
Expand All @@ -279,7 +279,7 @@ for (const environment of environments) {
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});
await page.locator(".order-thank-you-msg").isVisible();
} else {
await checkoutPage.expectSuccess();
}
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 @@ -24,7 +24,7 @@ for (const environment of environments) {
}
});

test.skip('Klarna Success @quick', async ({ page }) => {
test('Klarna Success @quick', async ({ page }) => {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doKlarnaPayment();
await checkoutPage.completeCheckout();
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/countriesEUR/FR.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test.describe.parallel(`${environment.name} EUR FR`, () => {
cards = new Cards(page);
});

test.skip('No 3DS Amazon Pay @quick', async ({ page }) => {
test('No 3DS Amazon Pay @quick', async ({ page }) => {
await checkoutPage.goToCheckoutPageWithFullCart(regionsEnum.EU);
await checkoutPage.setShopperDetails(shopperData.FR);
if (environment.name.indexOf('v5') !== -1) {
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"yazl": "^2.5.1"
},
"devDependencies": {
"@playwright/test": "^1.38.0"
"@playwright/test": "^1.42.1"
},
"scripts": {
"test": "npx playwright test",
Expand Down
6 changes: 2 additions & 4 deletions tests/playwright/pages/AccountPageSFRA.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class AccountPageSFRA {
.locator('.input-field')
.type(cardInput.cvc);
}
await this.page.waitForLoadState('networkidle', { timeout: 20000 });
await this.page.waitForLoadState('networkidle');
await this.page.click('button[name="save"]');
};

Expand All @@ -41,7 +41,7 @@ export default class AccountPageSFRA {
const cardElement = this.savedCardElementGenerator(cardData);
const deleteButton = cardElement.locator('../../button');

await this.page.waitForLoadState('networkidle', { timeout: 20000 });
await this.page.waitForLoadState('networkidle');

await deleteButton.click();
await this.page.click('.delete-confirmation-btn');
Expand All @@ -52,7 +52,6 @@ export default class AccountPageSFRA {

await cardElement.waitFor({
state: 'visible',
timeout: 20000,
});
};

Expand All @@ -65,7 +64,6 @@ export default class AccountPageSFRA {

await cardElement.waitFor({
state: 'detached',
timeout: 20000,
});
};

Expand Down
34 changes: 17 additions & 17 deletions tests/playwright/pages/CheckoutPageSFRA5.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class CheckoutPageSFRA5 {

isPaymentModalShown = async (imgAltValue) => {
await expect(this.paymentModal.locator(`img[alt='${imgAltValue}']`))
.toBeVisible({ timeout: 20000 });
.toBeVisible();
}

navigateToCheckout = async (locale) => {
Expand All @@ -101,7 +101,7 @@ export default class CheckoutPageSFRA5 {

goToCheckoutPageWithFullCart = async (locale, itemCount = 1) => {
await this.addProductToCart(locale, itemCount);
await this.successMessage.waitFor({ visible: true, timeout: 20000 });
await this.successMessage.waitFor({ visible: true });

await this.navigateToCheckout(locale);
await this.checkoutGuest.click();
Expand Down Expand Up @@ -166,20 +166,20 @@ export default class CheckoutPageSFRA5 {
};

submitShipping = async () => {
await this.page.waitForLoadState('networkidle', { timeout: 20000 });
await this.page.waitForLoadState('networkidle');
await this.shippingSubmit.click();
await this.page.waitForNavigation({ waitUntil: "networkidle", timeout: 20000 });
await this.page.waitForNavigation({ waitUntil: "networkidle" });

// Ugly wait since the submit button takes time to mount.
await new Promise(r => setTimeout(r, 2000));
};

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

Expand All @@ -193,7 +193,7 @@ export default class CheckoutPageSFRA5 {
};

goBackAndSubmitShipping = async () => {
await this.page.waitForNavigation('load', { timeout: 20000 });
await this.page.waitForNavigation('load');
await this.navigateBack();
await this.submitShipping();
};
Expand All @@ -203,40 +203,40 @@ export default class CheckoutPageSFRA5 {
url: /Order-Confirm/,
timeout: 20000,
});
await expect(this.thankYouMessage).toBeVisible({ timeout: 20000 });
await expect(this.thankYouMessage).toBeVisible();
};

expectNonRedirectSuccess = async () => {
await expect(this.thankYouMessage).toBeVisible({ timeout: 20000 });
await expect(this.thankYouMessage).toBeVisible();
};

expectRefusal = async () => {
await expect(this.errorMessage).not.toBeEmpty({ timeout: 25000 });
await expect(this.errorMessage).not.toBeEmpty();
};

expectVoucher = async () => {
await expect(this.voucherCode).toBeVisible({ timeout: 20000 });
await expect(this.voucherCode).toBeVisible();
};

expectQRcode = async () => {
await this.qrLoader.waitFor({ state: 'attached', timeout: 20000 });
await expect(this.qrLoaderAmount).toBeVisible({ timeout: 20000 });
await expect(this.qrImg).toBeVisible({ timeout: 20000 });
await this.qrLoader.waitFor({ state: 'attached'});
await expect(this.qrLoaderAmount).toBeVisible();
await expect(this.qrImg).toBeVisible();
};

expectGiftCardWarning = async () => {
await expect(this.giftCardWarning).not.toBeEmpty();
};

getLocation = async () => {
await this.page.waitForLoadState('load', { timeout: 20000 });
await this.page.waitForLoadState('load');
return await this.page.url();
};

navigateBack = async () => {
await this.page.waitForLoadState('networkidle', { timeout: 20000 });
await this.page.waitForLoadState('networkidle');
await this.page.goBack();
await this.page.waitForLoadState('networkidle', { timeout: 20000 });
await this.page.waitForLoadState('networkidle');
};

loginUser = async (credentials) => {
Expand Down
52 changes: 23 additions & 29 deletions tests/playwright/pages/CheckoutPageSFRA6.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class CheckoutPageSFRA {

this.shippingSubmit = page.locator("button[value='submit-shipping']");

this.submitPaymentButton = page.locator("button[value='submit-payment']");
this.submitPaymentButton = page.locator('.submit-payment');
this.placeOrderButton = page.locator("button[value='place-order']");

this.errorMessage = page.locator('.error-message-text');
Expand Down Expand Up @@ -89,7 +89,7 @@ export default class CheckoutPageSFRA {

isPaymentModalShown = async (imgAltValue) => {
await expect(this.paymentModal.locator(`img[alt='${imgAltValue}']`))
.toBeVisible({ timeout: 20000 });
.toBeVisible();
}

navigateToCheckout = async (locale) => {
Expand All @@ -102,7 +102,7 @@ export default class CheckoutPageSFRA {

goToCheckoutPageWithFullCart = async (locale, itemCount = 1, email) => {
await this.addProductToCart(locale, itemCount);
await this.successMessage.waitFor({ visible: true, timeout: 20000 });
await this.successMessage.waitFor({ visible: true });

await this.navigateToCheckout(locale);
await this.setEmail(email);
Expand All @@ -127,7 +127,7 @@ export default class CheckoutPageSFRA {
};

setShopperDetails = async (shopperDetails) => {
await this.customerInfoSection.waitFor({ visible: true, timeout: 20000 });
await this.customerInfoSection.waitFor({ visible: true });


await this.checkoutPageUserFirstNameInput.type(
Expand Down Expand Up @@ -175,31 +175,26 @@ export default class CheckoutPageSFRA {
};

submitShipping = async () => {
await this.page.waitForLoadState('networkidle', { timeout: 20000 });
await this.page.waitForLoadState('networkidle');
await this.shippingSubmit.click();
await this.page.waitForNavigation({ waitUntil: "networkidle", timeout: 20000 });
await this.page.waitForNavigation({ waitUntil: "networkidle" });

// Ugly wait since the submit button takes time to mount.
await new Promise(r => setTimeout(r, 2000));
};

submitPayment = async () => {
await this.page.waitForLoadState('load', { timeout: 30000 });
await this.submitPaymentButton.click();
await this.page.waitForFunction(() => {
const button = document.querySelector('.submit-payment');
return button && !button.disabled;
});

await this.submitPaymentButton.click();
};

placeOrder = async () => {
let retries = 3;
while (retries > 0) {
try {
await this.page.waitForLoadState('load', { timeout: 30000 });
await this.placeOrderButton.click();
break; // Break out of the loop if successful
} catch (error) {
retries--;
await this.page.reload();
}
}
await this.page.waitForLoadState('load');
await this.placeOrderButton.click();
};

completeCheckoutLoggedInUser = async () => {
Expand All @@ -212,7 +207,7 @@ export default class CheckoutPageSFRA {
};

goBackAndSubmitShipping = async () => {
await this.page.waitForNavigation('load', { timeout: 20000 });
await this.page.waitForNavigation('load');
await this.navigateBack();
await this.submitShipping();
};
Expand All @@ -221,35 +216,34 @@ export default class CheckoutPageSFRA {
expectSuccess = async () => {
await this.page.waitForNavigation({
url: /Order-Confirm/,
timeout: 20000,
});
await expect(this.thankYouMessage).toBeVisible({ timeout: 20000 });
await expect(this.thankYouMessage).toBeVisible();
};

expectNonRedirectSuccess = async () => {
await expect(this.thankYouMessage).toBeVisible({ timeout: 20000 });
await expect(this.thankYouMessage).toBeVisible();
};

expectRefusal = async () => {
await expect(this.errorMessage).not.toBeEmpty({ timeout: 25000 });
await expect(this.errorMessage).not.toBeEmpty();
};

expectVoucher = async () => {
await expect(this.voucherCode).toBeVisible({ timeout: 20000 });
await expect(this.voucherCode).toBeVisible();
};

expectQRcode = async () => {
await this.qrLoader.waitFor({ state: 'attached', timeout: 20000 });
await expect(this.qrLoaderAmount).toBeVisible({ timeout: 20000 });
await expect(this.qrImg).toBeVisible({ timeout: 20000 });
await this.qrLoader.waitFor({ state: 'attached' });
await expect(this.qrLoaderAmount).toBeVisible();
await expect(this.qrImg).toBeVisible();
};

expectGiftCardWarning = async () => {
await expect(this.giftCardWarning).not.toBeEmpty();
};

getLocation = async () => {
await this.page.waitForLoadState('load', { timeout: 20000 });
await this.page.waitForLoadState('load');
return await this.page.url();
};

Expand Down
Loading

0 comments on commit 8017d91

Please sign in to comment.