@intentius/behold 0.29.18 → 0.29.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +15 -0
- package/dist/cli.js +615 -417
- package/package.json +1 -1
- package/web/kiosk-approval.js +4 -2
- package/web/kiosk-approval.test.js +2 -0
- package/web/kiosk-metrics.js +281 -0
- package/web/kiosk-metrics.test.js +94 -0
- package/web/kiosk-vendor.test.js +11 -5
- package/web/kiosk.html +115 -58
- package/web/kiosk.js +258 -73
- package/web/kiosk.test.js +105 -23
package/web/kiosk.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { INTRO_HEAD, STEP_VIEW, STEP_WORDS, aboutRows, approvalPanel, approveGloss, chantProject, focusRoots, introText, scenarioHead, frameSrc, factLines, kioskView,
|
|
2
|
+
import { BEAT_CHANGES, INTRO_HEAD, READ_STORE, READ_TITLE, STEP_VIEW, STEP_WORDS, aboutRows, approvalPanel, approveGloss, chantProject, factsLine, focusRoots, holdHead, holdModel, introText, readStored, readingRows, renderReading, scenarioHead, frameSrc, factLines, kioskView, matchingPull, pendingApproval, renderKiosk, renderViewToggle, reportless, runPanel, runPin, stepView, viewZoom } from "./kiosk.js";
|
|
3
3
|
import { VENDORS } from "./kiosk-vendor.js";
|
|
4
4
|
import { PICK_HOLD_MS } from "./kiosk-runs.js";
|
|
5
5
|
|
|
@@ -42,6 +42,25 @@ describe("focusRoots (#569)", () => {
|
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
describe("the hold panel (behold#571)", () => {
|
|
46
|
+
it("heads the panel with its wave, its run and its plan, else what its note is about", () => {
|
|
47
|
+
expect(holdHead({ wave: 2, run: 3605, digest: "jcs1-sha256:02812a1b9999" })).toBe("Wave 2 · run #3605 · plan 02812a1b");
|
|
48
|
+
expect(holdHead({ wave: 3 })).toBe("Wave 3");
|
|
49
|
+
expect(holdHead({ pull: 7 })).toBe("Pull request #7");
|
|
50
|
+
expect(holdHead({ commit: "abc12345ffff" })).toBe("Merge abc12345");
|
|
51
|
+
expect(holdHead({})).toBe(null);
|
|
52
|
+
});
|
|
53
|
+
it("holds how the hold ends, else the driver's approval, else the run's note, and nothing past that", () => {
|
|
54
|
+
const model = { wave: 2, digest: "sha256:02812a1b", run: 3605, rows: [] };
|
|
55
|
+
expect(holdModel({ approval: model }, demo("waiting"))).toMatchObject({ kind: "approval", wave: 2, head: "Wave 2 · run #3605 · plan 02812a1b" });
|
|
56
|
+
const p = progress([{ number: 2, state: "waiting", roots: ["app"], reads: [], digest: "jcs1-sha256:0accc105ba06" }]);
|
|
57
|
+
expect(holdModel({ progress: p }, demo("waiting", { next: { action: "approve wave-2", at: null } }))).toMatchObject({ kind: "driver", wave: 2, head: "Wave 2 · plan 0accc105" });
|
|
58
|
+
expect(holdModel({ answer: null, progress: null }, demo("planned", { pull: 989 }))).toEqual({ kind: "note", wave: null, head: "Pull request #989", lines: [{ cls: "k-note", text: "The pipeline is planning pull request #989." }] });
|
|
59
|
+
expect(holdModel({ noReports: true }, demo("planned"))).toBe(null);
|
|
60
|
+
expect(holdModel({ answer, progress: null }, demo("planned"))).toBe(null);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
45
64
|
describe("frameSrc (#569)", () => {
|
|
46
65
|
it("frames behold's own view, bare, told its host", () => {
|
|
47
66
|
expect(frameSrc("http://localhost:4700")).toBe("/?embed=1&bare=1&zoom=resources&host=http%3A%2F%2Flocalhost%3A4700");
|
|
@@ -51,6 +70,8 @@ describe("frameSrc (#569)", () => {
|
|
|
51
70
|
describe("factLines (#569)", () => {
|
|
52
71
|
it("says the pull request's totals and blast radius", () => {
|
|
53
72
|
expect(factLines(demo("planned"), answer)).toEqual(["pull request #7 changes across 3 roots: 3 update", "blast radius: app, edge, network", "unchanged: other"]);
|
|
73
|
+
// behold#571: the lead block shows them as one line.
|
|
74
|
+
expect(factsLine(demo("planned"), answer)).toBe("pull request #7 changes across 3 roots: 3 update · blast radius: app, edge, network · unchanged: other");
|
|
54
75
|
expect(factLines(demo("planned"), answer, "terragrunt")[0]).toBe("pull request #7 changes across 3 units: 3 update");
|
|
55
76
|
});
|
|
56
77
|
});
|
|
@@ -128,27 +149,37 @@ describe("the scenario's card under the title (behold#571)", () => {
|
|
|
128
149
|
const bar = document.createElement("header");
|
|
129
150
|
const s = { demo: { source: "fx", read: "2026-10-15T03:00:00Z", demo: demo("failed", { scenario: "failure", about }) }, answer: null, progress: null };
|
|
130
151
|
renderKiosk(bar, s, new Date("2026-10-15T03:01:00Z"));
|
|
131
|
-
const left = find(bar, "k-
|
|
132
|
-
// behold#571: the title, the
|
|
133
|
-
expect(left.children.map((c) => c.className
|
|
134
|
-
expect(left.children.map((c) => c.children.map((x) => x.className.split(" ")[0]))).toEqual([["k-title"], ["k-
|
|
152
|
+
const left = find(bar, "k-lead")[0];
|
|
153
|
+
// behold#571: the lead block: the title, the two beats (what changes, the step), the progress, the rest of the card, the facts; each box fixed.
|
|
154
|
+
expect(left.children.map((c) => c.className)).toEqual(["k-box k-box-title", "k-box k-box-beat", "k-box k-box-step", "k-progress", "k-box k-box-more", "k-box k-box-facts k-box-empty"]);
|
|
155
|
+
expect(left.children.map((c) => c.children.map((x) => x.className.split(" ")[0]))).toEqual([["k-title"], ["k-beat"], ["k-step"], ["k-strip", "k-next"], ["k-about"], []]);
|
|
156
|
+
const beat = find(bar, "k-beat")[0];
|
|
157
|
+
expect(beat.children.map((c) => [c.className, c.textContent])).toEqual([["k-beat-label", BEAT_CHANGES], ["k-beat-text", about.changes]]);
|
|
158
|
+
// The step's progress sits with the step line: the strip's stops, the driver's next action.
|
|
159
|
+
expect(find(bar, "k-stop").map((c) => c.textContent)).toEqual(["pull request", "planned", "merged", "waves", "applied", "reset"]);
|
|
160
|
+
// The rest of the card, one quieter paragraph: each field after its label.
|
|
135
161
|
const card = find(bar, "k-about")[0];
|
|
136
|
-
expect(card.tagName).toBe("
|
|
137
|
-
expect(card.children.map((c) => [c.
|
|
138
|
-
["
|
|
139
|
-
["
|
|
140
|
-
["dt", "Shows"], ["dd", about.shows],
|
|
162
|
+
expect(card.tagName).toBe("p");
|
|
163
|
+
expect(card.children.filter((c) => c.className).map((c) => [c.className, c.textContent])).toEqual([
|
|
164
|
+
["k-about-label", "Watch for"], ["k-about-text", about.watch],
|
|
165
|
+
["k-about-label", "Shows"], ["k-about-text", about.shows],
|
|
141
166
|
]);
|
|
142
167
|
|
|
143
168
|
s.demo.demo = demo("reset", { scenario: "base", about: null });
|
|
144
169
|
renderKiosk(bar, s, new Date("2026-10-15T03:01:00Z"));
|
|
145
170
|
expect(find(bar, "k-about")).toEqual([]);
|
|
171
|
+
expect(find(bar, "k-beat")).toEqual([]);
|
|
172
|
+
// Render what's present: the boxes with nothing in them draw no box.
|
|
173
|
+
expect(find(bar, "k-box-empty").map((c) => c.className)).toEqual(["k-box k-box-beat k-box-empty", "k-box k-box-more k-box-empty", "k-box k-box-facts k-box-empty"]);
|
|
174
|
+
// On the base, the hold panel holds the run's note, quiet, with no wave to light.
|
|
175
|
+
expect(find(bar, "k-box-hold")[0].className).toBe("k-box k-box-hold k-hold");
|
|
146
176
|
|
|
147
177
|
// behold#571: no intro band at a live step; between scenarios the intro takes the card's box.
|
|
148
178
|
const intro = "Terraform keeps what it built in a state file.";
|
|
149
179
|
s.demo.demo = demo("waiting", { scenario: "failure", about, intro });
|
|
150
180
|
renderKiosk(bar, s, new Date("2026-10-15T03:01:00Z"));
|
|
151
181
|
expect(find(bar, "k-intro")).toEqual([]);
|
|
182
|
+
expect(find(bar, "k-beat")).toHaveLength(1);
|
|
152
183
|
s.demo.demo = demo("reset", { scenario: "failure", about, intro });
|
|
153
184
|
renderKiosk(bar, s, new Date("2026-10-15T03:01:00Z"));
|
|
154
185
|
const shown = find(bar, "k-intro");
|
|
@@ -193,8 +224,9 @@ describe("the approval panel's drawing (behold#571)", () => {
|
|
|
193
224
|
],
|
|
194
225
|
};
|
|
195
226
|
const panel = approvalPanel(model, { showLine: (l) => shown.push(l) });
|
|
196
|
-
|
|
197
|
-
expect(
|
|
227
|
+
// behold#571: the wave, the run and the plan head the hold panel; the panel's own head says what its rows are.
|
|
228
|
+
expect(find(panel, "k-ap-head")[0].textContent).toBe("How this hold ends · times in UTC");
|
|
229
|
+
expect(holdHead({ wave: model.wave, run: 3605, digest: model.digest })).toBe("Wave 2 · run #3605 · plan 0accc105");
|
|
198
230
|
expect(find(panel, "k-ap-row").map((r) => r.className)).toEqual(["k-ap-row k-ap-lit", "k-ap-row k-ap-dim", "k-ap-row k-ap-dim", "k-ap-row k-ap-dim"]);
|
|
199
231
|
expect(find(panel, "k-ap-facts")[0].textContent).toBe("04:09:41 · ledger 57869649");
|
|
200
232
|
expect(find(panel, "k-command")[0].textContent).toBe("chant approve tf-apply wave-2");
|
|
@@ -244,21 +276,67 @@ describe("which view the frame shows (#571)", () => {
|
|
|
244
276
|
expect(viewZoom("nonsense")).toBe("resources");
|
|
245
277
|
});
|
|
246
278
|
|
|
247
|
-
it("says how to read the view shown", () => {
|
|
248
|
-
|
|
249
|
-
expect(
|
|
279
|
+
it("says how to read the view shown, a row per mark", () => {
|
|
280
|
+
const words = (v, t) => readingRows(v, t).map((r) => r.words).join(" ");
|
|
281
|
+
expect(readingRows("components").map((r) => r.mark)).toEqual(["card", "box", "solid", "dashed", "order", "marks"]);
|
|
282
|
+
expect(readingRows("resources").map((r) => r.mark)).toEqual(["box", "card", "solid", "dashed", "marks"]);
|
|
283
|
+
expect(readingRows("components")[0].words).toBe("Card: a Terraform root with its own state.");
|
|
284
|
+
expect(readingRows("components")[1].words).toBe("Box: a wave, titled with the job that applies it.");
|
|
285
|
+
expect(readingRows("resources")[0].words).toBe("Box: a Terraform root with its own state.");
|
|
286
|
+
expect(words("components")).toMatch(/Solid arrow: a read of applied outputs\. Dashed arrow: planned values, before they apply\./);
|
|
287
|
+
expect(words("components")).toMatch(/Marks: the forge and the tools a job runs/);
|
|
288
|
+
// Short items, so two to a line keep the open frame a few lines tall.
|
|
289
|
+
for (const v of ["components", "resources"]) for (const r of readingRows(v, "terragrunt")) expect(r.words.length, r.words).toBeLessThanOrEqual(50);
|
|
250
290
|
// behold#571: a Terragrunt scenario names its units.
|
|
251
291
|
for (const v of ["components", "resources"]) {
|
|
252
|
-
const
|
|
253
|
-
expect(
|
|
254
|
-
expect(
|
|
255
|
-
expect(words).not.toMatch(/\broots?\b/);
|
|
292
|
+
const w = words(v, "terragrunt");
|
|
293
|
+
expect(w).toMatch(/a Terragrunt unit with its own state/);
|
|
294
|
+
expect(w).not.toMatch(/\broots?\b/);
|
|
256
295
|
}
|
|
296
|
+
expect(words("components", "terragrunt")).toMatch(/Waves apply in order, units in a wave together/);
|
|
257
297
|
// A tool whose pipeline writes no reports: behold's own components graph, with no jobs or planned values in it.
|
|
258
|
-
expect(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
298
|
+
expect(readingRows("components", "chant")).toEqual([
|
|
299
|
+
{ mark: "card", words: "Card: a Terraform root with its own state." },
|
|
300
|
+
{ mark: "box", words: "Box: a wave of components that apply together." },
|
|
301
|
+
{ mark: "solid", words: "Arrow: a component reading another's outputs." },
|
|
302
|
+
]);
|
|
303
|
+
expect(readingRows("resources", "chant")).toEqual([{ mark: "box", words: "Box: a Terraform root with its own state." }]);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it("draws 'How to read this' as a header that folds the rows, and keeps the viewer's fold", () => {
|
|
307
|
+
const was = globalThis.document;
|
|
308
|
+
globalThis.document = { createElement: (tag) => {
|
|
309
|
+
const n = { tagName: tag, className: "", textContent: "", children: [], attrs: {}, listeners: {} };
|
|
310
|
+
n.appendChild = (c) => (n.children.push(c), c);
|
|
311
|
+
n.append = (...cs) => cs.forEach((c) => n.children.push(c));
|
|
312
|
+
n.replaceChildren = () => (n.children = []);
|
|
313
|
+
n.setAttribute = (k, v) => (n.attrs[k] = v);
|
|
314
|
+
n.addEventListener = (k, f) => (n.listeners[k] = f);
|
|
315
|
+
return n;
|
|
316
|
+
} };
|
|
317
|
+
try {
|
|
318
|
+
const host = document.createElement("section");
|
|
319
|
+
const toggled = [];
|
|
320
|
+
renderReading(host, "components", null, { open: true, onToggle: (o) => toggled.push(o) });
|
|
321
|
+
expect(host.hidden).toBe(false);
|
|
322
|
+
expect(host.children.map((c) => c.className)).toEqual(["k-read-head", "k-read-rows"]);
|
|
323
|
+
expect(host.children[0].textContent).toBe(READ_TITLE);
|
|
324
|
+
expect(host.children[1].children.map((li) => li.children[0].className)).toEqual(["k-read-mark k-read-card", "k-read-mark k-read-box", "k-read-mark k-read-solid", "k-read-mark k-read-dashed", "k-read-mark k-read-order", "k-read-mark k-read-marks"]);
|
|
325
|
+
host.children[0].listeners.click();
|
|
326
|
+
expect(toggled).toEqual([false]);
|
|
327
|
+
// Folded, the header stays as its one line.
|
|
328
|
+
renderReading(host, "components", null, { open: false });
|
|
329
|
+
expect(host.children.map((c) => c.className)).toEqual(["k-read-head"]);
|
|
330
|
+
expect(host.children[0].attrs["aria-expanded"]).toBe("false");
|
|
331
|
+
} finally {
|
|
332
|
+
globalThis.document = was;
|
|
333
|
+
}
|
|
334
|
+
const store = (v) => ({ getItem: (k) => (k === READ_STORE ? v : null) });
|
|
335
|
+
expect(readStored(store("open"))).toBe(true);
|
|
336
|
+
expect(readStored(store("closed"))).toBe(false);
|
|
337
|
+
expect(readStored(store(null))).toBe(null);
|
|
338
|
+
expect(readStored({ getItem: () => { throw new Error("blocked"); } })).toBe(null);
|
|
339
|
+
expect(readStored(null)).toBe(null);
|
|
262
340
|
});
|
|
263
341
|
|
|
264
342
|
it("knows a tool whose pipeline writes no terragucci reports, and a chant project behold draws itself", () => {
|
|
@@ -383,6 +461,10 @@ describe("the kiosk for a viewer new to the demo (behold#571)", () => {
|
|
|
383
461
|
const card = find(bar, "k-approve")[0];
|
|
384
462
|
expect(card.children.map((c) => c.className)).toEqual(["k-approve-gloss", "k-command", "k-approve-then"]);
|
|
385
463
|
expect(card.children[1].textContent).toBe("chant approve tf-apply wave-2 --actor <reviewer> --sign <reviewer key>");
|
|
464
|
+
// behold#571: the hold panel is headed with its wave and plan, and lit as its wave's job row is.
|
|
465
|
+
const hold = find(bar, "k-box-hold")[0];
|
|
466
|
+
expect(hold.className).toBe("k-box k-box-hold k-hold k-hold-wave");
|
|
467
|
+
expect(hold.children[0].textContent).toBe("Wave 2 · plan 0accc105");
|
|
386
468
|
} finally {
|
|
387
469
|
globalThis.document = was;
|
|
388
470
|
}
|