context("Permissions API", () => { before(() => { cy.visit("/login"); cy.login("Administrator"); cy.call("xhiveframework.tests.ui_test_helpers.add_remove_role", { action: "remove", user: "xhiveframework@example.com", role: "System Manager", }); cy.call("logout"); cy.login("xhiveframework@example.com"); cy.visit("/app"); }); it("Checks permissions via `has_perm` for Kanban Board DocType", () => { cy.visit("/app/kanban-board/view/list"); cy.window() .its("xhiveframework") .then((xhiveframework) => { xhiveframework.model.with_doctype("Kanban Board", function () { // needed to make sure doc meta is loaded expect(xhiveframework.perm.has_perm("Kanban Board", 0, "read")).to.equal(true); expect(xhiveframework.perm.has_perm("Kanban Board", 0, "write")).to.equal(true); expect(xhiveframework.perm.has_perm("Kanban Board", 0, "print")).to.equal(false); }); }); }); it("Checks permissions via `get_perm` for Kanban Board DocType", () => { cy.visit("/app/kanban-board/view/list"); cy.window() .its("xhiveframework") .then((xhiveframework) => { xhiveframework.model.with_doctype("Kanban Board", function () { // needed to make sure doc meta is loaded const perms = xhiveframework.perm.get_perm("Kanban Board"); expect(perms.read).to.equal(true); expect(perms.write).to.equal(true); expect(perms.rights_without_if_owner).to.include("read"); }); }); }); after(() => { cy.call("logout"); cy.login("Administrator"); cy.call("xhiveframework.tests.ui_test_helpers.add_remove_role", { action: "add", user: "xhiveframework@example.com", role: "System Manager", }); cy.call("logout"); }); });