showDestroy and portal were each passed by one caller, the old card and the old table cell, and neither exists now. Two test headers still named the detail panel.
64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
// An opened agent card's allowed-domains editor: which entries one agent sees and
|
|
// the bodies it sends. Run by `npm test` with Node's type stripping.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import {
|
|
allowedSummary,
|
|
entriesFor,
|
|
entryBody,
|
|
} from "../src/agent/detail/allowed-domains.ts";
|
|
|
|
const all = [
|
|
{ domain: "crates.io", agent: "atlas" },
|
|
{ domain: "docs.rs", agent: "argus" },
|
|
{ domain: "github.com" },
|
|
{ domain: "pypi.org", agent: "atlas" },
|
|
];
|
|
|
|
test("an agent sees the swarm-wide entries first, then its own, and not another agent's", () => {
|
|
assert.deepEqual(entriesFor(all, "atlas"), [
|
|
{ domain: "github.com" },
|
|
{ domain: "crates.io", agent: "atlas" },
|
|
{ domain: "pypi.org", agent: "atlas" },
|
|
]);
|
|
// Control: the other agent's entry is there to be found.
|
|
assert.deepEqual(entriesFor(all, "argus"), [
|
|
{ domain: "github.com" },
|
|
{ domain: "docs.rs", agent: "argus" },
|
|
]);
|
|
assert.deepEqual(entriesFor(all, "iris"), [{ domain: "github.com" }]);
|
|
assert.deepEqual(entriesFor([], "atlas"), []);
|
|
});
|
|
|
|
test("the summary counts each scope", () => {
|
|
assert.equal(allowedSummary([]), "none added");
|
|
assert.equal(
|
|
allowedSummary(entriesFor(all, "atlas")),
|
|
"1 swarm-wide, 2 for this agent",
|
|
);
|
|
assert.equal(allowedSummary(entriesFor(all, "iris")), "1 swarm-wide");
|
|
assert.equal(
|
|
allowedSummary([{ domain: "a.io", agent: "atlas" }]),
|
|
"1 for this agent",
|
|
);
|
|
});
|
|
|
|
test("the body is swarm-wide or for the agent, with the name trimmed", () => {
|
|
assert.deepEqual(entryBody(" github.com ", true, "atlas"), {
|
|
domain: "github.com",
|
|
});
|
|
assert.deepEqual(entryBody("github.com", false, "atlas"), {
|
|
domain: "github.com",
|
|
agent: "atlas",
|
|
});
|
|
});
|
|
|
|
test("a derived entry is counted as automatic, not as the operator's own", () => {
|
|
const derived = { domain: "llm.example.com", agent: "atlas", derived: true };
|
|
assert.equal(
|
|
allowedSummary([...entriesFor(all, "atlas"), derived]),
|
|
"1 swarm-wide, 2 for this agent, 1 automatic",
|
|
);
|
|
assert.equal(allowedSummary([derived]), "1 automatic");
|
|
assert.deepEqual(entriesFor([derived], "atlas"), [derived]);
|
|
});
|