mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 06:35:24 +00:00
feat: rebuild workspaces as the reference plugin
This commit is contained in:
1 parent
d774df8b41
commit
f217d8db89
79 files changed
+32995
-2184
No files matched your search
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
import { Boxes } from "lucide-react";
|
||||
import {
|
||||
hideableRailIds,
|
||||
permittedRailItems,
|
||||
promotableIds,
|
||||
RAIL_ITEMS,
|
||||
RAIL_UTILITY_ITEMS,
|
||||
@@ -230,3 +231,39 @@ describe("railItemLabel", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("permittedRailItems", () => {
|
||||
const items = [
|
||||
{ id: "open", icon: Boxes, labelKey: "nav.hosts" },
|
||||
{
|
||||
id: "gated",
|
||||
icon: Boxes,
|
||||
labelKey: "nav.hosts",
|
||||
permission: "demo.use",
|
||||
},
|
||||
];
|
||||
|
||||
it("hides an item gated on a permission the user lacks", () => {
|
||||
const ids = permittedRailItems(items, {
|
||||
loaded: true,
|
||||
has: () => false,
|
||||
}).map((item) => item.id);
|
||||
expect(ids).toEqual(["open"]);
|
||||
});
|
||||
|
||||
it("shows it once the user holds the permission", () => {
|
||||
const ids = permittedRailItems(items, {
|
||||
loaded: true,
|
||||
has: (permission) => permission === "demo.use",
|
||||
}).map((item) => item.id);
|
||||
expect(ids).toEqual(["open", "gated"]);
|
||||
});
|
||||
|
||||
it("keeps gated items hidden until permissions have loaded", () => {
|
||||
const ids = permittedRailItems(items, {
|
||||
loaded: false,
|
||||
has: () => true,
|
||||
}).map((item) => item.id);
|
||||
expect(ids).toEqual(["open"]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user