swarm ui: the create form picks an archetype from tiles with their icons
An archetype's meta gets an optional icon, the SVG text (at most 16 KiB), which the controller checks, stores and serves on GET /api/archetypes. The built-in archetypes read theirs from nix/archetypes/icons. The create form shows each archetype as a tile with its icon and name, laid out like the broadcast screen's agent tiles, in place of the dropdown, and draws the SVG through an img data URL.
This commit is contained in:
parent
f8beca4e6a
commit
53224d877e
1 changed files with 240 additions and 16 deletions
|
|
@ -4,6 +4,7 @@ import assert from "node:assert/strict";
|
|||
import { test } from "node:test";
|
||||
import {
|
||||
archetypeKey,
|
||||
iconSrc,
|
||||
prefill,
|
||||
requestArchetype,
|
||||
} from "../src/pages/CreateAgentArchetype.ts";
|
||||
|
|
@ -83,3 +84,11 @@ test("a picked archetype is sent by source and name, none is left out", () => {
|
|||
});
|
||||
assert.equal(requestArchetype(undefined), undefined);
|
||||
});
|
||||
|
||||
test("an icon is a data URL of the SVG text, and none without text", () => {
|
||||
assert.equal(iconSrc(undefined), null);
|
||||
assert.equal(iconSrc(" \n"), null);
|
||||
const src = iconSrc('<svg viewBox="0 0 1 1"><script>x()</script></svg>');
|
||||
assert.ok(src.startsWith("data:image/svg+xml;charset=utf-8,%3Csvg"), src);
|
||||
assert.ok(!src.includes("<"), "the markup is percent-encoded");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue