mirror of https://github.com/nocodb/nocodb
Raju Udava
2 years ago
committed by
Muhammed Mustafa
13 changed files with 498 additions and 40 deletions
@ -1,22 +1,22 @@ |
|||||||
import { test } from "@playwright/test"; |
import { test } from "@playwright/test"; |
||||||
import { DashboardPage } from "../pages/Dashboard"; |
import { DashboardPage } from "../pages/Dashboard"; |
||||||
import setup from "../setup"; |
import setup from "../setup"; |
||||||
|
import { ToolbarPage } from "../pages/Dashboard/common/Toolbar"; |
||||||
|
|
||||||
test.describe("Test block name", () => { |
test.describe.only("Test block name", () => { |
||||||
let dashboard: DashboardPage; |
let dashboard: DashboardPage; |
||||||
|
let toolbar: ToolbarPage; |
||||||
let context: any; |
let context: any; |
||||||
|
|
||||||
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.grid.toolbar; |
||||||
}); |
}); |
||||||
|
|
||||||
test("Test case name", async () => { |
test("Test case name", async () => { |
||||||
// close 'Team & Auth' tab
|
// close 'Team & Auth' tab
|
||||||
await dashboard.closeTab({ title: "Team & Auth" }); |
await dashboard.closeTab({ title: "Team & Auth" }); |
||||||
await dashboard.treeView.openTable({ title: "Country" }); |
await dashboard.treeView.openTable({ title: "Country" }); |
||||||
|
|
||||||
// ...
|
|
||||||
// ..
|
|
||||||
}); |
}); |
||||||
}); |
}); |
||||||
|
@ -0,0 +1,27 @@ |
|||||||
|
import { Locator, expect } from "@playwright/test"; |
||||||
|
import { SettingsPage } from "."; |
||||||
|
import BasePage from "../../Base"; |
||||||
|
|
||||||
|
export class AclPage extends BasePage { |
||||||
|
private readonly settings: SettingsPage; |
||||||
|
|
||||||
|
constructor(settings: SettingsPage) { |
||||||
|
super(settings.rootPage); |
||||||
|
this.settings = settings; |
||||||
|
} |
||||||
|
|
||||||
|
get() { |
||||||
|
return this.settings |
||||||
|
.get() |
||||||
|
.locator(`[pw-data="nc-settings-subtab-UI Access Control"]`); |
||||||
|
} |
||||||
|
|
||||||
|
async toggle({ table, role }: { table: string; role: string }) { |
||||||
|
await this.get().locator(`.nc-acl-${table}-${role}-chkbox`).click(); |
||||||
|
} |
||||||
|
|
||||||
|
async save() { |
||||||
|
this.get().locator(`button:has-text("Save")`).click(); |
||||||
|
await this.toastWait({ message: "Updated UI ACL for tables successfully" }); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
import { Locator, expect } from "@playwright/test"; |
||||||
|
import { SettingsPage } from "."; |
||||||
|
import BasePage from "../../Base"; |
||||||
|
import { writeFileAsync } from "xlsx"; |
||||||
|
import { ToolbarPage } from "../common/Toolbar"; |
||||||
|
|
||||||
|
export class TeamsPage extends BasePage { |
||||||
|
private readonly settings: SettingsPage; |
||||||
|
readonly inviteTeamBtn: Locator; |
||||||
|
readonly inviteTeamModal: Locator; |
||||||
|
|
||||||
|
constructor(settings: SettingsPage) { |
||||||
|
super(settings.rootPage); |
||||||
|
this.settings = settings; |
||||||
|
this.inviteTeamBtn = this.get().locator(`button:has-text("Invite Team")`); |
||||||
|
this.inviteTeamModal = this.rootPage.locator( |
||||||
|
`.nc-modal-invite-user-and-share-base` |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
get() { |
||||||
|
return this.settings |
||||||
|
.get() |
||||||
|
.locator(`[pw-data="nc-settings-subtab-Users Management"]`); |
||||||
|
} |
||||||
|
|
||||||
|
async invite({ email, role }: { email: string; role: string }) { |
||||||
|
await this.inviteTeamBtn.click(); |
||||||
|
await this.inviteTeamModal |
||||||
|
.locator(`input[placeholder="E-mail"]`) |
||||||
|
.fill(email); |
||||||
|
await this.inviteTeamModal.locator(`.nc-user-roles`).click(); |
||||||
|
const userRoleModal = this.rootPage.locator(`.nc-dropdown-user-role`); |
||||||
|
await userRoleModal.locator(`.nc-role-option:has-text("${role}")`).click(); |
||||||
|
await this.inviteTeamModal.locator(`button:has-text("Invite")`).click(); |
||||||
|
await this.toastWait({ message: "Successfully updated the user details" }); |
||||||
|
|
||||||
|
return await this.inviteTeamModal.locator(`.ant-alert-message`).innerText(); |
||||||
|
} |
||||||
|
|
||||||
|
async closeInvite() { |
||||||
|
// two btn-icon-only in invite modal: close & copy url
|
||||||
|
await this.inviteTeamModal |
||||||
|
.locator(`button.ant-btn-icon-only`) |
||||||
|
.first() |
||||||
|
.click(); |
||||||
|
} |
||||||
|
|
||||||
|
async inviteMore() { |
||||||
|
await this.inviteTeamModal |
||||||
|
.locator(`button:has-text("Invite More")`) |
||||||
|
.click(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,114 @@ |
|||||||
|
import { test } from "@playwright/test"; |
||||||
|
import { DashboardPage } from "../pages/Dashboard"; |
||||||
|
import setup from "../setup"; |
||||||
|
import { ToolbarPage } from "../pages/Dashboard/common/Toolbar"; |
||||||
|
import { |
||||||
|
SettingsPage, |
||||||
|
SettingsSubTab, |
||||||
|
SettingTab, |
||||||
|
} from "../pages/Dashboard/Settings"; |
||||||
|
|
||||||
|
let roleDb = [ |
||||||
|
{ email: "creator@nocodb.com", role: "creator", url: "" }, |
||||||
|
{ email: "editor@nocodb.com", role: "editor", url: "" }, |
||||||
|
{ email: "commenter@nocodb.com", role: "commenter", url: "" }, |
||||||
|
{ email: "viewer@nocodb.com", role: "viewer", url: "" }, |
||||||
|
]; |
||||||
|
|
||||||
|
async function roleSignup(roleIdx: number, db: any) { |
||||||
|
console.log(roleDb[roleIdx].url); |
||||||
|
await db.signOut(); |
||||||
|
|
||||||
|
await db.rootPage.goto(roleDb[roleIdx].url); |
||||||
|
await db.signUp({ |
||||||
|
email: roleDb[roleIdx].email, |
||||||
|
password: "Password123.", |
||||||
|
}); |
||||||
|
|
||||||
|
await db.openProject({ title: "externalREST0" }); |
||||||
|
|
||||||
|
// close 'Team & Auth' tab
|
||||||
|
if (roleDb[roleIdx].role === "creator") { |
||||||
|
await db.closeTab({ title: "Team & Auth" }); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
test.describe("User roles", () => { |
||||||
|
let dashboard: DashboardPage; |
||||||
|
let toolbar: ToolbarPage; |
||||||
|
let settings: SettingsPage; |
||||||
|
let context: any; |
||||||
|
|
||||||
|
test.beforeAll(async ({ page }) => { |
||||||
|
context = await setup({ page }); |
||||||
|
dashboard = new DashboardPage(page, context.project); |
||||||
|
toolbar = dashboard.grid.toolbar; |
||||||
|
settings = dashboard.settings; |
||||||
|
}); |
||||||
|
|
||||||
|
test("Create role", async () => { |
||||||
|
// close 'Team & Auth' tab
|
||||||
|
await dashboard.closeTab({ title: "Team & Auth" }); |
||||||
|
await dashboard.gotoSettings(); |
||||||
|
await settings.selectTab({ tab: SettingTab.TeamAuth }); |
||||||
|
for (let i = 0; i < roleDb.length; i++) { |
||||||
|
roleDb[i].url = await settings.teams.invite({ |
||||||
|
email: roleDb[i].email, |
||||||
|
role: roleDb[i].role, |
||||||
|
}); |
||||||
|
await settings.teams.closeInvite(); |
||||||
|
} |
||||||
|
await settings.close(); |
||||||
|
|
||||||
|
// configure access control
|
||||||
|
await dashboard.gotoSettings(); |
||||||
|
await settings.selectTab({ |
||||||
|
tab: SettingTab.ProjectMetadata, |
||||||
|
subTab: SettingsSubTab.ACL, |
||||||
|
}); |
||||||
|
await settings.acl.toggle({ table: "Language", role: "editor" }); |
||||||
|
await settings.acl.toggle({ table: "Language", role: "commenter" }); |
||||||
|
await settings.acl.toggle({ table: "Language", role: "viewer" }); |
||||||
|
await settings.acl.toggle({ table: "CustomerList", role: "editor" }); |
||||||
|
await settings.acl.toggle({ table: "CustomerList", role: "commenter" }); |
||||||
|
await settings.acl.toggle({ table: "CustomerList", role: "viewer" }); |
||||||
|
await settings.acl.save(); |
||||||
|
await settings.close(); |
||||||
|
}); |
||||||
|
|
||||||
|
async function roleTest(roleIdx: number, db: any) { |
||||||
|
await roleSignup(roleIdx, dashboard); |
||||||
|
await dashboard.validateProjectMenu({ |
||||||
|
role: roleDb[roleIdx].role, |
||||||
|
}); |
||||||
|
|
||||||
|
await dashboard.treeView.openTable({ title: "Country" }); |
||||||
|
|
||||||
|
await dashboard.viewSidebar.validateRoleAccess({ |
||||||
|
role: roleDb[roleIdx].role, |
||||||
|
}); |
||||||
|
|
||||||
|
await toolbar.validateRoleAccess({ |
||||||
|
role: roleDb[roleIdx].role, |
||||||
|
}); |
||||||
|
|
||||||
|
await dashboard.treeView.validateRoleAccess({ |
||||||
|
role: roleDb[roleIdx].role, |
||||||
|
}); |
||||||
|
|
||||||
|
await dashboard.grid.validateRoleAccess({ |
||||||
|
role: roleDb[roleIdx].role, |
||||||
|
}); |
||||||
|
|
||||||
|
await dashboard.grid.openExpandedRow({ index: 0 }); |
||||||
|
await dashboard.expandedForm.validateRoleAccess({ |
||||||
|
role: roleDb[roleIdx].role, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
test("Role Test", async () => { |
||||||
|
for (let i = 0; i < roleDb.length; i++) { |
||||||
|
await roleTest(i, dashboard); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
Loading…
Reference in new issue