Skip to content

Commit

Permalink
fix: adjusting/removing some timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 committed Oct 8, 2024
1 parent 03a2ad5 commit 5d9ebff
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 43 deletions.
4 changes: 2 additions & 2 deletions tests/playwright/fixtures/USD.spec.mjs
Original file line number Diff line number Diff line change
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
5 changes: 2 additions & 3 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 Down
24 changes: 12 additions & 12 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 @@ -175,11 +175,11 @@ export default class CheckoutPageSFRA5 {
};

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,25 +203,25 @@ 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 () => {
Expand Down
19 changes: 9 additions & 10 deletions tests/playwright/pages/CheckoutPageSFRA6.mjs
Original file line number Diff line number Diff line change
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 @@ -216,27 +216,26 @@ 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 expect(this.qrLoaderAmount).toBeVisible();
await expect(this.qrImg).toBeVisible();
};

expectGiftCardWarning = async () => {
Expand Down
32 changes: 16 additions & 16 deletions tests/playwright/pages/PaymentMethodsPage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class PaymentMethodsPage {

// Capture popup for interaction
const [popup] = await Promise.all([
this.page.waitForEvent('popup', { timeout: 30000 }),
this.page.waitForEvent('popup'),
payPalButton.click({ timeout: 40000 }),
]);

Expand Down Expand Up @@ -83,7 +83,7 @@ export default class PaymentMethodsPage {
else {
await this.cancelButton.click();
await this.page.goBack();
await expect(this.page.locator('.add-to-cart'),).toBeVisible({ timeout: 20000 });
await expect(this.page.locator('.add-to-cart'),).toBeVisible();
}
};

Expand All @@ -95,7 +95,7 @@ export default class PaymentMethodsPage {
if (normalFlow) {
await this.page.click("#rb_amazonpay");
}
await this.page.waitForLoadState('domcontentloaded', { timeout: 20000 });
await this.page.waitForLoadState('domcontentloaded', { timeout: 30000 });
await this.page.click(".adyen-checkout__amazonpay__button");

// Amazon Sandbox selectors
Expand All @@ -111,7 +111,7 @@ export default class PaymentMethodsPage {
await this.passwordInput.click();
await this.passwordInput.type(paymentData.AmazonPay.password);
await this.loginButton.click();
await this.page.waitForLoadState("networkidle", { timeout: 20000 });
await this.page.waitForLoadState("networkidle", { timeout: 30000 });

if (await this.amazonCaptcha.isVisible()){
return false;
Expand Down Expand Up @@ -357,22 +357,22 @@ export default class PaymentMethodsPage {
waitForKlarnaLoad = async () => {
await this.page.waitForNavigation({
url: /.*playground.klarna/,
timeout: 25000,
timeout: 30000,
waitUntil: 'load',
});
};

// Generic function to be used for simulating the redirect
waitForRedirect = async () => {
await this.page.waitForNavigation({
timeout: 20000,
timeout: 30000,
waitUntil: 'load',
});
};

async continueOnKlarna(skipModal) {
await this.waitForKlarnaLoad();
await this.page.waitForLoadState('networkidle', { timeout: 25000 });
await this.page.waitForLoadState('networkidle', { timeout: 30000 });
this.klarnaIframe = this.page.frameLocator(
'#klarna-apf-iframe',
);
Expand All @@ -385,7 +385,7 @@ export default class PaymentMethodsPage {
await this.klarnaContinueButton.click();
await this.klarnaVerificationCodeInput.waitFor({
state: 'visible',
timeout: 25000,
timeout: 30000,
});
await this.klarnaVerificationCodeInput.fill('123456');
if (this.klarnaSelectPlanButton.isVisible() && !skipModal) {
Expand All @@ -394,7 +394,7 @@ export default class PaymentMethodsPage {
}
await this.klarnaBuyButton.waitFor({
state: 'visible',
timeout: 25000,
timeout: 30000,
});
await this.klarnaBuyButton.click();
}
Expand Down Expand Up @@ -444,10 +444,10 @@ export default class PaymentMethodsPage {
'#invoice_kp-invoice-payment-method',
);

await this.page.waitForNavigation('networkidle', { timeout: 20000 });
await this.klarnaPaymentMethodGroup.waitFor('visible', { timeout: 20000 });
await this.page.waitForLoadState('networkidle', { timeout: 20000 });
await this.klarnaBuyButton.waitFor('visible', { timeout: 20000 });
await this.page.waitForNavigation('networkidle', { timeout: 30000 });
await this.klarnaPaymentMethodGroup.waitFor('visible', { timeout: 30000 });
await this.page.waitForLoadState('networkidle', { timeout: 30000 });
await this.klarnaBuyButton.waitFor('visible', { timeout: 30000 });

await this.klarnaBuyButton.click();
await this.klarnaIdNumberField.fill('811228-9874');
Expand All @@ -456,7 +456,7 @@ export default class PaymentMethodsPage {

cancelKlarnaPayment = async () => {
await this.waitForKlarnaLoad();
await this.page.waitForLoadState('networkidle', { timeout: 25000 });
await this.page.waitForLoadState('networkidle', { timeout: 30000 });
this.cancelButton = this.page.locator("button[title='Close']");
await this.cancelButton.click();
await this.page.click("button[id='payment-cancel-dialog-express__confirm']");
Expand All @@ -468,8 +468,8 @@ export default class PaymentMethodsPage {
const backButton = this.page.locator("button[name='backLink']");

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

Expand Down

0 comments on commit 5d9ebff

Please sign in to comment.