add a default archetype, preselected by the clients
This commit is contained in:
parent
a74d23d313
commit
8f7c45d40f
1 changed files with 253 additions and 47 deletions
|
|
@ -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, "");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue