// The detail panel's permissions editor: its starting selection and the // summary line. Run by `npm test` with Node's type stripping. import assert from "node:assert/strict"; import { test } from "node:test"; import { editorSelection, grantSummary, } from "../src/agent/detail/permissions.ts"; const all = ["messaging", "meta", "inbox", "execution", "manage_root_agent"]; const defaults = ["messaging", "meta", "inbox", "execution"]; test("an agent the swarm sets nothing for starts on the default set", () => { assert.deepEqual(editorSelection(undefined, all, defaults), defaults); }); test("a stored list is the starting selection, empty included", () => { assert.deepEqual( editorSelection(["meta", "manage_root_agent"], all, defaults), ["meta", "manage_root_agent"], ); assert.deepEqual(editorSelection([], all, defaults), []); }); test("a stored name the catalogue does not list is not offered", () => { assert.deepEqual(editorSelection(["meta", "retired"], all, defaults), [ "meta", ]); }); test("the summary tells unset, empty and a list apart", () => { assert.equal(grantSummary(undefined), "the default set"); assert.equal(grantSummary([]), "none"); assert.equal(grantSummary(["meta", "inbox"]), "2 granted"); });