@intentius/behold 0.29.42 → 0.29.44

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.
Files changed (68) hide show
  1. package/AGENTS.md +77 -0
  2. package/dist/cli.js +3969 -1918
  3. package/package.json +1 -1
  4. package/web/app.js +1463 -80
  5. package/web/carve-narration.js +33 -1
  6. package/web/chant-live-pace.js +138 -0
  7. package/web/chant-live-pace.test.js +116 -0
  8. package/web/chant-pr-marks.js +417 -39
  9. package/web/chant-pr-marks.test.js +208 -4
  10. package/web/collision-marks.js +124 -0
  11. package/web/collision-marks.test.js +89 -0
  12. package/web/cone.js +269 -0
  13. package/web/cone.test.js +213 -0
  14. package/web/dots-cards.js +362 -0
  15. package/web/dots-cards.test.js +303 -0
  16. package/web/dots-live.test.js +151 -1
  17. package/web/dots-lod.js +20 -0
  18. package/web/dots-lod.test.js +19 -1
  19. package/web/dots-scene.js +110 -10
  20. package/web/dots.js +489 -87
  21. package/web/embed.js +17 -1
  22. package/web/embed.test.js +19 -1
  23. package/web/event-help-modal.js +85 -3
  24. package/web/event-help-modal.test.js +85 -1
  25. package/web/feature-flags.js +143 -0
  26. package/web/feature-flags.test.js +96 -0
  27. package/web/index.html +33 -0
  28. package/web/kiosk-carve.js +59 -6
  29. package/web/kiosk-event-help-ui.js +150 -19
  30. package/web/kiosk-event-help.js +102 -15
  31. package/web/kiosk-event-help.test.js +58 -1
  32. package/web/kiosk-metrics.js +4 -3
  33. package/web/kiosk-runs.js +8 -5
  34. package/web/kiosk-shot.js +157 -3
  35. package/web/kiosk-shot.test.js +223 -1
  36. package/web/kiosk-source.js +43 -0
  37. package/web/kiosk-source.test.js +39 -0
  38. package/web/kiosk-story-gate.test.js +44 -0
  39. package/web/kiosk-track.js +312 -0
  40. package/web/kiosk-track.test.js +148 -0
  41. package/web/kiosk-unknown-step.test.js +58 -0
  42. package/web/kiosk-vendor.js +71 -4
  43. package/web/kiosk-vendor.test.js +103 -3
  44. package/web/kiosk-watch.js +154 -1
  45. package/web/kiosk-watch.test.js +53 -1
  46. package/web/kiosk.html +57 -22
  47. package/web/kiosk.js +566 -53
  48. package/web/kiosk.test.js +2 -1
  49. package/web/small-stage.test.js +150 -0
  50. package/web/terragucci-blocked.test.js +192 -0
  51. package/web/terragucci-change.js +197 -17
  52. package/web/terragucci-components-live.js +189 -13
  53. package/web/terragucci-live-pace.js +92 -0
  54. package/web/terragucci-wave-results.test.js +125 -0
  55. package/web/terralith.html +7 -7
  56. package/web/tg-outside.js +124 -0
  57. package/web/tg-outside.test.js +100 -0
  58. package/web/tg-read-pills.js +122 -0
  59. package/web/tg-read-pills.test.js +117 -0
  60. package/web/theme.js +13 -1
  61. package/web/theme.test.js +21 -1
  62. package/web/tooltip.js +19 -7
  63. package/web/tooltip.test.js +15 -0
  64. package/web/tours/terralith.json +4 -4
  65. package/web/trunk-lane.test.js +1 -1
  66. package/web/view-url.js +8 -2
  67. package/web/why.js +129 -1
  68. package/web/why.test.js +113 -1
@@ -1,7 +1,8 @@
1
1
  // behold#571: Watch mode's camera, as arithmetic: where a shot puts its
2
2
  // target, how a move goes, and which messages the frame takes.
3
3
  import { describe, expect, it } from "vitest";
