Browse Source

feat(testing): Moved toolbar to commons folder

pull/3848/head
Muhammed Mustafa 2 years ago
parent
commit
08b03bdb09
  1. 33
      scripts/playwright/pages/Dashboard/Form/index.ts
  2. 14
      scripts/playwright/pages/Dashboard/Gallery/index.ts
  3. 8
      scripts/playwright/pages/Dashboard/Grid/Column/index.ts
  4. 4
      scripts/playwright/pages/Dashboard/Grid/index.ts
  5. 4
      scripts/playwright/pages/Dashboard/TreeView.ts
  6. 2
      scripts/playwright/pages/Dashboard/common/Toolbar/Actions/Erd.ts
  7. 2
      scripts/playwright/pages/Dashboard/common/Toolbar/Actions/index.ts
  8. 4
      scripts/playwright/pages/Dashboard/common/Toolbar/Fields.ts
  9. 13
      scripts/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  10. 2
      scripts/playwright/pages/Dashboard/common/Toolbar/ShareView.ts
  11. 4
      scripts/playwright/pages/Dashboard/common/Toolbar/Sort.ts
  12. 9
      scripts/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts
  13. 22
      scripts/playwright/pages/Dashboard/common/Toolbar/index.ts
  14. 4
      scripts/playwright/pages/Dashboard/index.ts
  15. 12
      scripts/playwright/tests/metaSync.spec.ts
  16. 2
      scripts/playwright/tests/tableColumnOperation.spec.ts
  17. 5
      scripts/playwright/tests/toolbarOperations.spec.ts

33
scripts/playwright/pages/Dashboard/Form/index.ts

