diff --git a/.changeset/olive-rocks-accept.md b/.changeset/olive-rocks-accept.md new file mode 100644 index 00000000000..865c825e5b4 --- /dev/null +++ b/.changeset/olive-rocks-accept.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Fix flaky PW tests diff --git a/playwright.config.ts b/playwright.config.ts index 44e834b8009..c23c0b44d53 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -10,9 +10,10 @@ export default defineConfig({ forbidOnly: !!process.env.CI, // TODO hardcoded values should be extracted to ENVs retries: process.env.CI ? 2 : 0, - workers: process.env.CI ? 2 : undefined, + workers: process.env.CI ? 2 : 2, reporter: process.env.CI ? "blob" : "html", - timeout: process.env.CI ? 60000 : 30000, + timeout: 60000 , + expect: { timeout: 10000 }, // webServer: { // command: "npm run dev", // url: "http://localhost:9000/", diff --git a/playwright/pages/dialogs/addProductsDialog.ts b/playwright/pages/dialogs/addProductsDialog.ts index ee4ccdb35ae..a386d459a2f 100644 --- a/playwright/pages/dialogs/addProductsDialog.ts +++ b/playwright/pages/dialogs/addProductsDialog.ts @@ -28,6 +28,7 @@ export class AddProductsDialog { .locator(this.productRowCheckbox) .click(); await this.clickConfirmButton(); + await this.productRow.first().waitFor({state:"hidden"}) await expect(this.productRow.first()).not.toBeVisible(); } } diff --git a/playwright/pages/dialogs/addressDialog.ts b/playwright/pages/dialogs/addressDialog.ts index 49514e9bd90..e36310b0a3d 100644 --- a/playwright/pages/dialogs/addressDialog.ts +++ b/playwright/pages/dialogs/addressDialog.ts @@ -96,8 +96,11 @@ export class AddressDialog { await this.typeCity(customerInfo.cityName); await this.typeZip(customerInfo.zip); await this.clickCountrySelect(); + await this.countrySelect.locator("input").clear() await this.countrySelect.locator("input").fill(customerInfo.country); - await this.selectOptions.filter({ hasText: customerInfo.country }).click(); + await this.selectOptions + .getByText(customerInfo.country) + .click(); await this.clickConfirmButton(); await this.submitButton.waitFor({ state: "hidden" }); } diff --git a/playwright/pages/loginPage.ts b/playwright/pages/loginPage.ts index 2815a2865e2..fbfe3ccce94 100644 --- a/playwright/pages/loginPage.ts +++ b/playwright/pages/loginPage.ts @@ -38,12 +38,15 @@ export class LoginPage { await this.typeEmail(userEmail); await this.typePassword(userPassword); await this.clickSignInButton(); - await expect(this.homePage.welcomeMessage).toContainText("Hello there,"); + await expect(this.homePage.welcomeMessage).toContainText("Hello there,", { + timeout: 15000 + }); // End of authentication steps. await page.context().storageState({ path }); } async typeEmail(email: string) { + await this.emailInput.waitFor({state: "visible", timeout:15000}) await this.emailInput.fill(email); } async typePassword(password: string) { diff --git a/playwright/pages/ordersPage.ts b/playwright/pages/ordersPage.ts index 263c9ccdcfa..e93ae75ca90 100644 --- a/playwright/pages/ordersPage.ts +++ b/playwright/pages/ordersPage.ts @@ -68,6 +68,7 @@ export class OrdersPage extends BasePage { await this.manualTransactionButton.click(); } async clickMarkAsPaidButton() { + await this.markAsPaidButton.waitFor({ state: "visible", timeout: 60000 }); await this.markAsPaidButton.click(); } async clickFulfillButton() { @@ -81,7 +82,7 @@ export class OrdersPage extends BasePage { } async clickFinalizeButton() { - await this.finalizeButton.click(); + await this.finalizeButton.click({timeout: 90000}); } async expectSuccessBanner() { await this.basePage.expectSuccessBanner(); diff --git a/playwright/tests/orders.spec.ts b/playwright/tests/orders.spec.ts index 323bbbac4e5..5fdadf45036 100644 --- a/playwright/tests/orders.spec.ts +++ b/playwright/tests/orders.spec.ts @@ -34,9 +34,7 @@ test("TC: SALEOR_28 Create basic order @e2e @order", async () => { await ordersPage.clickAddShippingCarrierButton(); await ordersPage.shippingAddressDialog.pickAndConfirmFirstShippingMethod(); await ordersPage.clickFinalizeButton(); - await ordersPage.successBanner - .filter({ hasText: "finalized" }) - .waitFor({ state: "visible" }); + await expect(ordersPage.successBanner.getByText("finalized")).toBeVisible({timeout:60000}) }); test("TC: SALEOR_76 Create order with transaction flow activated @e2e @order", async () => { await ordersPage.goToOrdersListView(); @@ -57,7 +55,7 @@ test("TC: SALEOR_76 Create order with transaction flow activated @e2e @order", a await ordersPage.shippingAddressDialog.pickAndConfirmFirstShippingMethod(); await ordersPage.clickFinalizeButton(); await ordersPage.successBanner - .filter({ hasText: "finalized" }) + .getByText("finalized") .waitFor({ state: "visible" }); await expect(ordersPage.markAsPaidButton).toBeVisible(); await expect(ordersPage.paymentSummarySection).toBeVisible();