Fork Horse repository, listed by its owner. Publisher snapshot.

packages/forkhorse-dashboard/test/frame-controls.test.ts

Snapshot at 34e3175

Containing directory

1,667 bytes · typescriptView raw
1import { installDom } from "./dom.ts";
2import assert from "node:assert/strict";
3import { createRequire } from "node:module";
4import { test } from "node:test";
5import { mountDashboard } from "../src/dashboard.ts";
6import { fixtureState } from "./fixtures.ts";
7import { stateView } from "../src/model.ts";
8import { queryByRole } from "./roles.ts";
9
10const { JSDOM } = createRequire(import.meta.url)("jsdom");
11test("owner dashboard never renders agent banner, owner-link action or frame control", (t) => {
12  const dom = new JSDOM('<div id="root"></div>');
13  installDom(dom.window);
14  const root = dom.window.document.getElementById("root") as HTMLElement;
15  let calls = 0;
16  const view = mountDashboard(root, {
17    brand: { name: "Fixture product", tagline: "Fixture collaboration" },
18    initialProject: "demo", owner: true,
19    // Even accidental host metadata must not add these controls to the owner surface.
20    ownerLink: "https://core.fixture.idiot.tax/app?project=demo",
21    framePresentation: {
22      getSnapshot: () => false,
23      subscribe: () => () => {},
24      toggle: () => { calls++; },
25      reset: () => { calls++; },
26    },
27    transport: {
28      getState: async () => stateView(fixtureState()),
29      getActivity: async () => ({ activity: [], nextAfter: 0 }),
30      approve: async () => {},
31      promote: async () => ({ sha: "fixture" }),
32    },
33  });
34  t.after(() => { view.dispose(); dom.window.close(); });
35  assert.equal(queryByRole(root, "button", { name: "Expand" }), null);
36  assert.equal(queryByRole(root, "button", { name: "Copy owner link" }), null);
37  assert.equal(root.querySelector(".agent-notice"), null);
38  assert.equal(calls, 0);
39});
40