@ -2,10 +2,11 @@
import { Locator, expect } from "@playwright/test"; import { Locator, expect } from "@playwright/test";
import { DashboardPage } from ".."; import { DashboardPage } from "..";
import BasePage from "../../Base"; import BasePage from "../../Base";
import { ToolbarPage } from "../common/Toolbar";
export class FormPage extends BasePage { export class FormPage extends BasePage {
readonly dashboard: DashboardPage; readonly dashboard: DashboardPage;
readonly dashboardPage: DashboardPage; readonly toolbar: ToolbarPage;
readonly addAllButton: Locator; readonly addAllButton: Locator;
readonly removeAllButton: Locator; readonly removeAllButton: Locator;
@ -19,35 +20,37 @@ export class FormPage extends BasePage {
readonly formSubHeading: Locator; readonly formSubHeading: Locator;
readonly afterSubmitMsg: Locator; readonly afterSubmitMsg: Locator;
constructor(dashboardPage: DashboardPage) { constructor(dashboard: DashboardPage) {
super(dashboardPage.rootPage); super(dashboard.rootPage);
this.dashboard = dashboardPage; this.dashboard = dashboard;
this.addAllButton = dashboardPage this.toolbar = new ToolbarPage(this);
this.addAllButton = dashboard
.get() .get()
.locator('[data-pw="nc-form-add-all"]'); .locator('[data-pw="nc-form-add-all"]');
this.removeAllButton = dashboardPage this.removeAllButton = dashboard
.get() .get()
.locator('[data-pw="nc-form-remove-all"]'); .locator('[data-pw="nc-form-remove-all"]');
this.submitButton = dashboardPage this.submitButton = dashboard
.get() .get()
.locator('[data-pw="nc-form-submit"]'); .locator('[data-pw="nc-form-submit"]');
this.showAnotherFormRadioButton = dashboardPage this.showAnotherFormRadioButton = dashboard
.get() .get()
.locator('[data-pw="nc-form-checkbox-submit-another-form"]'); .locator('[data-pw="nc-form-checkbox-submit-another-form"]');
this.showAnotherFormAfter5SecRadioButton = dashboardPage this.showAnotherFormAfter5SecRadioButton = dashboard
.get() .get()
.locator('[data-pw="nc-form-checkbox-show-blank-form"]'); .locator('[data-pw="nc-form-checkbox-show-blank-form"]');
this.emailMeRadioButton = dashboardPage this.emailMeRadioButton = dashboard
.get() .get()
.locator('[data-pw="nc-form-checkbox-send-email"]'); .locator('[data-pw="nc-form-checkbox-send-email"]');
this.formHeading = dashboardPage this.formHeading = dashboard
.get() .get()
.locator('[data-pw="nc-form-heading"]'); .locator('[data-pw="nc-form-heading"]');
this.formSubHeading = dashboardPage this.formSubHeading = dashboard
.get() .get()
.locator('[data-pw="nc-form-sub-heading"]'); .locator('[data-pw="nc-form-sub-heading"]');
this.afterSubmitMsg = dashboardPage this.afterSubmitMsg = dashboard
.get() .get()
.locator('[data-pw="nc-form-after-submit-msg"]'); .locator('[data-pw="nc-form-after-submit-msg"]');
} }
@ -246,6 +249,10 @@ export class FormPage extends BasePage {
); );
} }
async waitLoading() {
await this.rootPage.waitForTimeout(1000);
}
verifyAfterSubmitMenuState(param: { verifyAfterSubmitMenuState(param: {
showBlankForm?: boolean; showBlankForm?: boolean;
submitAnotherForm?: boolean; submitAnotherForm?: boolean;

14
scripts/playwright/pages/Dashboard/Gallery/index.ts

@ -2,14 +2,16 @@
import { Locator, expect } from "@playwright/test"; import { Locator, expect } from "@playwright/test";
import { DashboardPage } from ".."; import { DashboardPage } from "..";
import BasePage from "../../Base"; import BasePage from "../../Base";
import { ToolbarPage } from "../common/Toolbar";
export class GalleryPage extends BasePage { export class GalleryPage extends BasePage {
readonly dashboard: DashboardPage; readonly dashboard: DashboardPage;
readonly dashboardPage: DashboardPage; readonly toolbar: ToolbarPage;
constructor(dashboardPage: DashboardPage) { constructor(dashboard: DashboardPage) {
super(dashboardPage.rootPage); super(dashboard.rootPage);
this.dashboard = dashboardPage; this.dashboard = dashboard;
this.toolbar = new ToolbarPage(this);
} }
get() { get() {
@ -42,4 +44,8 @@ export class GalleryPage extends BasePage {
await this.rootPage.waitForTimeout(1000); await this.rootPage.waitForTimeout(1000);
await this.rootPage.locator(`.nc-fields-menu-btn`).click(); await this.rootPage.locator(`.nc-fields-menu-btn`).click();
} }
async waitLoading() {
await this.rootPage.waitForTimeout(1000);
}
} }

8
scripts/playwright/pages/Dashboard/Grid/Column/index.ts

@ -212,11 +212,11 @@ export class ColumnPageObject extends BasePage {
await this.rootPage.waitForTimeout(200); await this.rootPage.waitForTimeout(200);
} }
async verify({ title, isVisible }: { title: string; isVisible?: boolean }) { async verify({ title, isVisible = true }: { title: string; isVisible?: boolean }) {
if (false === isVisible) { if (!isVisible) {
return expect( return expect(
await this.rootPage.locator(`th[data-title="${title}"]`).count() await this.rootPage.locator(`th[data-title="${title}"]`)
).toBe(0); ).not.toBeVisible();
} }
await expect( await expect(
this.rootPage.locator(`th[data-title="${title}"]`) this.rootPage.locator(`th[data-title="${title}"]`)

4
scripts/playwright/pages/Dashboard/Grid/index.ts

@ -4,7 +4,7 @@ import { DashboardPage } from "..";
import BasePage from "../../Base"; import BasePage from "../../Base";
import { CellPageObject } from "./Cell"; import { CellPageObject } from "./Cell";
import { ColumnPageObject } from "./Column"; import { ColumnPageObject } from "./Column";
import { ToolbarPage } from "../Toolbar"; import { ToolbarPage } from "../common/Toolbar";
export class GridPage extends BasePage { export class GridPage extends BasePage {
readonly dashboard: DashboardPage; readonly dashboard: DashboardPage;
@ -20,7 +20,7 @@ export class GridPage extends BasePage {
this.addNewTableButton = dashboardPage.get().locator(".nc-add-new-table"); this.addNewTableButton = dashboardPage.get().locator(".nc-add-new-table");
this.column = new ColumnPageObject(this); this.column = new ColumnPageObject(this);
this.cell = new CellPageObject(this); this.cell = new CellPageObject(this);
this.toolbar = new ToolbarPage(this.dashboard); this.toolbar = new ToolbarPage(this);
} }
get() { get() {

4
scripts/playwright/pages/Dashboard/TreeView.ts

@ -77,6 +77,7 @@ export class TreeViewPage extends BasePage {
} }
async deleteTable({ title }: { title: string }) { async deleteTable({ title }: { title: string }) {
const tabCount = await this.rootPage.locator('.nc-container').count()
await this.get() await this.get()
.locator(`.nc-project-tree-tbl-${title}`) .locator(`.nc-project-tree-tbl-${title}`)
.click({ button: "right" }); .click({ button: "right" });
@ -90,6 +91,9 @@ export class TreeViewPage extends BasePage {
requestHttpMethod: "DELETE", requestHttpMethod: "DELETE",
requestUrlPathToMatch: `/api/v1/db/meta/tables/`, requestUrlPathToMatch: `/api/v1/db/meta/tables/`,
}); });
await expect.poll(async () => await this.rootPage.locator('.nc-container').count() === tabCount - 1).toBe(true);
(await this.rootPage.locator('.nc-container').last().elementHandle())?.waitForElementState('stable');
} }
async renameTable({ title, newTitle }: { title: string; newTitle: string }) { async renameTable({ title, newTitle }: { title: string; newTitle: string }) {

2
scripts/playwright/pages/Dashboard/Toolbar/Actions/Erd.ts → scripts/playwright/pages/Dashboard/common/Toolbar/Actions/Erd.ts

@ -1,5 +1,5 @@
import { ToolbarActionsPage } from "."; import { ToolbarActionsPage } from ".";
import { ErdBasePage } from "../../commonBase/Erd"; import { ErdBasePage } from "../../../commonBase/Erd";
export class ToolbarActionsErdPage extends ErdBasePage { export class ToolbarActionsErdPage extends ErdBasePage {
readonly toolbarActions: ToolbarActionsPage; readonly toolbarActions: ToolbarActionsPage;

2
scripts/playwright/pages/Dashboard/Toolbar/Actions/index.ts → scripts/playwright/pages/Dashboard/common/Toolbar/Actions/index.ts

@ -1,4 +1,4 @@
import BasePage from "../../../Base"; import BasePage from "../../../../Base";
import { ToolbarPage } from ".."; import { ToolbarPage } from "..";
import { ToolbarActionsErdPage } from "./Erd"; import { ToolbarActionsErdPage } from "./Erd";

4
scripts/playwright/pages/Dashboard/Toolbar/Fields.ts → scripts/playwright/pages/Dashboard/common/Toolbar/Fields.ts

@ -1,4 +1,4 @@
import BasePage from "../../Base"; import BasePage from "../../../Base";
import { ToolbarPage } from "./index"; import { ToolbarPage } from "./index";
export class ToolbarFieldsPage extends BasePage { export class ToolbarFieldsPage extends BasePage {
@ -27,6 +27,6 @@ export class ToolbarFieldsPage extends BasePage {
.locator(`[pw-data="nc-fields-menu-${title}"]`) .locator(`[pw-data="nc-fields-menu-${title}"]`)
.locator('input[type="checkbox"]') .locator('input[type="checkbox"]')
.click(); .click();
await this.toolbar.waitLoading(); await this.toolbar.parent.waitLoading();
} }
} }

13
scripts/playwright/pages/Dashboard/Toolbar/Filter.ts → scripts/playwright/pages/Dashboard/common/Toolbar/Filter.ts

@ -1,4 +1,4 @@
import BasePage from "../../Base"; import BasePage from "../../../Base";
import { ToolbarPage } from "./index"; import { ToolbarPage } from "./index";
export class ToolbarFilterPage extends BasePage { export class ToolbarFilterPage extends BasePage {
@ -40,8 +40,12 @@ export class ToolbarFilterPage extends BasePage {
await this.rootPage.locator(".nc-filter-value-select").last().fill(value); await this.rootPage.locator(".nc-filter-value-select").last().fill(value);
await this.waitForResponse({
requestHttpMethod: "POST",
requestUrlPathToMatch: "/filters",
})
await this.toolbar.clickFilter(); await this.toolbar.clickFilter();
await this.toolbar.waitLoading();
} }
click({ title }: { title: string }) { click({ title }: { title: string }) {
@ -54,6 +58,11 @@ export class ToolbarFilterPage extends BasePage {
async resetFilter() { async resetFilter() {
await this.toolbar.clickFilter(); await this.toolbar.clickFilter();
await this.get().locator(".nc-filter-item-remove-btn").click(); await this.get().locator(".nc-filter-item-remove-btn").click();
await this.waitForResponse({
requestHttpMethod: "DELETE",
requestUrlPathToMatch: "/api/v1/db/meta/filters/",
})
await this.toolbar.clickFilter(); await this.toolbar.clickFilter();
} }
} }

2
scripts/playwright/pages/Dashboard/Toolbar/ShareView.ts → scripts/playwright/pages/Dashboard/common/Toolbar/ShareView.ts

@ -1,4 +1,4 @@
import BasePage from "../../Base"; import BasePage from "../../../Base";
import { ToolbarPage } from "./index"; import { ToolbarPage } from "./index";
export class ToolbarShareViewPage extends BasePage { export class ToolbarShareViewPage extends BasePage {

4
scripts/playwright/pages/Dashboard/Toolbar/Sort.ts → scripts/playwright/pages/Dashboard/common/Toolbar/Sort.ts

@ -1,4 +1,4 @@
import BasePage from "../../Base"; import BasePage from "../../../Base";
import { ToolbarPage } from "./index"; import { ToolbarPage } from "./index";
export class ToolbarSortPage extends BasePage { export class ToolbarSortPage extends BasePage {
@ -41,7 +41,7 @@ export class ToolbarSortPage extends BasePage {
// close sort menu // close sort menu
await this.toolbar.clickSort(); await this.toolbar.clickSort();
await this.toolbar.waitLoading(); await this.toolbar.parent.waitLoading();
} }
async resetSort() { async resetSort() {

9
scripts/playwright/pages/Dashboard/Toolbar/ViewMenu.ts → scripts/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts

@ -1,5 +1,6 @@
import { Locator, expect } from "@playwright/test"; import { Locator, expect } from "@playwright/test";
import BasePage from "../../Base"; import BasePage from "../../../Base";
import { GridPage } from "../../Grid";
import { ToolbarPage } from "./index"; import { ToolbarPage } from "./index";
export class ToolbarViewMenuPage extends BasePage { export class ToolbarViewMenuPage extends BasePage {
@ -55,7 +56,7 @@ export class ToolbarViewMenuPage extends BasePage {
break; break;
} }
} }
await this.toolbar.waitLoading(); await this.toolbar.parent.waitLoading();
} }
async verifyLockMode() { async verifyLockMode() {
@ -74,7 +75,7 @@ export class ToolbarViewMenuPage extends BasePage {
.locator(`.nc-add-new-row-btn.nc-toolbar-btn > .nc-icon.disabled`) .locator(`.nc-add-new-row-btn.nc-toolbar-btn > .nc-icon.disabled`)
).toBeVisible(); ).toBeVisible();
await this.toolbar.grid.verifyEditDisabled({ columnHeader: "Country" }); await (this.toolbar.parent as GridPage).verifyEditDisabled({ columnHeader: "Country" });
} }
async verifyCollaborativeMode() { async verifyCollaborativeMode() {
@ -93,6 +94,6 @@ export class ToolbarViewMenuPage extends BasePage {
.locator(`.nc-add-new-row-btn.nc-toolbar-btn > .nc-icon`) .locator(`.nc-add-new-row-btn.nc-toolbar-btn > .nc-icon`)
).toBeVisible(); ).toBeVisible();
await this.toolbar.grid.verifyEditEnabled({ columnHeader: "Country" }); await (this.toolbar.parent as GridPage).verifyEditEnabled({ columnHeader: "Country" });
} }
} }

22
scripts/playwright/pages/Dashboard/Toolbar/index.ts → scripts/playwright/pages/Dashboard/common/Toolbar/index.ts

@ -1,17 +1,18 @@
import { expect } from "@playwright/test"; import { expect } from "@playwright/test";
import BasePage from "../../Base"; import BasePage from "../../../Base";
import { ToolbarFieldsPage } from "./Fields"; import { ToolbarFieldsPage } from "./Fields";
import { ToolbarSortPage } from "./Sort"; import { ToolbarSortPage } from "./Sort";
import { ToolbarFilterPage } from "./Filter"; import { ToolbarFilterPage } from "./Filter";
import { ToolbarShareViewPage } from "./ShareView"; import { ToolbarShareViewPage } from "./ShareView";
import { ToolbarViewMenuPage } from "./ViewMenu"; import { ToolbarViewMenuPage } from "./ViewMenu";
import * as fs from "fs"; import * as fs from "fs";
import { DashboardPage } from ".."; import { GridPage } from "../../Grid";
import { GridPage } from "../Grid";
import { ToolbarActionsPage } from "./Actions"; import { ToolbarActionsPage } from "./Actions";
import { GalleryPage } from "../../Gallery";
import { FormPage } from "../../Form";
export class ToolbarPage extends BasePage { export class ToolbarPage extends BasePage {
readonly dashboard: DashboardPage; readonly parent: GridPage | GalleryPage | FormPage;
readonly fields: ToolbarFieldsPage; readonly fields: ToolbarFieldsPage;
readonly sort: ToolbarSortPage; readonly sort: ToolbarSortPage;
readonly filter: ToolbarFilterPage; readonly filter: ToolbarFilterPage;
@ -19,9 +20,9 @@ export class ToolbarPage extends BasePage {
readonly viewsMenu: ToolbarViewMenuPage; readonly viewsMenu: ToolbarViewMenuPage;
readonly actions: ToolbarActionsPage; readonly actions: ToolbarActionsPage;
constructor(dashboard: DashboardPage) { constructor(parent: GridPage | GalleryPage | FormPage) {
super(dashboard.rootPage); super(parent.rootPage);
this.dashboard = dashboard; this.parent = parent;
this.fields = new ToolbarFieldsPage(this); this.fields = new ToolbarFieldsPage(this);
this.sort = new ToolbarSortPage(this); this.sort = new ToolbarSortPage(this);
this.filter = new ToolbarFilterPage(this); this.filter = new ToolbarFilterPage(this);
@ -110,11 +111,4 @@ export class ToolbarPage extends BasePage {
.locator(`.nc-toolbar-btn.nc-actions-menu-btn`) .locator(`.nc-toolbar-btn.nc-actions-menu-btn`)
.waitFor({ state: "hidden" }); .waitFor({ state: "hidden" });
} }
async waitLoading() {
await this.dashboard
.get()
.locator('[pw-data="grid-load-spinner"]')
.waitFor({ state: "hidden" });
}
} }

4
scripts/playwright/pages/Dashboard/index.ts

@ -10,7 +10,7 @@ import { TreeViewPage } from "./TreeView";
import { SettingsPage } from "./Settings"; import { SettingsPage } from "./Settings";
import { ViewSidebarPage } from "./ViewSidebar"; import { ViewSidebarPage } from "./ViewSidebar";
import { GalleryPage } from "./Gallery"; import { GalleryPage } from "./Gallery";
import { ToolbarPage } from "./Toolbar"; import { ToolbarPage } from "./common/Toolbar";
export class DashboardPage extends BasePage { export class DashboardPage extends BasePage {
readonly project: any; readonly project: any;
@ -25,7 +25,6 @@ export class DashboardPage extends BasePage {
readonly linkRecord: LinkRecord; readonly linkRecord: LinkRecord;
readonly settings: SettingsPage; readonly settings: SettingsPage;
readonly viewSidebar: ViewSidebarPage; readonly viewSidebar: ViewSidebarPage;
readonly toolbar: ToolbarPage;
constructor(rootPage: Page, project: any) { constructor(rootPage: Page, project: any) {
super(rootPage); super(rootPage);
@ -41,7 +40,6 @@ export class DashboardPage extends BasePage {
this.linkRecord = new LinkRecord(this); this.linkRecord = new LinkRecord(this);
this.settings = new SettingsPage(this); this.settings = new SettingsPage(this);
this.viewSidebar = new ViewSidebarPage(this); this.viewSidebar = new ViewSidebarPage(this);
this.toolbar = new ToolbarPage(this);
} }
get() { get() {

12
scripts/playwright/tests/metaSync.spec.ts

@ -33,7 +33,7 @@ test.describe("Meta sync", () => {
test.setTimeout(process.env.CI ? 100000 : 70000); test.setTimeout(process.env.CI ? 100000 : 70000);
await dashboard.gotoSettings(); await dashboard.gotoSettings();
await settings.selectTab({tab: SettingTab['Project Metadata']}); await settings.selectTab({tab: SettingTab.ProjectMetadata});
await dbExec( await dbExec(
`CREATE TABLE ${projectPrefix}table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))` `CREATE TABLE ${projectPrefix}table1 (id INT NOT NULL, col1 INT NULL, PRIMARY KEY (id))`
@ -230,16 +230,16 @@ test.describe("Meta sync", () => {
await dashboard.treeView.openTable({ title: "Table1" }); await dashboard.treeView.openTable({ title: "Table1" });
await dashboard.toolbar.clickFields(); await dashboard.grid.toolbar.clickFields();
await dashboard.toolbar.fields.click({ title: "Col1" }); await dashboard.grid.toolbar.fields.click({ title: "Col1" });
await dashboard.toolbar.clickFields(); await dashboard.grid.toolbar.clickFields();
await dashboard.toolbar.sort.addSort({ await dashboard.grid.toolbar.sort.addSort({
columnTitle: "Col1", columnTitle: "Col1",
isAscending: false, isAscending: false,
}); });
await dashboard.toolbar.filter.addNew({ await dashboard.grid.toolbar.filter.addNew({
columnTitle: "Col1", columnTitle: "Col1",
opType: ">=", opType: ">=",
value: "5", value: "5",

2
scripts/playwright/tests/tableColumnOperation.spec.ts

@ -26,7 +26,7 @@ test.describe("Table Column Operations", () => {
await grid.column.verify({ title: "column_name_b" }); await grid.column.verify({ title: "column_name_b" });
await grid.column.delete({ title: "column_name_b" }); await grid.column.delete({ title: "column_name_b" });
await grid.column.verify({ title: "column_name_b", isVisible: true }); await grid.column.verify({ title: "column_name_b", isVisible: false });
await grid.addNewRow({ index: 0, value: `Row 0` }); await grid.addNewRow({ index: 0, value: `Row 0` });
await grid.verifyRow({ index: 0 }); await grid.verifyRow({ index: 0 });

5
scripts/playwright/tests/toolbarOperations.spec.ts

@ -1,7 +1,8 @@
import { test } from "@playwright/test"; import { test } from "@playwright/test";
import { DashboardPage } from "../pages/Dashboard"; import { DashboardPage } from "../pages/Dashboard";
import { ToolbarPage } from "../pages/Dashboard/common/Toolbar";
import setup from "../setup"; import setup from "../setup";
import { ToolbarPage } from "../pages/Dashboard/Toolbar";
test.describe("Toolbar operations (GRID)", () => { test.describe("Toolbar operations (GRID)", () => {
let dashboard: DashboardPage, toolbar: ToolbarPage; let dashboard: DashboardPage, toolbar: ToolbarPage;
@ -18,7 +19,7 @@ test.describe("Toolbar operations (GRID)", () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
context = await setup({ page }); context = await setup({ page });
dashboard = new DashboardPage(page, context.project); dashboard = new DashboardPage(page, context.project);
toolbar = dashboard.toolbar; toolbar = dashboard.grid.toolbar;
}); });
test("Hide, Sort, Filter", async () => { test("Hide, Sort, Filter", async () => {

Loading…
Cancel
Save