// SPDX-License-Identifier: AGPL-3.0-or-later import { describe, expect, it } from "vitest"; import { atLeast, grantableRoles } from "./workspaces"; describe("workspace role helpers", () => { it("ranks roles like the server", () => { expect(atLeast("owner", "admin")).toBe(true); expect(atLeast("admin", "admin")).toBe(true); expect(atLeast("member", "admin")).toBe(false); expect(atLeast("", "guest")).toBe(false); expect(atLeast(undefined, "guest")).toBe(false); }); it("never offers a role above the actor's own", () => { expect(grantableRoles("owner")).toEqual(["owner", "admin", "member", "guest"]); expect(grantableRoles("admin")).toEqual(["admin", "member", "guest"]); expect(grantableRoles("member")).toEqual(["member", "guest"]); }); });