4
- import { SHOT_MS, ease, sameViewBox, shotFromMessage, shotMessage, shotViewBox, tweenViewBox, unionBox } from "./kiosk-shot.js";
4
+ import { HELD_CAPTION_PX, HELD_FILL, HELD_MAX_SCALE, HELD_PAD, HOLD_RESERVE_PX, SHOT_MS, SMALL_STAGE_CARD_PX, ease, heldFrame, heldInsets, heldTarget, holdsStage, medianWidth, sameViewBox, shotFromMessage, shotMessage, shotViewBox, smallStage, tweenViewBox, unionBox } from "./kiosk-shot.js";
5
+ import { captionRoom, shotFor } from "./kiosk-watch.js";
5
6
 
6
7
  const pane = { width: 1600, height: 900 };
7
8
 
@@ -77,3 +78,224 @@ describe("kiosk shot: the messages", () => {
77
78
  expect(shotFromMessage({ origin: host, data: { type: "behold:shot", release: true } }, host)).toEqual({ type: "behold:shot", release: true });
78
79
  });
79
80
  });
81
+
82
+
83
+
84
+ // One framing on a small stage: three roots' cards in two wave boxes, at the kiosk's 1280 x 800, as web/app.js
85
+ // kioskShotBox frames it (heldTarget, heldInsets, heldFrame, the tab's session storage between frames). Nothing a
86
+ // step shows sits over the graph in Watch, so the graph has the stage's whole width less the margins.
87
+ describe("one framing on a small stage", () => {
88
+ const pane = { width: 1280, height: 720 };
89
+ const key = "demo-cone|components";
90
+ const boxes = [{ x: 0, y: 0, x2: 240, y2: 110 }, { x: 300, y: 0, x2: 620, y2: 110 }];
91
+ const cards = [{ x: 20, y: 30, x2: 220, y2: 95 }, { x: 320, y: 30, x2: 460, y2: 95 }, { x: 470, y: 30, x2: 600, y2: 95 }];
92
+ const whole = heldTarget(boxes, cards);
93
+ const STEPS = ["pull-request", "planned", "merged", "applying", "waiting", "approved", "applied", "reset"];
94
+ const demo = (cycle, step) => ({ cycle, scenario: "cone", step, label: "", started_at: "2026-10-17T10:00:00Z", pull: cycle, commit: step === "pull-request" || step === "planned" ? "2222222" : "3333333" });
95
+ /**
96
+ * What the kiosk's shot carries at each step (web/kiosk.js shotInsets): the caption under the stage, taller with
97
+ * the cone line at planned, the quiet line at the waves and the approval, the counts at applied, and event-help's
98
+ * trail over it as the cycle's beats come in. The right inset is a drawer the viewer opened on a wave at applying.
99
+ * The merge frame's pane is half a pixel off the plan frame's.
100
+ */
101
+ const shot = (step) => {
102
+ const trail = { "pull-request": 0, planned: 0, merged: 22, applying: 22, waiting: 44, approved: 44, applied: 44, reset: 0 }[step];
103
+ const lines = { planned: 22, applying: 20, waiting: 20, applied: 20 }[step] || 0;
104
+ const caption = 150 + lines + trail;
105
+ const right = step === "applying" ? Math.round(0.46 * 1280) + 44 : 0;
106
+ return { insets: { top: 20, right, bottom: caption + 16, left: 20 }, pane: step === "merged" || step === "applying" ? { width: 1280, height: 719.5 } : pane };
107
+ };
108
+
109
+ it("counts the stage small when the whole graph draws its cards readably, and a big graph not", () => {
110
+ expect(smallStage(whole, pane, heldInsets({ bottom: 192 }), 140)).toBe(true);
111
+ // 60 roots in a row: the whole graph is a strip of specks.
112
+ expect(smallStage({ x: 0, y: 0, x2: 60 * 220, y2: 500 }, pane, { bottom: 176 }, 180)).toBe(false);
113
+ expect(smallStage(whole, pane, {}, 0)).toBe(false);
114
+ expect(SMALL_STAGE_CARD_PX).toBe(90);
115
+ expect(medianWidth([180, 0, 175, 190])).toBe(180);
116
+ });
117
+
118
+ it("holds one viewBox through every step of three cycles, across the frames the kiosk swaps in", () => {
119
+ let stored = null;
120
+ const seen = [];
121
+ for (const cycle of [111, 112, 113]) {
122
+ for (const step of STEPS) {
123
+ expect(typeof shotFor(demo(cycle, step), {}).id).toBe("string");
124
+ const { insets, pane: p } = shot(step);
125
+ const held = stored ? JSON.parse(stored) : null;
126
+ // The kiosk measures the caption's tallest (kiosk-watch.js captionRoom) and sends it with every shot: 150 px, two extra rows, the trail at two lines, 16.
127
+ const ins = heldInsets(insets, 150 + 2 * 22 + 2 * 26 + 16);
128
+ expect(smallStage(whole, p, held ? held.insets : ins, 140)).toBe(true);
129
+ // A frame drawn from another checkout lays the boxes a few units off.
130
+ const target = step === "merged" ? { x: 2, y: 1, x2: 621, y2: 109 } : whole;
131
+ const next = heldFrame(held, { key, pane: p, insets: ins, target });
132
+ stored = JSON.stringify(next);
133
+ seen.push(next);
134
+ }
135
+ }
136
+ expect(seen).toHaveLength(24);
137
+ expect(seen.map((h) => h.reason)).toEqual(["first", ...Array(23).fill("held")]);
138
+ for (const h of seen) expect(sameViewBox(h.vb, seen[0].vb)).toBe(true);
139
+ const [x, y, w, h] = seen[0].vb;
140
+ const s = pane.width / w;
141
+ // Every box stays in view, clear of the tallest caption and of the run's caption at the top.
142
+ expect(x <= whole.x && x + w >= whole.x2).toBe(true);
143
+ expect(y + (20 + HELD_CAPTION_PX) / s <= whole.y + 36).toBe(true);
144
+ expect(y + h - (150 + 22 + 44 + 16) / s >= whole.y2).toBe(true);
145
+ });
146
+
147
+ it("would have moved at the merge with a step's own card at the right, the 48 px reserve and an exact pane", () => {
148
+ // Round 3's inputs: the shot's right inset growing at the waves, and the trail's growth past 48 px.
149
+ const a = heldFrame(null, { key, pane, insets: { top: 52, right: 450, bottom: 166 }, target: whole });
150
+ const b = heldFrame(a, { key, pane: { width: 1280, height: 719.5 }, insets: { top: 52, right: 454, bottom: 166 + 70 }, target: whole });
151
+ expect(b.reason).toBe("insets");
152
+ const ha = heldFrame(null, { key, pane, insets: heldInsets({ top: 20, bottom: 166, left: 20 }, 262), target: whole });
153
+ const hb = heldFrame(ha, { key, pane: { width: 1280, height: 719.5 }, insets: heldInsets({ top: 20, right: 454, bottom: 166 + 70, left: 20 }, 262), target: whole });
154
+ expect(hb.reason).toBe("held");
155
+ expect(sameViewBox(hb.vb, ha.vb)).toBe(true);
156
+ });
157
+
158
+ it("frames again for another repo or view, or a resized pane, and never for an overlay it kept room for", () => {
159
+ const a = heldFrame(null, { key, pane, insets: { bottom: 150 }, target: whole });
160
+ expect(heldFrame(a, { key, pane, insets: { bottom: 150 + HOLD_RESERVE_PX }, target: whole }).reason).toBe("held");
161
+ expect(heldFrame(a, { key: "demo-cone|resources", pane, insets: { bottom: 150 }, target: whole }).reason).toBe("key");
162
+ expect(heldFrame(a, { key, pane: { width: 1200, height: 720 }, insets: { bottom: 150 }, target: whole }).reason).toBe("pane");
163
+ expect(heldFrame(a, { key, pane, insets: { bottom: 150 }, target: { ...whole, x2: 2400 } }).reason).toBe("target");
164
+ });
165
+
166
+ it("keeps no card's room at the side: the right margin is the left's, whatever the shot says", () => {
167
+ expect(heldInsets({ top: 20, right: 600, bottom: 160, left: 20 })).toEqual({ top: 20 + HELD_CAPTION_PX, right: 20, bottom: 160, left: 20 });
168
+ expect(shotMessage({ whole: true })).not.toHaveProperty("dock");
169
+ expect(shotFromMessage({ origin: "https://k", data: { type: "behold:shot", whole: true, dock: 450 } }, "https://k")).not.toHaveProperty("dock");
170
+ });
171
+ });
172
+
173
+ // Round 5, cycles 111-112: the held framing used a third of the stage (two wave boxes about 220 x 100 px in
174
+ // 1280 x 800). Round 6: with nothing at the side, it fills the stage less the caption and the margins.
175
+ describe("a held small stage fills the stage", () => {
176
+ const pane = { width: 1280, height: 760 };
177
+ const ins = heldInsets({ top: 20, bottom: 192, left: 20 });
178
+ const boxes = [{ x: 0, y: 0, x2: 240, y2: 110 }, { x: 300, y: 0, x2: 620, y2: 110 }];
179
+ const cards = [{ x: 20, y: 30, x2: 220, y2: 95 }, { x: 320, y: 30, x2: 460, y2: 95 }, { x: 470, y: 30, x2: 600, y2: 95 }];
180
+ // A box round every box (a member's, the page's) and a mark far off the graph are not what it spans.
181
+ const outer = { x: -400, y: -200, x2: 1600, y2: 900 };
182
+
183
+ it("frames the innermost boxes that hold the cards, and the cards", () => {
184
+ expect(heldTarget([...boxes, outer], cards)).toEqual({ x: 0, y: 0, x2: 620, y2: 110 });
185
+ expect(heldTarget([{ x: 2000, y: 2000, x2: 2100, y2: 2100 }, ...boxes], cards)).toEqual({ x: 0, y: 0, x2: 620, y2: 110 });
186
+ expect(heldTarget(boxes, [])).toBeNull();
187
+ });
188
+
189
+ it("zooms in as far as the stage area allows, so the boxes fill its width", () => {
190
+ const target = heldTarget([...boxes, outer], cards);
191
+ const h = heldFrame(null, { key: "demo-cone|components", pane, insets: ins, target });
192
+ const s = pane.width / h.vb[2];
193
+ const openW = pane.width - ins.left - ins.right;
194
+ const openH = pane.height - ins.top - (ins.bottom + HOLD_RESERVE_PX);
195
+ expect(Math.max(((target.x2 - target.x + 72) * s) / openW, ((target.y2 - target.y + 72) * s) / openH)).toBeGreaterThan(0.98);
196
+ expect(s).toBeGreaterThan(1.7);
197
+ expect(s).toBeLessThanOrEqual(HELD_MAX_SCALE);
198
+ // apply-wave-2's box is about 2.5 times the 220 px it was.
199
+ expect((boxes[1].x2 - boxes[1].x) * s).toBeGreaterThan(550);
200
+ });
201
+
202
+ it("a framing kept from before, wider than the graph needs, frames again once to fill, then holds", () => {
203
+ const target = heldTarget(boxes, cards);
204
+ const wide = heldFrame(null, { key: "demo-cone|components", pane, insets: ins, target: { x: -180, y: -13, x2: 1222, y2: 826 } });
205
+ const filled = heldFrame(JSON.parse(JSON.stringify(wide)), { key: "demo-cone|components", pane, insets: ins, target });
206
+ expect(filled.reason).toBe("fill");
207
+ expect(filled.vb[2]).toBeLessThan(wide.vb[2] * HELD_FILL);
208
+ expect(heldFrame(filled, { key: "demo-cone|components", pane, insets: ins, target }).reason).toBe("held");
209
+ });
210
+ });
211
+
212
+ describe("which stage may be held", () => {
213
+ it("an estate whose every root runs on choudoufu; b-waves, failure and tg-planned-outputs (tofu) keep a shot per step", () => {
214
+ expect(holdsStage({ network: "choudoufu", "service-a": "choudoufu", "service-b": "choudoufu" })).toBe(true);
215
+ expect(holdsStage({ network: "tofu", app: "tofu", edge: "tofu" })).toBe(false);
216
+ expect(holdsStage({ network: "choudoufu", app: "tofu" })).toBe(false);
217
+ expect(holdsStage({})).toBe(false);
218
+ expect(holdsStage(null)).toBe(false);
219
+ });
220
+ });
221
+
222
+ // Cycle 122: the held viewBox was -339,-10,1325,793 in a 1270 px frame (0.96 px a unit), the wave boxes at about
223
+ // x 200..640 of the window and the right 45% of the stage empty: the target reached past the boxes. It is the boxes.
224
+ describe("the held frame fits the graph's boxes to the open stage", () => {
225
+ const pane = { width: 1270, height: 800 };
226
+ const ins = heldInsets({ top: 20, bottom: 224, left: 20 });
227
+ // network's box, and apply-wave-2's with service-a and service-b, as drawn at x -131..328 of the svg.
228
+ const boxes = [{ x: -131, y: 0, x2: 89, y2: 104 }, { x: 108, y: 0, x2: 328, y2: 104 }];
229
+ const cards = [{ x: -121, y: 30, x2: 79, y2: 90 }, { x: 118, y: 30, x2: 214, y2: 90 }, { x: 222, y: 30, x2: 318, y2: 90 }];
230
+ // What inflated it: a card no box holds, far to the right, and a card's hover ring wider than its box.
231
+ const stray = { x: 700, y: 380, x2: 780, y2: 420 };
232
+ const ring = { x: -160, y: 20, x2: 100, y2: 100 };
233
+
234
+ it("takes the boxes that hold the cards, and nothing in no box", () => {
235
+ expect(heldTarget(boxes, [...cards, stray, ring])).toEqual({ x: -131, y: 0, x2: 328, y2: 104 });
236
+ // No box at all: the cards are the graph.
237
+ expect(heldTarget([], cards)).toEqual({ x: -121, y: 30, x2: 318, y2: 90 });
238
+ });
239
+
240
+ it("scales the boxes up to the open stage's width, about 1230 px here, from 440", () => {
241
+ const target = heldTarget(boxes, [...cards, stray, ring]);
242
+ const h = heldFrame(null, { key: "demo-cone|components", pane, insets: ins, target });
243
+ const s = pane.width / h.vb[2];
244
+ const openW = pane.width - ins.left - ins.right;
245
+ // The boxes and their pad span the open width (the height has room to spare at this shape).
246
+ expect(((target.x2 - target.x + 72) * s) / openW).toBeGreaterThan(0.99);
247
+ expect((target.x2 - target.x) * s).toBeGreaterThan(1000);
248
+ expect(s).toBeGreaterThan(2);
249
+ // Centred: as much room left of the boxes as right of them.
250
+ const left = (target.x - h.vb[0]) * s;
251
+ const right = (h.vb[0] + h.vb[2] - target.x2) * s;
252
+ expect(Math.abs(left - right)).toBeLessThan(2);
253
+ });
254
+
255
+ it("a framing from the inflated target frames again once, then holds", () => {
256
+ const wide = heldFrame(null, { key: "demo-cone|components", pane, insets: ins, target: unionBox([...boxes, stray, ring]) });
257
+ const target = heldTarget(boxes, [...cards, stray, ring]);
258
+ const fit = heldFrame(JSON.parse(JSON.stringify(wide)), { key: "demo-cone|components", pane, insets: ins, target });
259
+ expect(fit.reason).toBe("fill");
260
+ expect(heldFrame(fit, { key: "demo-cone|components", pane, insets: ins, target }).reason).toBe("held");
261
+ });
262
+ });
263
+
264
+ // Cycle 122 at 80a8867e, from window.__kioskHeld(): pane 1270 x 760, insets {top 52, right 20, bottom 271, left 20},
265
+ // target 488 x 384 units (wave 2 stacked over wave 1), vb 1325 wide: 0.958 px a unit, the 36-unit pad included.
266
+ describe("the held scale is the open stage over the graph, nothing else", () => {
267
+ const pane = { width: 1270, height: 760 };
268
+ const key = "demo-choudoufu|components";
269
+ const stacked = { x: 80, y: 80, x2: 568, y2: 464 };
270
+
271
+ it("applies min(openW / targetW, openH / targetH): no pad, the same insets that judged it", () => {
272
+ const insets = { top: 52, right: 20, bottom: 271, left: 20 };
273
+ const h = heldFrame(null, { key, pane, insets: { ...insets, bottom: 271 - HOLD_RESERVE_PX }, target: stacked });
274
+ const s = pane.width / h.vb[2];
275
+ expect(h.insets.bottom).toBe(271);
276
+ expect(s).toBeCloseTo(Math.min((1270 - 40) / 488, (760 - 52 - 271) / 384, HELD_MAX_SCALE), 6);
277
+ expect(HELD_PAD).toBe(0);
278
+ });
279
+
280
+ it("the waves in a row, with the caption's measured tallest plus 24: about twice the scale", () => {
281
+ // captionRoom: a 150 px caption showing one 22 px row and no trail, at most two rows and a two-line trail.
282
+ const room = captionRoom({ capHeight: 150, extras: [22], rowH: 22, trailH: 0, trailLineH: 26, below: 5 });
283
+ expect(room).toBe(5 + 128 + 44 + 52 + 16);
284
+ const insets = heldInsets({ top: 20, bottom: 175, left: 20 }, room);
285
+ expect(insets.bottom).toBe(room);
286
+ // network | service-a, service-b: the same boxes side by side, 900 x 190 units.
287
+ const row = { x: 0, y: 0, x2: 900, y2: 190 };
288
+ const h = heldFrame(null, { key, pane, insets, target: row });
289
+ const s = pane.width / h.vb[2];
290
+ const was = pane.width / 1325.2;
291
+ expect(s).toBeCloseTo(Math.min((1270 - 40) / 900, (760 - 52 - (room + HOLD_RESERVE_PX)) / 190, HELD_MAX_SCALE), 6);
292
+ expect(s / was).toBeGreaterThan(1.4);
293
+ });
294
+
295
+ it("carries the room with the shot, only when there is some", () => {
296
+ expect(shotMessage({ whole: true, room: 245 }).room).toBe(245);
297
+ expect(shotMessage({ whole: true })).not.toHaveProperty("room");
298
+ expect(shotFromMessage({ origin: "https://k", data: { type: "behold:shot", whole: true, room: 245 } }, "https://k").room).toBe(245);
299
+ expect(heldInsets({ bottom: 300 }, 245).bottom).toBe(300);
300
+ });
301
+ });
@@ -0,0 +1,43 @@
1
+ // behold#752: where a kiosk page reads its demo. terragucci's loop (demo.json,
2
+ // cycles/<tool>/latest.json, runs/ copied from the forge) through
3
+ // /api/terragucci/…, or chant's fan-out demo's own records (demo-step/v1,
4
+ // demo-cycle/v1, runs built from chant's run events) through /api/chant/demo…
5
+ // (src/chant-demo.ts). The server says which in a meta tag
6
+ // (src/terragucci-demo.ts vendorPage); a page without it reads terragucci's,
7
+ // as every page did before.
8
+
9
+ /** The reads of terragucci's loop. `own: false`: the reports, run view, event stream and lane are read too. */
10
+ export const TERRAGUCCI_READS = {
11
+ source: null,
12
+ demo: "/api/terragucci/demo",
13
+ cycle: (tool) => `/api/terragucci/cycles/${encodeURIComponent(tool)}`,
14
+ runs: "/api/terragucci/runs",
15
+ run: (id) => `/api/terragucci/runs/${id}`,
16
+ own: false,
17
+ };
18
+
19
+ /**
20
+ * The reads of chant's fan-out demo. `own: true`: the demo is chant's alone, so
21
+ * terragucci's reports, run view, event stream and lane are never asked for.
22
+ * The cycle is the demo's one latest cycle, whatever tool the page names.
23
+ */
24
+ export const CHANT_DEMO_READS = {
25
+ source: "chant-demo",
26
+ demo: "/api/chant/demo",
27
+ cycle: () => "/api/chant/demo/cycle",
28
+ runs: "/api/chant/demo/runs",
29
+ run: (id) => `/api/chant/demo/runs/${id}`,
30
+ own: true,
31
+ };
32
+
33
+ /** The reads for a source name: chant's demo for `chant-demo`, terragucci's for anything else. */
34
+ export function readsFor(source) {
35
+ return source === "chant-demo" ? CHANT_DEMO_READS : TERRAGUCCI_READS;
36
+ }
37
+
38
+ /** The source the page was served for (`<meta name="kiosk-source">`), or null. */
39
+ export function pageSource(doc) {
40
+ const m = doc && doc.querySelector ? doc.querySelector('meta[name="kiosk-source"]') : null;
41
+ const s = m ? m.getAttribute("content") : null;
42
+ return s === "chant-demo" ? s : null;
43
+ }
@@ -0,0 +1,39 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { CHANT_DEMO_READS, TERRAGUCCI_READS, pageSource, readsFor } from "./kiosk-source.js";
3
+ import { startMetrics } from "./kiosk-metrics.js";
4
+
5
+ // behold#752: a kiosk page reads terragucci's loop unless the server tells it chant's demo is its source.
6
+ const docWith = (content) => ({ querySelector: (q) => (q === 'meta[name="kiosk-source"]' && content !== null ? { getAttribute: () => content } : null) });
7
+
8
+ describe("where a kiosk page reads its demo (behold#752)", () => {
9
+ it("a page without the tag reads terragucci's loop, as every page did before", () => {
10
+ expect(pageSource(docWith(null))).toBeNull();
11
+ expect(readsFor(pageSource(docWith(null)))).toBe(TERRAGUCCI_READS);
12
+ expect(TERRAGUCCI_READS).toMatchObject({ demo: "/api/terragucci/demo", runs: "/api/terragucci/runs", own: false });
13
+ expect(TERRAGUCCI_READS.cycle("chant-fanout")).toBe("/api/terragucci/cycles/chant-fanout");
14
+ expect(TERRAGUCCI_READS.run(7)).toBe("/api/terragucci/runs/7");
15
+ });
16
+ it("a page told `chant-demo` reads chant's records, and nothing of terragucci's", () => {
17
+ const r = readsFor(pageSource(docWith("chant-demo")));
18
+ expect(r).toBe(CHANT_DEMO_READS);
19
+ expect([r.demo, r.cycle("chant-fanout"), r.runs, r.run(61002)]).toEqual(["/api/chant/demo", "/api/chant/demo/cycle", "/api/chant/demo/runs", "/api/chant/demo/runs/61002"]);
20
+ expect(r.own).toBe(true);
21
+ expect(JSON.stringify([r.demo, r.cycle("x"), r.runs, r.run(1)])).not.toMatch(/terragucci/);
22
+ });
23
+ it("an unknown source name is no source", () => {
24
+ expect(pageSource(docWith("elsewhere"))).toBeNull();
25
+ });
26
+ it("the metrics pane asks the page's own demo", async () => {
27
+ const host = { hidden: true, replaceChildren() {}, appendChild() {}, classList: { toggle() {} } };
28
+ const doc = { createElement: () => ({ classList: { toggle() {} }, dataset: {}, setAttribute() {}, addEventListener() {}, append() {}, appendChild() {} }), body: null, head: null, getElementById: () => null };
29
+ const asked = async (reads) => {
30
+ const urls = [];
31
+ const fetchJson = async (url) => (urls.push(url), { error: "none" });
32
+ const m = startMetrics(host, { tool: "chant-fanout", ...(reads ? { reads } : {}), fetchJson, store: { getItem: () => "closed", setItem() {} }, setTimer: () => 0, clearTimer() {}, doc });
33
+ await m.tick();
34
+ return urls;
35
+ };
36
+ expect(await asked(null)).toEqual(["/api/terragucci/demo", "/api/terragucci/cycles/chant-fanout"]);
37
+ expect(await asked(CHANT_DEMO_READS)).toEqual(["/api/chant/demo", "/api/chant/demo/cycle"]);
38
+ });
39
+ });
@@ -0,0 +1,44 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { storyGate, whatLine, whatParts, whatTool } from "./kiosk.js";
3
+
4
+ // behold#741: the #740 kiosk features (track, chapters, wedge, waiting modal,
5
+ // pacing, wave blocks, applied earlier, one tip at a time, the title line)
6
+ // are on for a chant repo's loop, or a terragucci repo whose demo.json step
7
+ // carries `chapter`. b-waves, failure and tg-planned-outputs carry none.
8
+ const step = (extra = {}) => ({ cycle: 3, scenario: "b-waves", step: "applying", pull: 12, ...extra });
9
+ const chapter = { n: 2, of: 4, headline: "cluster-a breaks" };
10
+
11
+ describe("the kiosk's story gate (behold#741)", () => {
12
+ it("is chant's for a chant repo's loop, whatever the step carries", () => {
13
+ expect(storyGate({ chantLoop: true, demo: step() })).toBe("chant");
14
+ expect(storyGate({ chantLoop: true, terragucciRepo: false, demo: null })).toBe("chant");
15
+ });
16
+ it("is terragucci's for a terragucci repo only when the step carries a chapter", () => {
17
+ expect(storyGate({ terragucciRepo: true, demo: step({ scenario: "fan-out", chapter }) })).toBe("terragucci");
18
+ for (const scenario of ["b-waves", "failure", "tg-planned-outputs"]) expect(storyGate({ terragucciRepo: true, demo: step({ scenario }) })).toBe(null);
19
+ expect(storyGate({ terragucciRepo: true, demo: step({ chapter: { headline: "no number" } }) })).toBe(null);
20
+ expect(storyGate({ terragucciRepo: true, demo: null })).toBe(null);
21
+ });
22
+ it("is off for a repo that is neither, chapter or not", () => {
23
+ expect(storyGate({ demo: step({ chapter }) })).toBe(null);
24
+ });
25
+ });
26
+
27
+ describe("a terragucci story's title line (behold#741)", () => {
28
+ it("names terragucci, its engine and its forge, with only the marks behold ships", () => {
29
+ expect(whatLine({ scenario: "fan-out" }, "forgejo", { tools: ["opentofu"] })).toBe("terragucci · OpenTofu · on Forgejo · fan-out · live demo");
30
+ const parts = whatParts({ scenario: "fan-out" }, "forgejo", { tools: ["opentofu"] });
31
+ // No terragucci mark ships: its name alone.
32
+ expect(parts[0].logo).toBeUndefined();
33
+ expect(parts[1].logo).toBe("opentofu");
34
+ expect(parts[2].logo).toBe("forgejo");
35
+ });
36
+ it("says Terraform by name alone, and no engine when none is declared", () => {
37
+ expect(whatTool(["terraform"])).toEqual({ id: "terraform", name: "Terraform" });
38
+ expect(whatTool([])).toBe(null);
39
+ expect(whatLine({ scenario: "fan-out" }, null, { tools: [] })).toBe("terragucci · fan-out · live demo");
40
+ });
41
+ it("leaves chant's line as it was", () => {
42
+ expect(whatLine({ scenario: "fan-out" }, "forgejo")).toBe("chant's pull-request pipeline · on Forgejo · fan-out · live demo");
43
+ });
44
+ });