swarm-ui: link an agent's forge profile and config repo from its overview
The agent card's overview gets a forge row with two links, built from the forge entry of the swarm's service links.
This commit is contained in:
parent
412c80d4ff
commit
e8e6150137
1 changed files with 129 additions and 2 deletions
41
frontend/packages/swarm-ui/test/forge-links.test.mjs
Normal file
41
frontend/packages/swarm-ui/test/forge-links.test.mjs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// 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",
|
||||
);
|
||||
});
|
||||
Loading…
Reference in a new issue