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

+41 -3
View File
@@ -358,11 +358,49 @@ describe("plugin tab types in layouts", () => {
expect(snapshots.map((s) => s.type)).toEqual(["terminal"]);
});
it("leaves out a plugin tab type nobody registered", () => {
it("keeps a plugin tab type nobody registered, so a disabled plugin loses nothing", () => {
const { snapshots } = buildWorkspaceTabSnapshots([
makeTab({ id: "x", type: "some-plugin-tab" }),
makeTab({ id: "x", type: "some-plugin-tab", data: { a: 1 } }),
makeTab({ id: "d", type: "dashboard" }),
makeTab({ id: "h", type: "host-manager" }),
]);
expect(snapshots).toEqual([]);
expect(snapshots.map((s) => s.type)).toEqual(["some-plugin-tab"]);
expect(snapshotData(snapshots[0])).toEqual({ a: 1 });
});
it("reopens a hostless tab of a missing plugin as a placeholder", () => {
expect(
resolveWorkspaceTabTarget(
{ slotId: "s", type: "some-plugin-tab", label: "Gone" },
[],
),
).toEqual({ kind: "singleton" });
});
it("reopens a missing plugin's host tab while its host exists", () => {
const host = makeHost({ syncId: "sync-1" });
expect(
resolveWorkspaceTabTarget(
{
slotId: "s",
type: "some-plugin-tab",
label: "Gone",
hostSyncId: "sync-1",
},
[host],
),
).toEqual({ kind: "host", host });
expect(
resolveWorkspaceTabTarget(
{
slotId: "s",
type: "some-plugin-tab",
label: "Gone",
hostSyncId: "sync-deleted",
},
[host],
),
).toEqual({ kind: "skip" });
});
it("carries a tab's plugin data and reads the older fleetId field", () => {
+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"]);
});
});