Browse Source

test: ACL

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
adc74498e4
  1. 38
      scripts/playwright/pages/Dashboard/TreeView.ts
  2. 10
      scripts/playwright/tests/rolesCreate.spec.ts
  3. 58
      scripts/playwright/tests/tableOperations.spec.ts

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

@ -73,24 +73,32 @@ export class TreeViewPage extends BasePage {
await this.dashboard.waitForTabRender({ title });
}
async verifyTable({ title, index }: { title: string; index?: number }) {
await expect(
this.get().locator(`.nc-project-tree-tbl-${title}`)
).toBeVisible();
if (index) {
expect(await this.get().locator(".nc-tbl-title").nth(index)).toHaveText(
title
);
async verifyTable({
title,
index,
exists = true,
}: {
title: string;
index?: number;
exists?: boolean;
}) {
if (exists) {
await expect(
this.get().locator(`.nc-project-tree-tbl-${title}`)
).toBeVisible();
if (index) {
expect(await this.get().locator(".nc-tbl-title").nth(index)).toHaveText(
title
);
}
} else {
await expect(
await this.get().locator(`.nc-project-tree-tbl-${title}`).count()
).toBe(0);
}
}
async verifyTableDoesNotExist({ title }: { title: string }) {
await expect(
await this.get().locator(`.nc-project-tree-tbl-${title}`).count()
).toBe(0);
}
async deleteTable({ title }: { title: string }) {
await this.get()
.locator(`.nc-project-tree-tbl-${title}`)

10
scripts/playwright/tests/rolesCreate.spec.ts

@ -104,6 +104,16 @@ test.describe("User roles", () => {
await dashboard.expandedForm.validateRoleAccess({
role: roleDb[roleIdx].role,
});
// Access control validation
await dashboard.treeView.verifyTable({
title: "Language",
exists: roleDb[roleIdx].role === "creator" ? true : false,
});
await dashboard.treeView.verifyTable({
title: "CustomerList",
exists: roleDb[roleIdx].role === "creator" ? true : false,
});
}
test("Role Test", async () => {

58
scripts/playwright/tests/tableOperations.spec.ts

@ -1,42 +1,50 @@
import { test } from '@playwright/test';
import { DashboardPage } from '../pages/Dashboard';
import { SettingsPage, SettingTab } from '../pages/Dashboard/Settings';
import setup from '../setup';
import { test } from "@playwright/test";
import { DashboardPage } from "../pages/Dashboard";
import { SettingsPage, SettingTab } from "../pages/Dashboard/Settings";
import setup from "../setup";
test.describe('Table Operations', () => {
test.describe("Table Operations", () => {
let dashboard: DashboardPage, settings: SettingsPage;
let context: any;
test.beforeEach(async ({page}) => {
test.beforeEach(async ({ page }) => {
context = await setup({ page });
dashboard = new DashboardPage(page, context.project);
settings = dashboard.settings;
})
});
test("Create, and delete table, verify in audit tab, rename City table and reorder tables", async () => {
await dashboard.treeView.createTable({ title: "tablex" });
await dashboard.treeView.verifyTable({ title: "tablex" });
await dashboard.treeView.deleteTable({ title: "tablex" });
await dashboard.treeView.verifyTable({ title: "tablex", exists: false });
test('Create, and delete table, verify in audit tab, rename City table and reorder tables', async () => {
await dashboard.treeView.createTable({title: "tablex"});
await dashboard.treeView.verifyTable({title: "tablex"});
await dashboard.treeView.deleteTable({title: "tablex"});
await dashboard.treeView.verifyTableDoesNotExist({title: "tablex"});
await dashboard.gotoSettings();
await settings.selectTab({tab: SettingTab.Audit});
await settings.audit.verifyRow({index: 0, opType: 'TABLE', opSubtype: 'DELETED', user: 'user@nocodb.com'});
await settings.audit.verifyRow({index: 1, opType: 'TABLE', opSubtype: 'CREATED', user: 'user@nocodb.com'});
await settings.selectTab({ tab: SettingTab.Audit });
await settings.audit.verifyRow({
index: 0,
opType: "TABLE",
opSubtype: "DELETED",
user: "user@nocodb.com",
});
await settings.audit.verifyRow({
index: 1,
opType: "TABLE",
opSubtype: "CREATED",
user: "user@nocodb.com",
});
await settings.close();
await dashboard.treeView.renameTable({title: "City", newTitle: "Cityx"});
await dashboard.treeView.verifyTable({title: "Cityx"});
await dashboard.treeView.renameTable({ title: "City", newTitle: "Cityx" });
await dashboard.treeView.verifyTable({ title: "Cityx" });
await dashboard.treeView.focusTable({title: "Actor"});
await dashboard.treeView.verifyTable({title: "Actor", index: 0});
await dashboard.treeView.focusTable({ title: "Actor" });
await dashboard.treeView.verifyTable({ title: "Actor", index: 0 });
await dashboard.treeView.reorderTables({
sourceTable: "Actor",
destinationTable: "Address"
destinationTable: "Address",
});
await dashboard.treeView.verifyTable({title: "Address", index: 0});
await dashboard.treeView.verifyTable({ title: "Address", index: 0 });
});
});

Loading…
Cancel
Save