// Where the hive dashboard's agent rows lead. Run by `npm test`. import assert from "node:assert/strict"; import { test } from "node:test"; import { agentPageUrl, loginPageUrl } from "../../dashboard/src/agent-page.js"; test("an agent's name leads to its terminal in the swarm UI", () => { const state = { swarm_public_url: "https://swarm.example" }; assert.equal( agentPageUrl(state, "iris"), "https://swarm.example/agents/iris/terminal", ); }); test("a trailing slash on the swarm address makes no double slash", () => { const state = { swarm_public_url: "https://swarm.example/" }; assert.equal( agentPageUrl(state, "iris"), "https://swarm.example/agents/iris/terminal", ); assert.equal(loginPageUrl(state), "https://swarm.example/agents"); }); test("a name is escaped into the path", () => { const state = { swarm_public_url: "https://swarm.example" }; assert.equal( agentPageUrl(state, "a b/c"), "https://swarm.example/agents/a%20b%2Fc/terminal", ); }); test("a hive without a swarm domain has no page to link", () => { for (const state of [ null, undefined, {}, { swarm_public_url: null }, { swarm_public_url: "" }, ]) { assert.equal(agentPageUrl(state, "iris"), null); assert.equal(loginPageUrl(state), null); } });