"use strict";
const test = require("node:test");
const assert = require("node:assert/strict");
const { lowerSurfaceToHtml, neutraliseCommandControls } = require("../src/static-lowering.cjs");
function surfaceWith(children) {
return {
providerId: "erycina",
title: "Erycina Operator",
surface: {
schema: "gamecult.eve.surface.v1",
id: "erycina-operator-surface",
title: "Erycina Operator",
root: { id: "root", kind: "dashboard", props: { title: "Erycina" }, children },
},
};
}
const panel = {
id: "readiness",
kind: "panel",
props: { title: "Readiness" },
// "metric" is the kind Erycina real surface uses for a labelled value.
// The renderer silently drops kinds it does not know, so a fixture that
// invents one tests nothing.
children: [{ id: "manifest", kind: "metric", props: { label: "Manifest", value: "present" } }],
};
const commandButton = {
id: "run-ingest",
kind: "control.button",
props: { label: "Run ingest", command: "erycina.ingest.run", target: "cultmesh://erycina/commands/ingest" },
};
test("a surface lowers to a standalone document", async () => {
const { html, title } = await lowerSurfaceToHtml(surfaceWith([panel]));
assert.equal(title, "Erycina Operator");
assert.match(html, /^/);
assert.match(html, //);
assert.match(html, /<\/html>\s*$/);
// Content the graph declared actually reaches the page.
assert.match(html, /Readiness/);
assert.match(html, /Manifest/);
});
test("styles are inlined, so the page needs no second request", async () => {
const { html } = await lowerSurfaceToHtml(surfaceWith([panel]));
assert.match(html, /