Skip to content

Commit

Permalink
Fix flaky tests (#4693)
Browse files Browse the repository at this point in the history
* Fix flaky tests

* add changeset
  • Loading branch information
karola312 authored Feb 28, 2024
1 parent f97dd45 commit 8d30330
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-rocks-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Fix flaky PW tests
5 changes: 3 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
1 change: 1 addition & 0 deletions playwright/pages/dialogs/addProductsDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
5 changes: 4 additions & 1 deletion playwright/pages/dialogs/addressDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
}
Expand Down
5 changes: 4 additions & 1 deletion playwright/pages/loginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion playwright/pages/ordersPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
Expand Down
6 changes: 2 additions & 4 deletions playwright/tests/orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 8d30330

Please sign in to comment.