From 49eb1f9049dc2f0306a2ff5f390dfc3aacf28acb Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Wed, 19 Oct 2022 17:09:52 +0530 Subject: [PATCH] feat(testing): Improved flakyness --- scripts/playwright/pages/Dashboard/TreeView.ts | 8 ++++++-- scripts/playwright/tests/erd.spec.ts | 3 +++ scripts/playwright/tests/linkToAnotherRecord.spec.ts | 5 ++++- scripts/playwright/tests/metaSync.spec.ts | 2 ++ scripts/playwright/tests/toolbarOperations.spec.ts | 9 ++------- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/playwright/pages/Dashboard/TreeView.ts b/scripts/playwright/pages/Dashboard/TreeView.ts index 9598ed7041..73d7629fae 100644 --- a/scripts/playwright/pages/Dashboard/TreeView.ts +++ b/scripts/playwright/pages/Dashboard/TreeView.ts @@ -79,7 +79,6 @@ export class TreeViewPage extends BasePage { } async deleteTable({ title }: { title: string }) { - const tabCount = await this.dashboard.tabBar.locator('.ant-tabs-tab').count() await this.get() .locator(`.nc-project-tree-tbl-${title}`) .click({ button: "right" }); @@ -93,7 +92,12 @@ export class TreeViewPage extends BasePage { httpMethodsToMatch: ["DELETE"], requestUrlPathToMatch: `/api/v1/db/meta/tables/`, }); - await expect.poll(async () => await this.dashboard.tabBar.locator('.ant-tabs-tab').count()).toBe(tabCount - 1); + + await expect.poll(async () => + await this.dashboard.tabBar.locator('.ant-tabs-tab', { + hasText: title + }).isVisible() + ).toBe(false); (await this.rootPage.locator('.nc-container').last().elementHandle())?.waitForElementState('stable'); } diff --git a/scripts/playwright/tests/erd.spec.ts b/scripts/playwright/tests/erd.spec.ts index 7ca10e0f8a..bc7c95856d 100644 --- a/scripts/playwright/tests/erd.spec.ts +++ b/scripts/playwright/tests/erd.spec.ts @@ -13,6 +13,9 @@ test.describe("Erd", () => { let project: any; let sakilaTables, sakilaSqlViews; + // todo: Break the test into smaller tests + test.setTimeout(150000); + test.beforeEach(async ({ page }) => { context = await setup({ page }); dashboard = new DashboardPage(page, context.project); diff --git a/scripts/playwright/tests/linkToAnotherRecord.spec.ts b/scripts/playwright/tests/linkToAnotherRecord.spec.ts index b46fa3e52a..1cfbbec264 100644 --- a/scripts/playwright/tests/linkToAnotherRecord.spec.ts +++ b/scripts/playwright/tests/linkToAnotherRecord.spec.ts @@ -6,12 +6,15 @@ test.describe("LTAR create & update", () => { let dashboard: DashboardPage; let context: any; + // todo: Break the test into smaller tests + test.setTimeout(150000); + test.beforeEach(async ({ page }) => { context = await setup({ page }); dashboard = new DashboardPage(page, context.project); }); - test.only("LTAR", async () => { + test("LTAR", async () => { // close 'Team & Auth' tab await dashboard.closeTab({ title: "Team & Auth" }); diff --git a/scripts/playwright/tests/metaSync.spec.ts b/scripts/playwright/tests/metaSync.spec.ts index ab3e316fd3..ed45b3e93c 100644 --- a/scripts/playwright/tests/metaSync.spec.ts +++ b/scripts/playwright/tests/metaSync.spec.ts @@ -237,12 +237,14 @@ test.describe("Meta sync", () => { await dashboard.grid.toolbar.sort.addSort({ columnTitle: "Col1", isAscending: false, + isLocallySaved: true }); await dashboard.grid.toolbar.filter.addNew({ columnTitle: "Col1", opType: ">=", value: "5", + isLocallySaved: true }); await dashboard.grid.verifyRowCount({ count: 5 }); diff --git a/scripts/playwright/tests/toolbarOperations.spec.ts b/scripts/playwright/tests/toolbarOperations.spec.ts index e9f700ad40..17a62f0b00 100644 --- a/scripts/playwright/tests/toolbarOperations.spec.ts +++ b/scripts/playwright/tests/toolbarOperations.spec.ts @@ -34,7 +34,6 @@ test.describe("Toolbar operations (GRID)", () => { }); // hide column - console.log("hide column"); await toolbar.fields.toggle({ title: "LastUpdate" }); await dashboard.grid.column.verify({ title: "LastUpdate", @@ -42,7 +41,6 @@ test.describe("Toolbar operations (GRID)", () => { }); // un-hide column - console.log("un-hide column"); await toolbar.fields.toggle({ title: "LastUpdate" }); await dashboard.grid.column.verify({ title: "LastUpdate", @@ -51,26 +49,23 @@ test.describe("Toolbar operations (GRID)", () => { await validateFirstRow("Afghanistan"); // Sort column - console.log("sort column"); - await toolbar.sort.addSort({ columnTitle: "Country", isAscending: false }); + await toolbar.sort.addSort({ columnTitle: "Country", isAscending: false, isLocallySaved: true }); await validateFirstRow("Zambia"); // reset sort - console.log("reset sort"); await toolbar.sort.resetSort(); await validateFirstRow("Afghanistan"); // Filter column - console.log("filter column"); await toolbar.filter.addNew({ columnTitle: "Country", value: "India", opType: "is equal", + isLocallySaved: true }); await validateFirstRow("India"); // Reset filter - console.log("reset filter"); await toolbar.filter.resetFilter(); await validateFirstRow("Afghanistan");