feat: rebuild workspaces as the reference plugin

This commit is contained in:
LukeGus committed 2026-09-23 07:04:03 -05:00
1 parent d774df8b41
commit f217d8db89
79 files changed
+32995 -2184

No files matched your search

+37
View File
@@ -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"]);
});
});