Browse Source

test: use baseURL instead of hardcoding for validation, enable cache

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3848/head
Raju Udava 2 years ago committed by Muhammed Mustafa
parent
commit
d76fbe2133
  1. 60
      scripts/playwright/pages/Dashboard.ts

60
scripts/playwright/pages/Dashboard.ts

@ -1,7 +1,7 @@
// playwright-dev-page.ts
import { expect, Locator, Page } from '@playwright/test';
import { BasePage } from './Base';
import { ExpandedFormPage } from './ExpandedForm';
import { expect, Locator, Page } from "@playwright/test";
import { BasePage } from "./Base";
import { ExpandedFormPage } from "./ExpandedForm";
export class DashboardPage {
readonly project: any;
@ -15,57 +15,77 @@ export class DashboardPage {
this.page = page;
this.base = new BasePage(page);
this.project = project;
this.tablesSideBar = page.locator('.nc-treeview-container');
this.tabBar = page.locator('.nc-tab-bar');
this.tablesSideBar = page.locator(".nc-treeview-container");
this.tabBar = page.locator(".nc-tab-bar");
this.expandedForm = new ExpandedFormPage(page);
}
async goto() {
await this.page.goto(`http://localhost:3000/#/nc/${this.project.id}/auth`);
await this.page.goto(`/#/nc/${this.project.id}/auth`);
}
async gotoSettings() {
await this.page.locator('[pw-data="nc-project-menu"]').click();
await this.page.locator('div.nc-project-menu-item:has-text(" Team & Settings")').click();
await this.page
.locator('div.nc-project-menu-item:has-text(" Team & Settings")')
.click();
}
async openTable({ title }: { title: string }) {
await this.tablesSideBar.locator(`.nc-project-tree-tbl-${title}`).click();
await this.tabBar.textContent().then((text) => expect(text).toContain(title));
await this.tabBar
.textContent()
.then((text) => expect(text).toContain(title));
}
async createTable({ title }: { title: string }) {
await this.tablesSideBar.locator('.nc-add-new-table').click();
await this.tablesSideBar.locator(".nc-add-new-table").click();
await this.page.locator('.ant-modal-body').waitFor()
await this.page.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 expect(this.page).toHaveURL(`http://localhost:3000/#/nc/${this.project.id}/table/${title}`);
await this.page.locator('[pw-data="grid-load-spinner"]').waitFor({ state: 'hidden' });
await expect(this.page).toHaveURL(
`/#/nc/${this.project.id}/table/${title}`
);
await this.page
.locator('[pw-data="grid-load-spinner"]')
.waitFor({ state: "hidden" });
}
async verifyTableExistsInSidebar({ title }: { title: string }) {
await expect(this.tablesSideBar.locator(`.nc-project-tree-tbl-${title}`)).toBeVisible();
await expect(
this.tablesSideBar.locator(`.nc-project-tree-tbl-${title}`)
).toBeVisible();
}
async verifyTableDoesNotExistInSidebar({ title }: { title: string }) {
await expect(await this.tablesSideBar.locator(`.nc-project-tree-tbl-${title}`).count()).toBe(0);
await expect(
await this.tablesSideBar.locator(`.nc-project-tree-tbl-${title}`).count()
).toBe(0);
}
async deleteTable({ title }: { title: string }) {
await this.tablesSideBar.locator(`.nc-project-tree-tbl-${title}`).click({ button: 'right' });
await this.page.locator('div.nc-project-menu-item:has-text("Delete")').click();
await this.tablesSideBar
.locator(`.nc-project-tree-tbl-${title}`)
.click({ button: "right" });
await this.page
.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.base.toastWait({ message: "Deleted table successfully" });
}
async renameTable({ title, newTitle }: { title: string; newTitle: string }) {
await this.tablesSideBar.locator(`.nc-project-tree-tbl-${title}`).click({ button: 'right' });
await this.page.locator('div.nc-project-menu-item:has-text("Rename")').click();
await this.tablesSideBar
.locator(`.nc-project-tree-tbl-${title}`)
.click({ button: "right" });
await this.page
.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.base.toastWait({ message: "Table renamed successfully" });
}
}
Loading…
Cancel
Save