Watch
0
0
Fork
You've already forked hyperhive
0

add a default archetype, preselected by the clients

This commit is contained in:
atlas 2026-11-27 17:41:52 +01:00 • committed by mara
commit 8f7c45d40f

View file

@ -5,6 +5,8 @@ import { test } from "node:test";
import {
archetypeKey,
iconSrc,
openingKey,
pickerTiles,
prefill,
requestArchetype,
} from "../src/pages/CreateAgentArchetype.ts";
@ -81,7 +83,7 @@ test("the key tells sources apart", () => {
);
});
test("a picked archetype is sent by source and name, none is left out", () => {
test("a picked archetype is sent by source and name, none (a custom agent) is left out", () => {
const reviewer = {
source: "hyperhive",
name: "reviewer",
@ -102,3 +104,38 @@ test("an icon is a data URL of the SVG text, and none without text", () => {
assert.ok(src.startsWith("data:image/svg+xml;charset=utf-8,%3Csvg"), src);
assert.ok(!src.includes("<"), "the markup is percent-encoded");
});
const listed = (...names) =>
names.map((name) => ({ source: "hyperhive", name, description: "d" }));
test("the form opens on default once the list has it, and on none otherwise", () => {
assert.equal(openingKey(null), null);
assert.equal(
openingKey(listed("reviewer", "default")),
archetypeKey({ source: "hyperhive", name: "default", description: "d" }),
);
// An older controller or builder lists no default: a custom agent, as before.
assert.equal(openingKey(listed("reviewer", "ruth")), "");
assert.equal(openingKey([]), "");
// A `default` from another source is not the built-in one.
assert.equal(
openingKey([{ source: "other", name: "default", description: "d" }]),
"",
);
});
test("the tiles are default, then none, then the rest in list order", () => {
const names = (list) => pickerTiles(list).map((t) => t.name);
assert.deepEqual(names(listed("reviewer", "default", "ruth")), [
"default",
"none",
"reviewer",
"ruth",
]);
assert.deepEqual(names(listed("reviewer", "ruth")), [
"none",
"reviewer",
"ruth",
]);
assert.equal(pickerTiles(listed("default"))[1].key, "");
});