mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-01 15:07:06 +00:00
feat(testing): Refactored Page object model
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { expect, Page } from "@playwright/test";
|
||||
import { BasePage } from "../Base";
|
||||
import { expect } from "@playwright/test";
|
||||
import { DashboardPage } from ".";
|
||||
import BasePage from "../Base";
|
||||
|
||||
export class TreeViewPage {
|
||||
readonly page: Page;
|
||||
readonly base: BasePage;
|
||||
export class TreeViewPage extends BasePage {
|
||||
readonly dashboard: DashboardPage;
|
||||
readonly project: any;
|
||||
|
||||
constructor(page: Page, project: any) {
|
||||
this.page = page;
|
||||
constructor(dashboard: DashboardPage, project: any) {
|
||||
super(dashboard.rootPage);
|
||||
this.dashboard = dashboard;
|
||||
this.project = project;
|
||||
this.base = new BasePage(page);
|
||||
}
|
||||
|
||||
get() {
|
||||
return this.page.locator(".nc-treeview-container");;
|
||||
return this.dashboard.get().locator(".nc-treeview-container");;
|
||||
}
|
||||
|
||||
async focusTable({ title }: { title: string }) {
|
||||
@@ -27,15 +27,15 @@ export class TreeViewPage {
|
||||
async createTable({ title }: { title: string }) {
|
||||
await this.get().locator(".nc-add-new-table").click();
|
||||
|
||||
await this.page.locator(".ant-modal-body").waitFor();
|
||||
await this.dashboard.get().locator(".ant-modal-body").waitFor();
|
||||
|
||||
await this.page.locator('[placeholder="Enter table name"]').fill(title);
|
||||
await this.page.locator('button:has-text("Submit")').click();
|
||||
await this.dashboard.get().locator('[placeholder="Enter table name"]').fill(title);
|
||||
await this.dashboard.get().locator('button:has-text("Submit")').click();
|
||||
|
||||
await expect(this.page).toHaveURL(
|
||||
await expect(this.rootPage).toHaveURL(
|
||||
`/#/nc/${this.project.id}/table/${title}`
|
||||
);
|
||||
await this.page
|
||||
await this.dashboard.get()
|
||||
.locator('[pw-data="grid-load-spinner"]')
|
||||
.waitFor({ state: "hidden" });
|
||||
}
|
||||
@@ -60,23 +60,23 @@ export class TreeViewPage {
|
||||
await this.get()
|
||||
.locator(`.nc-project-tree-tbl-${title}`)
|
||||
.click({ button: "right" });
|
||||
await this.page
|
||||
await this.dashboard.get()
|
||||
.locator('div.nc-project-menu-item:has-text("Delete")')
|
||||
.click();
|
||||
await this.page.locator('button:has-text("Yes")').click();
|
||||
await this.base.toastWait({ message: "Deleted table successfully" });
|
||||
await this.dashboard.get().locator('button:has-text("Yes")').click();
|
||||
await this.toastWait({ message: "Deleted table successfully" });
|
||||
}
|
||||
|
||||
async renameTable({ title, newTitle }: { title: string; newTitle: string }) {
|
||||
await this.get()
|
||||
.locator(`.nc-project-tree-tbl-${title}`)
|
||||
.click({ button: "right" });
|
||||
await this.page
|
||||
await this.dashboard.get()
|
||||
.locator('div.nc-project-menu-item:has-text("Rename")')
|
||||
.click();
|
||||
await this.page.locator('[placeholder="Enter table name"]').fill(newTitle);
|
||||
await this.page.locator('button:has-text("Submit")').click();
|
||||
await this.base.toastWait({ message: "Table renamed successfully" });
|
||||
await this.dashboard.get().locator('[placeholder="Enter table name"]').fill(newTitle);
|
||||
await this.dashboard.get().locator('button:has-text("Submit")').click();
|
||||
await this.toastWait({ message: "Table renamed successfully" });
|
||||
}
|
||||
|
||||
async reorderTables({ sourceTable, destinationTable}: {
|
||||
@@ -84,7 +84,7 @@ export class TreeViewPage {
|
||||
destinationTable: string;
|
||||
}) {
|
||||
|
||||
await this.page.locator(`[pw-data="tree-view-table-draggable-handle-${sourceTable}"]`).dragTo(
|
||||
await this.dashboard.get().locator(`[pw-data="tree-view-table-draggable-handle-${sourceTable}"]`).dragTo(
|
||||
this.get().locator(`[pw-data="tree-view-table-${destinationTable}"]`),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user