Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/forge-links.test.mjs
iris 356390befb swarm ui: the agent detail leaves out the config repo link for an archetype agent
An agent built from an archetype has no config repo on the forge, so the link
404ed. It shows again once the agent is turned into a custom one.
2026-11-11 01:48:37 +01:00

47 lines
1.6 KiB
JavaScript

// 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",
);
});
test("an agent without a config repo, one from an archetype, has no config link", () => {
const links = agentForgeLinks("https://forge.example", "iris", false);
assert.equal(links.configRepo, null);
assert.equal(links.profile, "https://forge.example/iris");
});