// Shared setup for the vector tests: install the stubbed DOM (the SAME module
// the fixture generator used, so a diff is a real diff), lay out the shell the
// renderers look for, then load the compiled testlib.
//
// Order matters: home.i18n hydrates the static markup at namespace load, so the
// document has to exist before the import.
import { readFileSync } from "node:fs";
import { installDom, serialize, h, flush } from "./dom-stub.mjs";
export { serialize, h, flush };
export function shell(env) {
const body = env.body;
body.replaceChildren();
const nav = h("nav", { id: "tabs", "aria-label": "sections", "data-i18n-attr": "aria-label:nav.aria" });
for (const [href, key, text] of [
["#/apps", "nav.apps", "apps"],
["#/about", "nav.about", "why"],
["#/you", "nav.you", "you"],
["#/boards", "nav.boards", "boards"],
["#/bots", "nav.bots", "bots"],
]) {
const a = h("a", { href, "data-i18n": key });
a.textContent = text;
nav.appendChild(a);
}
body.appendChild(nav);
const views = {};
for (const v of ["apps", "about", "you", "boards", "bots"]) {
views[v] = h("section", { class: "view", id: `view-${v}` });
body.appendChild(views[v]);
}
views.apps.appendChild(h("div", { class: "apps" }));
views.you.append(
h("section", { class: "id-card", id: "identity" }),
h("section", { class: "soc", id: "social" }),
h("section", { class: "soc on", id: "you-lang" }),
);
views.boards.appendChild(h("section", { class: "soc", id: "lb" }));
views.bots.appendChild(h("section", { class: "soc", id: "bots" }));
body.appendChild(h("span", { id: "footer-lang" }));
return views;
}
/** installDom + shell + the compiled testlib, in the one order that works. */
export async function boot(opts = {}) {
const env = installDom(opts);
const views = shell(env);
const lib = await import("../test-dist/testlib.js");
return { env, views, lib };
}
export function vectors(name) {
return JSON.parse(readFileSync(new URL(`./vectors/${name}.json`, import.meta.url), "utf8"));
}