hive dashboard: an agent's name links to its terminal in the swarm UI
This commit is contained in:
parent
ccac38995d
commit
8ca6317356
1 changed files with 97 additions and 15 deletions
|
|
@ -0,0 +1,42 @@
|
|||
// 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);
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue