// Where an agent lives on the swarm's forge: its profile and config repo, from // the forge entry of the swarm's service links. Run by `npm test` with Node's // type stripping. import assert from "node:assert/strict"; import { test } from "node:test"; import { agentForgeLinks, forgeBase } from "../src/agent/detail/forge-links.ts"; const link = (label, url) => ({ label, icon: "x", url }); test("the forge base is the forge entry's URL, any case, without a trailing slash", () => { assert.equal( forgeBase([ link("Grafana", "https://grafana.example/"), link("Forge", "https://forge.example/"), ]), "https://forge.example", ); assert.equal( forgeBase([link("forge", "https://forge.example")]), "https://forge.example", ); }); test("no forge entry gives no base", () => { assert.equal(forgeBase([]), null); assert.equal(forgeBase([link("Grafana", "https://grafana.example/")]), null); }); test("an agent's profile and config repo sit under the forge base", () => { assert.deepEqual(agentForgeLinks("https://forge.example", "iris"), { profile: "https://forge.example/iris", configRepo: "https://forge.example/agent-configs/iris", }); }); test("the agent name is encoded", () => { assert.equal( agentForgeLinks("https://forge.example", "a b").profile, "https://forge.example/a%20b", ); });