mirror of https://github.com/nocodb/nocodb
Raju Udava
2 years ago
committed by
Muhammed Mustafa
4 changed files with 211 additions and 0 deletions
@ -0,0 +1,98 @@
|
||||
import { Locator, expect } from "@playwright/test"; |
||||
import BasePage from "../../../Base"; |
||||
import { ToolbarPage } from "."; |
||||
|
||||
export class ToolbarViewMenuPage extends BasePage { |
||||
readonly toolbar: ToolbarPage; |
||||
readonly viewsMenuBtn: Locator; |
||||
|
||||
constructor(toolbar: ToolbarPage) { |
||||
super(toolbar.rootPage); |
||||
this.toolbar = toolbar; |
||||
this.viewsMenuBtn = this.toolbar.get().locator(`.nc-actions-menu-btn`); |
||||
} |
||||
|
||||
get() { |
||||
return this.rootPage.locator(`.ant-dropdown.nc-dropdown-actions-menu`); |
||||
} |
||||
|
||||
getLockTypeSubMenu() { |
||||
return this.rootPage.locator(`[id="sub_menu_1_$$_lock-type-popup"]`); |
||||
} |
||||
|
||||
// menu items
|
||||
// Collaborative View
|
||||
// Download
|
||||
// Upload
|
||||
// Shared View List
|
||||
// Webhooks
|
||||
// Get API Snippet
|
||||
// ERD View
|
||||
|
||||
async click({ menu, subMenu }: { menu: string; subMenu?: string }) { |
||||
await this.viewsMenuBtn.click(); |
||||
await this.get() |
||||
.locator(`.ant-dropdown-menu-title-content:has-text("${menu}")`) |
||||
.first() |
||||
.click(); |
||||
if (subMenu) { |
||||
await this.getLockTypeSubMenu() |
||||
.locator(`.nc-locked-menu-item:has-text("${subMenu}")`) |
||||
.last() |
||||
.click(); |
||||
switch (subMenu) { |
||||
case "Locked View": |
||||
await this.toastWait({ |
||||
message: "Successfully Switched to locked view", |
||||
}); |
||||
break; |
||||
case "Collaborative View": |
||||
await this.toastWait({ |
||||
message: "Successfully Switched to collaborative view", |
||||
}); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
await this.toolbar.grid.waitLoading(); |
||||
} |
||||
|
||||
async verifyLockMode() { |
||||
expect( |
||||
await this.toolbar.get().locator(`.nc-fields-menu-btn.nc-toolbar-btn`) |
||||
).toBeDisabled(); |
||||
expect( |
||||
await this.toolbar.get().locator(`.nc-filter-menu-btn.nc-toolbar-btn`) |
||||
).toBeDisabled(); |
||||
expect( |
||||
await this.toolbar.get().locator(`.nc-sort-menu-btn.nc-toolbar-btn`) |
||||
).toBeDisabled(); |
||||
expect( |
||||
await this.toolbar |
||||
.get() |
||||
.locator(`.nc-add-new-row-btn.nc-toolbar-btn > .nc-icon.disabled`) |
||||
).toBeVisible(); |
||||
|
||||
await this.toolbar.grid.verifyEditDisabled({ columnHeader: "Country" }); |
||||
} |
||||
|
||||
async verifyCollaborativeMode() { |
||||
expect( |
||||
await this.toolbar.get().locator(`.nc-fields-menu-btn.nc-toolbar-btn`) |
||||
).toBeEnabled(); |
||||
expect( |
||||
await this.toolbar.get().locator(`.nc-filter-menu-btn.nc-toolbar-btn`) |
||||
).toBeEnabled(); |
||||
expect( |
||||
await this.toolbar.get().locator(`.nc-sort-menu-btn.nc-toolbar-btn`) |
||||
).toBeEnabled(); |
||||
expect( |
||||
await this.toolbar |
||||
.get() |
||||
.locator(`.nc-add-new-row-btn.nc-toolbar-btn > .nc-icon`) |
||||
).toBeVisible(); |
||||
|
||||
await this.toolbar.grid.verifyEditEnabled({ columnHeader: "Country" }); |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
import { test } from "@playwright/test"; |
||||
import { DashboardPage } from "../pages/Dashboard"; |
||||
import setup from "../setup"; |
||||
|
||||
test.describe("Grid view locked", () => { |
||||
let dashboard: DashboardPage; |
||||
let context: any; |
||||
|
||||
test.beforeEach(async ({ page }) => { |
||||
context = await setup({ page }); |
||||
dashboard = new DashboardPage(page, context.project); |
||||
}); |
||||
|
||||
test("ReadOnly lock & collaboration mode", async () => { |
||||
// close 'Team & Auth' tab
|
||||
await dashboard.closeTab({ title: "Team & Auth" }); |
||||
await dashboard.treeView.openTable({ title: "Country" }); |
||||
|
||||
await dashboard.grid.toolbar.viewsMenu.verifyCollaborativeMode(); |
||||
|
||||
// enable view lock
|
||||
await dashboard.grid.toolbar.viewsMenu.click({ |
||||
menu: "Collaborative View", |
||||
subMenu: "Locked View", |
||||
}); |
||||
|
||||
// verify view lock
|
||||
await dashboard.grid.toolbar.viewsMenu.verifyLockMode(); |
||||
|
||||
// enable collaborative view
|
||||
await dashboard.grid.toolbar.viewsMenu.click({ |
||||
menu: "Locked View", |
||||
subMenu: "Collaborative View", |
||||
}); |
||||
|
||||
await dashboard.grid.toolbar.viewsMenu.verifyCollaborativeMode(); |
||||
|
||||
await dashboard.rootPage.waitForTimeout(1000); |
||||
}); |
||||
}); |
Loading…
Reference in new issue