@intentius/behold 0.29.47 → 0.29.49
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/dist/cli.js +14 -11
- package/package.json +1 -1
- package/web/app.js +22 -0
- package/web/event-help-modal.js +13 -3
- package/web/kiosk-annotations.js +2 -2
- package/web/kiosk-event-help-ui.js +46 -9
- package/web/kiosk-event-help.js +6 -3
- package/web/kiosk-metrics.js +39 -8
- package/web/kiosk-metrics.test.js +36 -1
- package/web/kiosk-modal-sticky.test.js +27 -3
- package/web/kiosk-popover.js +29 -1
- package/web/kiosk-popover.test.js +32 -0
- package/web/kiosk-replay.test.js +79 -0
- package/web/kiosk-result.test.js +36 -0
- package/web/kiosk-runs.js +12 -0
- package/web/kiosk-story-gate.test.js +22 -1
- package/web/kiosk-trace.js +84 -21
- package/web/kiosk-trace.test.js +56 -10
- package/web/kiosk-track.js +138 -12
- package/web/kiosk-track.test.js +84 -1
- package/web/kiosk-watch.js +3 -1
- package/web/kiosk-watch.test.js +2 -0
- package/web/kiosk-wave-list.js +130 -0
- package/web/kiosk-wave-list.test.js +103 -0
- package/web/kiosk.html +85 -10
- package/web/kiosk.js +328 -54
- package/web/kiosk.test.js +112 -2
- package/web/small-stage.test.js +8 -0
package/web/kiosk-track.js
CHANGED
|
@@ -32,6 +32,30 @@ export const MIN_SHARE = 0.045;
|
|
|
32
32
|
/** How long nothing must change before the "Waiting on…" modal shows. */
|
|
33
33
|
export const WAITING_AFTER_MS = 3_000;
|
|
34
34
|
|
|
35
|
+
/** A job that has started, as the run's own document says it. */
|
|
36
|
+
const STARTED = new Set(["running", "waiting", "success", "failure"]);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* behold#774: the apply jobs of this step's run that have started, from the
|
|
40
|
+
* run's own document (the forge's jobs): `[{ job, wave, status }]`. The run
|
|
41
|
+
* view moves a wave only once its job reports, a minute or two into a long
|
|
42
|
+
* apply, so "Waiting on the pipeline to start the apply" stayed up while
|
|
43
|
+
* apply-wave-3 ran. A job starting is the first sign the apply is under way.
|
|
44
|
+
* Empty for another commit's run (the change's, while the fix's merge starts).
|
|
45
|
+
*/
|
|
46
|
+
export function applyJobs(runDoc, demo) {
|
|
47
|
+
if (!runDoc || !Array.isArray(runDoc.jobs) || !demo) return [];
|
|
48
|
+
const c = typeof runDoc.commit === "string" ? runDoc.commit : "";
|
|
49
|
+
const d = typeof demo.commit === "string" ? demo.commit : "";
|
|
50
|
+
if (!c || !d || !(c.startsWith(d) || d.startsWith(c))) return [];
|
|
51
|
+
return runDoc.jobs
|
|
52
|
+
.filter((j) => j && typeof j.name === "string" && /^apply/.test(j.name) && STARTED.has(j.status))
|
|
53
|
+
.map((j) => {
|
|
54
|
+
const m = /^apply-wave-(\d+)$/.exec(j.name);
|
|
55
|
+
return { job: j.name, wave: m ? Number(m[1]) : null, status: j.status };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
35
59
|
const ms = (a, b) => Math.max(0, Date.parse(b) - Date.parse(a));
|
|
36
60
|
const secs = (n) => Math.max(1, Math.round(n / 1000));
|
|
37
61
|
|
|
@@ -78,7 +102,8 @@ export function cycleTrack(cycle) {
|
|
|
78
102
|
last.ms += took;
|
|
79
103
|
return;
|
|
80
104
|
}
|
|
81
|
-
|
|
105
|
+
// behold#787: the segment's first step's time, where a replay of it starts.
|
|
106
|
+
chapter.segments.push({ label, steps: [s.step], ms: took, labelText: s.label || "", at: s.at });
|
|
82
107
|
});
|
|
83
108
|
const total = chapters.reduce((sum, c) => sum + c.segments.reduce((a, g) => a + g.ms, 0), 0) || 1;
|
|
84
109
|
return { chapters, total, cycle: cycle.cycle, byStory };
|
|
@@ -102,9 +127,12 @@ export function chapterTitle(index, pull) {
|
|
|
102
127
|
* The track as it stands now. `demo` is demo.json; `pulls` the pull requests
|
|
103
128
|
* this cycle has opened, in order; `since` when the current segment began
|
|
104
129
|
* (ms); `waves` the apply's waves as the paced graph shows them
|
|
105
|
-
* ([{ wave, state }]), for the applying segment's ticks
|
|
130
|
+
* ([{ wave, state }]), for the applying segment's ticks; `jobs` the apply
|
|
131
|
+
* jobs of this step's run that have started ({@link applyJobs}). behold#787:
|
|
132
|
+
* a segment already past (in a `replay`, any but the current one) carries
|
|
133
|
+
* `seek`, its first step's time, and a chapter carries its first segment's.
|
|
106
134
|
*/
|
|
107
|
-
export function trackModel(track, { demo, pulls = [], since = null, now = Date.now(), waves = null } = {}) {
|
|
135
|
+
export function trackModel(track, { demo, pulls = [], since = null, now = Date.now(), waves = null, jobs = [], replay = false } = {}) {
|
|
108
136
|
if (!track || !demo) return null;
|
|
109
137
|
// Where the cycle is: the step's own story chapter when told in them; else the chapter of the current pull request
|
|
110
138
|
// (the reset, the last). Then the segment holding the step.
|
|
@@ -133,12 +161,51 @@ export function trackModel(track, { demo, pulls = [], since = null, now = Date.n
|
|
|
133
161
|
state,
|
|
134
162
|
tone,
|
|
135
163
|
fill: state === "done" ? 1 : state === "current" ? fill : 0,
|
|
164
|
+
// The reset is the cycle's end: nothing to replay from there.
|
|
165
|
+
seek: (replay ? state !== "current" : state === "done") && g.label !== "reset" && typeof g.at === "string" ? g.at : null,
|
|
136
166
|
...(state === "current" && g.label === "applying" && Array.isArray(waves) && waves.length ? { ticks: waves.map((w) => ({ wave: w.wave, state: w.state })) } : {}),
|
|
137
167
|
};
|
|
138
168
|
}),
|
|
139
169
|
}));
|
|
140
|
-
|
|
141
|
-
|
|
170
|
+
for (const c of chapters) c.seek = c.segments.length ? c.segments[0].seek : null;
|
|
171
|
+
const nowLine = nowWords({ demo, segment: current, expected, elapsed, overrun, waves, jobs, now, fix: track.byStory ? pulls.indexOf(demo.pull) > 0 : at.chapter > 0 });
|
|
172
|
+
return { chapters, at, elapsed, expected, overrun, now: nowLine, here: hereWords(chapters, at) };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** behold#787: how long before the failed step a replay of the failure starts: the apply's last stretch, where it breaks. */
|
|
176
|
+
export const FAILURE_LEAD_MS = 30_000;
|
|
177
|
+
|
|
178
|
+
/** behold#787: how far into the cycle a time is, in ms from its first step, for the replay's clock (kiosk-vendor.js replayAt). */
|
|
179
|
+
export function seekMs(cycle, at) {
|
|
180
|
+
const first = cycle && Array.isArray(cycle.steps) && cycle.steps[0] ? Date.parse(cycle.steps[0].at) : NaN;
|
|
181
|
+
const t = Date.parse(at || "");
|
|
182
|
+
return Number.isFinite(first) && Number.isFinite(t) ? Math.max(0, t - first) : 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* behold#787: where a replay of the cycle's failure starts: FAILURE_LEAD_MS
|
|
187
|
+
* before its failed step, never before the step ahead of it (the apply that
|
|
188
|
+
* broke). Null for a cycle with no failure.
|
|
189
|
+
*/
|
|
190
|
+
export function failureAt(cycle) {
|
|
191
|
+
const steps = cycle && Array.isArray(cycle.steps) ? cycle.steps : [];
|
|
192
|
+
const i = steps.findIndex((x) => x && x.step === "failed");
|
|
193
|
+
if (i < 0) return null;
|
|
194
|
+
const t = Date.parse(steps[i].at);
|
|
195
|
+
const before = i > 0 ? Date.parse(steps[i - 1].at) : t;
|
|
196
|
+
if (!Number.isFinite(t)) return null;
|
|
197
|
+
return new Date(Math.max(Number.isFinite(before) ? before : t, t - FAILURE_LEAD_MS)).toISOString();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* behold#778: the current step by name, "Step: applying, in 3 The fix", for a
|
|
202
|
+
* phone, whose segments are too narrow for their labels. Null when the cycle
|
|
203
|
+
* stands at no segment.
|
|
204
|
+
*/
|
|
205
|
+
export function hereWords(chapters, at) {
|
|
206
|
+
const c = chapters && at ? chapters[at.chapter] : null;
|
|
207
|
+
const g = c && at.segment >= 0 ? c.segments[at.segment] : null;
|
|
208
|
+
return g ? `Step: ${g.label}, in ${c.title}` : null;
|
|
142
209
|
}
|
|
143
210
|
|
|
144
211
|
const typical = (expected, overrun) => (overrun ? "taking longer than usual…" : expected > 0 ? `usually about ${secs(expected)} s` : null);
|
|
@@ -148,7 +215,7 @@ const countdown = (demo, now) => {
|
|
|
148
215
|
};
|
|
149
216
|
|
|
150
217
|
/** What is happening now and what is waited on, in plain words: `{ text, waiting, why, expected, elapsed, overrun }`. */
|
|
151
|
-
export function nowWords({ demo, segment, expected = 0, elapsed = 0, overrun = false, waves = null, now = Date.now(), fix = false } = {}) {
|
|
218
|
+
export function nowWords({ demo, segment, expected = 0, elapsed = 0, overrun = false, waves = null, jobs = [], now = Date.now(), fix = false } = {}) {
|
|
152
219
|
if (!demo || !segment) return null;
|
|
153
220
|
const why = firstSentence(demo.label);
|
|
154
221
|
const base = { why, expected, elapsed, overrun };
|
|
@@ -156,6 +223,12 @@ export function nowWords({ demo, segment, expected = 0, elapsed = 0, overrun = f
|
|
|
156
223
|
const running = Array.isArray(waves) ? waves.filter((w) => w.state === "running").map((w) => w.wave) : [];
|
|
157
224
|
const wavesSeen = Array.isArray(waves) && waves.some((w) => w.state && w.state !== "waiting");
|
|
158
225
|
const say = (text, waiting = null, timed = true) => ({ ...base, text: timed && typical(expected, overrun) ? `${text} · ${typical(expected, overrun)}` : text, waiting });
|
|
226
|
+
// behold#774: an apply job the run view has not caught up with yet: nothing waits on the pipeline any more.
|
|
227
|
+
const started = () => {
|
|
228
|
+
const ws = (jobs || []).filter((j) => j.status === "running" && Number.isInteger(j.wave)).map((j) => j.wave);
|
|
229
|
+
if (ws.length) return say(`Wave ${ws.join(" and ")} is applying`, null, false);
|
|
230
|
+
return (jobs || []).length ? say("The apply is under way", null, false) : null;
|
|
231
|
+
};
|
|
159
232
|
switch (segment.label) {
|
|
160
233
|
case "opened":
|
|
161
234
|
case "fix opened":
|
|
@@ -165,11 +238,11 @@ export function nowWords({ demo, segment, expected = 0, elapsed = 0, overrun = f
|
|
|
165
238
|
case "review":
|
|
166
239
|
return say("Waiting for the reviewer", "the reviewer to approve the plan");
|
|
167
240
|
case "merged":
|
|
168
|
-
return say("The pipeline is starting the apply job", "the pipeline to start the apply");
|
|
241
|
+
return started() || say("The pipeline is starting the apply job", "the pipeline to start the apply");
|
|
169
242
|
case "applying":
|
|
170
243
|
if (running.length) return say(`Wave ${running.join(" and ")} is applying`, null, false);
|
|
171
244
|
if (wavesSeen) return say("The apply is under way", null, false);
|
|
172
|
-
return say("The pipeline is starting the apply job", "the pipeline to start the apply");
|
|
245
|
+
return started() || say("The pipeline is starting the apply job", "the pipeline to start the apply");
|
|
173
246
|
case "failed":
|
|
174
247
|
return { ...base, text: left !== null && left > 0 ? `The fix opens in ${left} s` : "The fix opens next", waiting: "the fix to open" };
|
|
175
248
|
case "done":
|
|
@@ -240,10 +313,27 @@ body.k-watch #k-track { position: fixed; z-index: 7; left: 5px; right: 5px; }
|
|
|
240
313
|
#k-track .kt-seg.kt-current .kt-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, white 28%, transparent), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: kt-sheen 2.4s ease-in-out infinite; }
|
|
241
314
|
@keyframes kt-sheen { from { background-position: -60% 0; } to { background-position: 160% 0; } }
|
|
242
315
|
}
|
|
316
|
+
#k-track .kt-here { display: none; }
|
|
317
|
+
/* behold#787: a step already past is a button that replays it. */
|
|
318
|
+
#k-track button.kt-seek { font: inherit; margin: 0; cursor: pointer; background: transparent; color: inherit; text-align: inherit; }
|
|
319
|
+
#k-track button.kt-seg.kt-seek { padding: 0; }
|
|
320
|
+
#k-track button.kt-chapter-title.kt-seek { padding: 0; border: 0; color: var(--fg); text-decoration: underline dotted; text-underline-offset: 2px; }
|
|
321
|
+
#k-track button.kt-seg.kt-seek:hover { border-color: var(--pending); }
|
|
322
|
+
#k-track button.kt-seek:focus-visible { outline: 2px solid var(--pending); outline-offset: 1px; }
|
|
323
|
+
/* behold#778: a phone's segments are too narrow for their labels, so a line names the current step, and the chapters wrap to a new line instead of running off the right edge. */
|
|
243
324
|
@media (max-width: 600px) {
|
|
244
325
|
body.k-watch #k-track { position: static; }
|
|
326
|
+
#k-track { font-size: 1em; padding: 0.35em 16px 0.4em; }
|
|
327
|
+
#k-track .kt-row { flex-wrap: wrap; row-gap: 0.4em; }
|
|
328
|
+
#k-track .kt-chapter-title { font-size: 0.88em; }
|
|
245
329
|
#k-track .kt-segs .kt-label { display: none; }
|
|
246
|
-
#k-track .kt-seg { height: 0.8em; }
|
|
330
|
+
#k-track .kt-seg { height: 0.8em; min-width: 0.6em !important; }
|
|
331
|
+
#k-track .kt-here { display: block; margin: 0; color: var(--pending); font-size: 0.92em; }
|
|
332
|
+
#k-track .kt-now { font-size: 0.92em; white-space: normal; }
|
|
333
|
+
/* behold#787: a phone's segments are too thin to press; a past chapter's title is the 44px target. */
|
|
334
|
+
#k-track button.kt-seg.kt-seek { pointer-events: none; }
|
|
335
|
+
#k-track button.kt-chapter-title.kt-seek { align-self: flex-start; max-width: 100%; min-height: 44px; padding: 0 0.8em; border: 1.5px solid color-mix(in srgb, var(--pending) 70%, transparent); border-radius: 999px; text-decoration: none; }
|
|
336
|
+
#k-track button.kt-chapter-title.kt-seek::after { content: " · replay"; color: var(--pending); font-weight: 500; }
|
|
247
337
|
}
|
|
248
338
|
`;
|
|
249
339
|
|
|
@@ -262,6 +352,25 @@ export function drawTrack(host, model, doc = typeof document !== "undefined" ? d
|
|
|
262
352
|
if (text !== undefined && text !== null) n.textContent = text;
|
|
263
353
|
return n;
|
|
264
354
|
};
|
|
355
|
+
// behold#787: the track is rebuilt every second, so a press is read on the host: a tap whose button was
|
|
356
|
+
// rebuilt between its down and its up still seeks to where it went down, and a focused button keeps its focus.
|
|
357
|
+
host.ktSeek = model && model.onSeek ? model.onSeek : null;
|
|
358
|
+
if (!host.ktWired && host.addEventListener) {
|
|
359
|
+
host.ktWired = true;
|
|
360
|
+
let down = null;
|
|
361
|
+
const seekOf = (t) => (t && t.closest ? t.closest("[data-seek]") : null);
|
|
362
|
+
host.addEventListener("pointerdown", (e) => {
|
|
363
|
+
const b = seekOf(e.target);
|
|
364
|
+
down = b ? { seek: b.dataset.seek, at: Date.now() } : null;
|
|
365
|
+
});
|
|
366
|
+
host.addEventListener("click", (e) => {
|
|
367
|
+
const b = seekOf(e.target);
|
|
368
|
+
const seek = b ? b.dataset.seek : down && Date.now() - down.at < 1500 ? down.seek : null;
|
|
369
|
+
down = null;
|
|
370
|
+
if (seek && host.ktSeek) host.ktSeek(seek);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
const focused = doc.activeElement && host.contains && host.contains(doc.activeElement) && doc.activeElement.dataset ? doc.activeElement.dataset.seek : null;
|
|
265
374
|
host.replaceChildren();
|
|
266
375
|
if (!model) {
|
|
267
376
|
host.hidden = true;
|
|
@@ -275,14 +384,26 @@ export function drawTrack(host, model, doc = typeof document !== "undefined" ? d
|
|
|
275
384
|
const ch = el("div", `kt-chapter kt-${c.state}`);
|
|
276
385
|
// Grow factors summing to well over 1: below 1 a flex row leaves the rest of its width empty.
|
|
277
386
|
ch.style.flex = `${Math.round(share * 1000)} 1 0`;
|
|
278
|
-
|
|
387
|
+
// behold#787: a step already past replays from its start on a press: the chapter's title (a phone's target) and each segment.
|
|
388
|
+
const seekable = (o) => !!(o.seek && model.onSeek);
|
|
389
|
+
const head = el(seekable(c) ? "button" : "div", `kt-chapter-title${seekable(c) ? " kt-seek" : ""}`, c.title);
|
|
390
|
+
if (seekable(c)) {
|
|
391
|
+
head.type = "button";
|
|
392
|
+
head.title = `Replay from ${c.title}`;
|
|
393
|
+
head.dataset.seek = c.seek;
|
|
394
|
+
}
|
|
395
|
+
ch.appendChild(head);
|
|
279
396
|
const segs = el("div", "kt-segs");
|
|
280
397
|
for (const g of c.segments) {
|
|
281
|
-
const seg = el("div", `kt-seg kt-${g.state} kt-${g.tone}`);
|
|
398
|
+
const seg = el(seekable(g) ? "button" : "div", `kt-seg kt-${g.state} kt-${g.tone}${seekable(g) ? " kt-seek" : ""}`);
|
|
399
|
+
if (seekable(g)) {
|
|
400
|
+
seg.type = "button";
|
|
401
|
+
seg.dataset.seek = g.seek;
|
|
402
|
+
}
|
|
282
403
|
seg.style.flex = `${Math.round(g.share * 1000)} 1 0`;
|
|
283
404
|
// Never narrower than its short label, whole.
|
|
284
405
|
seg.style.minWidth = `${(g.short.length * 0.62 + 1).toFixed(2)}em`;
|
|
285
|
-
seg.title = g.label;
|
|
406
|
+
seg.title = seekable(g) ? `Replay from ${g.label}` : g.label;
|
|
286
407
|
const fill = el("div", "kt-fill");
|
|
287
408
|
fill.style.width = `${Math.round(g.fill * 1000) / 10}%`;
|
|
288
409
|
seg.appendChild(fill);
|
|
@@ -304,9 +425,14 @@ export function drawTrack(host, model, doc = typeof document !== "undefined" ? d
|
|
|
304
425
|
row.appendChild(ch);
|
|
305
426
|
}
|
|
306
427
|
host.appendChild(row);
|
|
428
|
+
if (model.here) host.appendChild(el("p", "kt-here", model.here));
|
|
307
429
|
if (model.now && model.now.text) host.appendChild(el("p", "kt-now", model.now.text));
|
|
308
430
|
// A label its segment cannot hold whole says its short form ("plan", "merge"); never a clipped word.
|
|
309
431
|
for (const lab of host.querySelectorAll ? host.querySelectorAll(".kt-label") : []) {
|
|
310
432
|
if (lab.scrollWidth > lab.clientWidth + 1 && lab.dataset.short) lab.textContent = lab.dataset.short;
|
|
311
433
|
}
|
|
434
|
+
if (focused && host.querySelector) {
|
|
435
|
+
const again = [...host.querySelectorAll("[data-seek]")].find((b) => b.dataset.seek === focused);
|
|
436
|
+
if (again && again.focus) again.focus();
|
|
437
|
+
}
|
|
312
438
|
}
|
package/web/kiosk-track.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { FILL_CAP, cycleTrack, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
2
|
+
import { FAILURE_LEAD_MS, FILL_CAP, applyJobs, cycleTrack, failureAt, hereWords, seekMs, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
3
3
|
|
|
4
4
|
// behold#631: chant-fanout's last finished cycle as cycles/chant-fanout/latest.json had it (cycle 499):
|
|
5
5
|
// fifteen steps, two pull requests, from the change's open to the reset.
|
|
@@ -112,6 +112,12 @@ describe("the track in the story's four chapters (behold#631)", () => {
|
|
|
112
112
|
const m = trackModel(track, { demo: { step: "applying", pull: 13, chapter: chapters[2] }, pulls: [12, 13], since: now - 2_000, now });
|
|
113
113
|
expect(m.chapters.map((c) => [c.title, c.state])).toEqual([["1 The change goes out", "done"], ["2 cluster-a breaks", "done"], ["3 The fix", "current"], ["4 Done", "ahead"]]);
|
|
114
114
|
expect(m.chapters[2].segments[4]).toMatchObject({ label: "applying", state: "current" });
|
|
115
|
+
// behold#778: and names the step in words, for a phone whose segments are too narrow for their labels.
|
|
116
|
+
expect(m.here).toBe("Step: applying, in 3 The fix");
|
|
117
|
+
});
|
|
118
|
+
it("names no step when the cycle stands at none (behold#778)", () => {
|
|
119
|
+
expect(hereWords([{ title: "1 The change", segments: [{ label: "opened" }] }], { chapter: 0, segment: -1 })).toBeNull();
|
|
120
|
+
expect(hereWords([{ title: "1 The change", segments: [{ label: "opened" }] }], { chapter: 0, segment: 0 })).toBe("Step: opened, in 1 The change");
|
|
115
121
|
});
|
|
116
122
|
it("names a chapter from its headline when the driver gives no short name", () => {
|
|
117
123
|
const plain = cycleTrack({ ...cycle, steps: told.steps.map((s) => ({ ...s, chapter: { n: s.chapter.n, of: 4, headline: s.chapter.headline } })) });
|
|
@@ -146,3 +152,80 @@ describe("the Waiting on… modal (behold#631)", () => {
|
|
|
146
152
|
expect(waitingSpec(at({ step: "planned", pull: 12 }, 1_000), { quietMs: 5_000 })).toBeNull();
|
|
147
153
|
});
|
|
148
154
|
});
|
|
155
|
+
|
|
156
|
+
// behold#774: on demo.intentius.io "Waiting on the pipeline to start the apply" stayed up about 2 minutes while
|
|
157
|
+
// apply-wave-3 ran: the run view moves a wave only once its job reports. The run's own jobs say it first.
|
|
158
|
+
describe("the apply's jobs end the wait (behold#774)", () => {
|
|
159
|
+
const track = cycleTrack(cycle);
|
|
160
|
+
const now = Date.parse(T("40:00"));
|
|
161
|
+
const C = "c27888c42a093b72166e924a339cf6f01a739547";
|
|
162
|
+
const doc = (jobs, commit = C) => ({ commit, jobs: jobs.map(([name, status]) => ({ name, status })) });
|
|
163
|
+
const run = doc([["check", "success"], ["plan", "skipped"], ["apply-comment", "skipped"], ["apply-wave-1", "success"], ["apply-wave-2", "success"], ["apply-wave-3", "running"], ["tips", "queued"]]);
|
|
164
|
+
it("reads the started apply jobs of this step's commit, by wave", () => {
|
|
165
|
+
expect(applyJobs(run, { commit: C })).toEqual([
|
|
166
|
+
{ job: "apply-wave-1", wave: 1, status: "success" },
|
|
167
|
+
{ job: "apply-wave-2", wave: 2, status: "success" },
|
|
168
|
+
{ job: "apply-wave-3", wave: 3, status: "running" },
|
|
169
|
+
]);
|
|
170
|
+
// A short commit either way matches.
|
|
171
|
+
expect(applyJobs(run, { commit: C.slice(0, 8) })).toHaveLength(3);
|
|
172
|
+
expect(applyJobs(doc([["apply-wave-1", "running"]], C.slice(0, 8)), { commit: C })).toHaveLength(1);
|
|
173
|
+
});
|
|
174
|
+
it("is empty for another commit's run, a queued job, or no run", () => {
|
|
175
|
+
expect(applyJobs(run, { commit: "298a730c2764cbbcc29b75360d12e8e5d03a8406" })).toEqual([]);
|
|
176
|
+
expect(applyJobs(doc([["apply-wave-1", "queued"]]), { commit: C })).toEqual([]);
|
|
177
|
+
expect(applyJobs(run, { commit: null })).toEqual([]);
|
|
178
|
+
expect(applyJobs(null, { commit: C })).toEqual([]);
|
|
179
|
+
expect(applyJobs({ commit: C }, { commit: C })).toEqual([]);
|
|
180
|
+
});
|
|
181
|
+
it("says which wave is applying, and opens no Waiting modal, once a job runs", () => {
|
|
182
|
+
const at = (step, jobs) => trackModel(track, { demo: { step, pull: 12, commit: C }, pulls: [12], since: now - 1_000, now, jobs });
|
|
183
|
+
const m = at("applying", applyJobs(run, { commit: C }));
|
|
184
|
+
expect(m.now).toMatchObject({ text: "Wave 3 is applying", waiting: null });
|
|
185
|
+
expect(waitingSpec(m, { quietMs: 60_000 })).toBeNull();
|
|
186
|
+
// The merged step, its first job already started.
|
|
187
|
+
expect(at("merged", [{ job: "apply-wave-1", wave: 1, status: "running" }]).now.text).toBe("Wave 1 is applying");
|
|
188
|
+
// Jobs that started and finished, none running now: under way.
|
|
189
|
+
expect(at("applying", [{ job: "apply-wave-1", wave: 1, status: "success" }]).now).toMatchObject({ text: "The apply is under way", waiting: null });
|
|
190
|
+
// No job yet: the wait stands.
|
|
191
|
+
expect(waitingSpec(at("applying", []), { quietMs: 5_000 }).what).toBe("the pipeline to start the apply");
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
describe("a past step replays from its start (behold#787)", () => {
|
|
196
|
+
const ch = (n, short) => ({ n, of: 4, headline: short, short });
|
|
197
|
+
const chapters = [ch(1, "The change goes out"), ch(2, "cluster-a breaks"), ch(3, "The fix"), ch(4, "Done")];
|
|
198
|
+
const of = (step, i) => (step === "failed" ? chapters[1] : ["applied", "reset"].includes(step) ? chapters[3] : i < 6 ? chapters[0] : chapters[2]);
|
|
199
|
+
const track = cycleTrack({ ...cycle, steps: cycle.steps.map((s, i) => ({ ...s, chapter: of(s.step, i) })) });
|
|
200
|
+
const now = Date.parse(T("40:00"));
|
|
201
|
+
|
|
202
|
+
it("gives each segment already past its first step's time, and each chapter its first segment's", () => {
|
|
203
|
+
const m = trackModel(track, { demo: { step: "planned", pull: 13, chapter: chapters[2] }, pulls: [12, 13], since: now, now });
|
|
204
|
+
expect(m.chapters[0].segments.map((g) => g.seek)).toEqual([T("18:49"), T("19:01"), T("19:14"), T("19:27"), T("19:30")]);
|
|
205
|
+
expect(m.chapters.map((c) => c.seek)).toEqual([T("18:49"), T("19:49"), T("20:10"), null]);
|
|
206
|
+
// The current step and those ahead have no seek in the live cycle.
|
|
207
|
+
expect(m.chapters[2].segments.map((g) => g.seek)).toEqual([T("20:10"), null, null, null, null]);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("lets a replay seek to any step but the one it shows, and never to the reset", () => {
|
|
211
|
+
const m = trackModel(track, { demo: { step: "failed", pull: 12, chapter: chapters[1] }, pulls: [12], since: now, now, replay: true });
|
|
212
|
+
expect(m.chapters[1].segments[0]).toMatchObject({ state: "current", seek: null });
|
|
213
|
+
expect(m.chapters[2].segments[4]).toMatchObject({ state: "ahead", seek: T("20:37") });
|
|
214
|
+
expect(m.chapters[3].segments.map((g) => [g.label, g.seek])).toEqual([["done", T("20:56")], ["reset", null]]);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("measures a seek from the cycle's first step", () => {
|
|
218
|
+
expect(seekMs(cycle, T("19:49"))).toBe(60_000);
|
|
219
|
+
expect(seekMs(cycle, "2026-10-18T17:00:00Z")).toBe(0);
|
|
220
|
+
expect(seekMs(null, T("19:49"))).toBe(0);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("starts a replay of the failure in the apply's last stretch, never before the apply", () => {
|
|
224
|
+
// The apply took 19 s, under the lead: the replay starts with it.
|
|
225
|
+
expect(failureAt(cycle)).toBe(new Date(T("19:30")).toISOString());
|
|
226
|
+
const long = { ...cycle, steps: cycle.steps.map((s) => (s.step === "applying" && s.pull === 641 ? { ...s, at: "2026-10-18T18:17:00Z" } : s)) };
|
|
227
|
+
expect(Date.parse(failureAt(long))).toBe(Date.parse(T("19:49")) - FAILURE_LEAD_MS);
|
|
228
|
+
expect(failureAt({ ...cycle, steps: cycle.steps.filter((s) => s.step !== "failed") })).toBeNull();
|
|
229
|
+
expect(failureAt(null)).toBeNull();
|
|
230
|
+
});
|
|
231
|
+
});
|
package/web/kiosk-watch.js
CHANGED
|
@@ -235,8 +235,10 @@ export function badges(metrics) {
|
|
|
235
235
|
export function doraLine(metrics) {
|
|
236
236
|
const rows = metrics && metrics.dora;
|
|
237
237
|
if (!rows || !rows.length) return null;
|
|
238
|
+
// behold#786: the deploy rate says the span it counts ("last 24 hours"), since the numbers are recounted each cycle.
|
|
239
|
+
const span = metrics.window ? ` (${metrics.window})` : "";
|
|
238
240
|
const say = {
|
|
239
|
-
Deploys: (v) => `${roundedWeek(v)} deploys a week`,
|
|
241
|
+
Deploys: (v) => `${roundedWeek(v)} deploys a week${span}`,
|
|
240
242
|
"Lead time": (v) => `lead time ${v}`,
|
|
241
243
|
"Change failure rate": (v) => `change failure rate ${v}`,
|
|
242
244
|
"Time to restore": (v) => `time to restore ${v}`,
|
package/web/kiosk-watch.test.js
CHANGED
|
@@ -127,6 +127,8 @@ describe("kiosk watch: the numbers", () => {
|
|
|
127
127
|
it("says the delivery numbers on one line, a large rate rounded", () => {
|
|
128
128
|
expect(doraLine(metrics)).toBe("19,489 deploys a week · lead time 1 min 56 s · change failure rate 1% · time to restore 1 min 12 s");
|
|
129
129
|
expect(doraLine({ dora: [["Deploys", "4.5 a week"]] })).toBe("4.5 deploys a week");
|
|
130
|
+
// behold#786: with the span it counts.
|
|
131
|
+
expect(doraLine({ dora: [["Deploys", "1526 a week"], ["Lead time", "1 min 21 s"]], window: "last 24 hours" })).toBe("1,526 deploys a week (last 24 hours) · lead time 1 min 21 s");
|
|
130
132
|
expect(doraLine({ dora: null })).toBeNull();
|
|
131
133
|
});
|
|
132
134
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// behold#776: a phone's Watch as a list. On a 390 px screen the components
|
|
2
|
+
// graph shrinks until its card labels are about 5 px, so Watch reads as
|
|
3
|
+
// coloured boxes. Under the graph a phone gets the same marks as words: each
|
|
4
|
+
// wave, how it stands, and each of its roots with its state; a tap on a root
|
|
5
|
+
// opens what its card's popover says (its resources and which of them change).
|
|
6
|
+
//
|
|
7
|
+
// The frame owns the marks (web/terragucci-components-live.js componentMarks,
|
|
8
|
+
// web/chant-pr-marks.js chantComponentMarks) and posts them as `behold:marks`
|
|
9
|
+
// in the form waveListOf makes; the kiosk draws them with drawWaveList.
|
|
10
|
+
//
|
|
11
|
+
// Pure apart from drawWaveList, which builds DOM from a list.
|
|
12
|
+
|
|
13
|
+
const TONES = new Set(["ok", "bad", "wait", "busy", "idle"]);
|
|
14
|
+
const toneOf = (t) => (TONES.has(t) ? t : "idle");
|
|
15
|
+
const words = (x) => (typeof x === "string" ? x.trim() : "");
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The list from a draw's marks: `{ waves: [{ wave, words, tone, roots: [{ root, component, words, tone, facts, detail? }] }] }`,
|
|
19
|
+
* the waves in the order they apply (wave 1 first), each wave's roots by name.
|
|
20
|
+
* `details` maps a component to its popover's content (kiosk-popover.js rootPopover), when the frame has one.
|
|
21
|
+
* Null when the marks carry no cards.
|
|
22
|
+
*/
|
|
23
|
+
export function waveListOf(marks, details = {}) {
|
|
24
|
+
const cards = marks && marks.cards && typeof marks.cards === "object" ? marks.cards : null;
|
|
25
|
+
if (!cards || !Object.keys(cards).length) return null;
|
|
26
|
+
const waveMarks = marks.waves && typeof marks.waves === "object" ? marks.waves : {};
|
|
27
|
+
const byWave = new Map();
|
|
28
|
+
for (const [component, c] of Object.entries(cards)) {
|
|
29
|
+
if (!c || typeof c.root !== "string") continue;
|
|
30
|
+
const n = Number.isInteger(c.wave) ? c.wave : null;
|
|
31
|
+
if (!byWave.has(n)) byWave.set(n, []);
|
|
32
|
+
const d = details && details[component];
|
|
33
|
+
byWave.get(n).push({
|
|
34
|
+
root: c.root,
|
|
35
|
+
component,
|
|
36
|
+
words: words(c.words) || words(c.short) || words(c.state),
|
|
37
|
+
tone: toneOf(c.tone),
|
|
38
|
+
facts: Array.isArray(c.facts) ? c.facts.filter((f) => typeof f === "string" && f) : [],
|
|
39
|
+
...(d && typeof d.head === "string" ? { detail: { head: d.head, rows: (d.rows || []).map((r) => ({ address: r.address, state: r.state, words: r.words })), more: d.more || 0 } } : {}),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const waves = [...byWave.keys()]
|
|
43
|
+
.sort((a, b) => (a === null ? 1 : b === null ? -1 : a - b))
|
|
44
|
+
.map((n) => {
|
|
45
|
+
const w = n !== null ? waveMarks[n] : null;
|
|
46
|
+
const said = w ? words(w.status && w.status.words) || words(w.state) : "";
|
|
47
|
+
return { wave: n, words: said, tone: toneOf(w ? w.tone : "idle"), roots: byWave.get(n).sort((a, b) => a.root.localeCompare(b.root)) };
|
|
48
|
+
});
|
|
49
|
+
return { waves };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A list's identity, so the frame posts it and the kiosk redraws it only when it changes. */
|
|
53
|
+
export function waveListKey(list) {
|
|
54
|
+
return JSON.stringify(list || null);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A wave's heading: "Wave 2 · failed", "Wave 2" before any state, "Other roots" for roots in no wave. */
|
|
58
|
+
export function waveHead(w) {
|
|
59
|
+
const name = w.wave === null ? "Other roots" : `Wave ${w.wave}`;
|
|
60
|
+
return w.words ? `${name} · ${w.words}` : name;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** What the list says it is, over its waves. */
|
|
64
|
+
export const LIST_WORDS = { title: "The waves", hint: "Tap a root for its resources." };
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Draw the list into `host`. `open` is the set of roots whose details are
|
|
68
|
+
* shown; `onToggle(root)` is called on a tap. `paint(doc, root)` returns the
|
|
69
|
+
* node for a root's name (its colour dot), or null for the plain name.
|
|
70
|
+
*/
|
|
71
|
+
export function drawWaveList(host, list, { doc = typeof document !== "undefined" ? document : null, open = new Set(), onToggle = () => {}, paint = null } = {}) {
|
|
72
|
+
if (!host || !doc) return;
|
|
73
|
+
const el = (tag, cls, text) => {
|
|
74
|
+
const n = doc.createElement(tag);
|
|
75
|
+
if (cls) n.className = cls;
|
|
76
|
+
if (text !== undefined && text !== null) n.textContent = text;
|
|
77
|
+
return n;
|
|
78
|
+
};
|
|
79
|
+
host.replaceChildren();
|
|
80
|
+
host.hidden = !list || !list.waves.length;
|
|
81
|
+
if (host.hidden) return;
|
|
82
|
+
const head = el("div", "k-wl-head");
|
|
83
|
+
head.append(el("h2", "k-wl-title", LIST_WORDS.title), el("span", "k-wl-hint", LIST_WORDS.hint));
|
|
84
|
+
host.appendChild(head);
|
|
85
|
+
for (const w of list.waves) {
|
|
86
|
+
const sec = el("section", "k-wl-wave");
|
|
87
|
+
sec.dataset.kTone = w.tone;
|
|
88
|
+
if (w.wave !== null) sec.dataset.kWave = String(w.wave);
|
|
89
|
+
sec.appendChild(el("h3", `k-wl-wave-head k-wl-${w.tone}`, waveHead(w)));
|
|
90
|
+
const ul = el("ul", "k-wl-roots");
|
|
91
|
+
for (const r of w.roots) {
|
|
92
|
+
const shown = open.has(r.root);
|
|
93
|
+
const li = el("li", `k-wl-root${shown ? " k-wl-open" : ""}`);
|
|
94
|
+
li.dataset.kTone = r.tone;
|
|
95
|
+
li.dataset.kRoot = r.root;
|
|
96
|
+
const b = el("button", "k-wl-row");
|
|
97
|
+
b.type = "button";
|
|
98
|
+
b.setAttribute("aria-expanded", String(shown));
|
|
99
|
+
const name = (paint && paint(doc, r.root)) || el("span", "k-wl-name", r.root);
|
|
100
|
+
if (name.classList) name.classList.add("k-wl-name");
|
|
101
|
+
b.append(name, el("span", `k-wl-state k-wl-${r.tone}`, r.words));
|
|
102
|
+
b.addEventListener("click", () => onToggle(r.root));
|
|
103
|
+
li.appendChild(b);
|
|
104
|
+
if (shown) li.appendChild(rootDetail(el, r));
|
|
105
|
+
ul.appendChild(li);
|
|
106
|
+
}
|
|
107
|
+
sec.appendChild(ul);
|
|
108
|
+
host.appendChild(sec);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** A root's details under its row: its card's facts, then its resources as its popover lists them. */
|
|
113
|
+
function rootDetail(el, r) {
|
|
114
|
+
const box = el("div", "k-wl-detail");
|
|
115
|
+
for (const f of r.facts) box.appendChild(el("p", "k-wl-fact", f));
|
|
116
|
+
if (r.detail) {
|
|
117
|
+
box.appendChild(el("p", "k-wl-res-head", r.detail.head));
|
|
118
|
+
if (r.detail.rows.length) {
|
|
119
|
+
const ul = el("ul", "k-wl-res");
|
|
120
|
+
for (const x of r.detail.rows) {
|
|
121
|
+
const li = el("li", null, `${x.address} `);
|
|
122
|
+
li.appendChild(el("span", `k-wl-res-${x.state}`, x.words));
|
|
123
|
+
ul.appendChild(li);
|
|
124
|
+
}
|
|
125
|
+
if (r.detail.more > 0) ul.appendChild(el("li", "k-wl-res-more", `and ${r.detail.more} more`));
|
|
126
|
+
box.appendChild(ul);
|
|
127
|
+
}
|
|
128
|
+
} else if (!r.facts.length) box.appendChild(el("p", "k-wl-fact", "Its resources show once the plan's report is read."));
|
|
129
|
+
return box;
|
|
130
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { drawWaveList, waveHead, waveListKey, waveListOf } from "./kiosk-wave-list.js";
|
|
3
|
+
|
|
4
|
+
// behold#776: the fan-out's marks as componentMarks has them when cluster-a fails in wave 2.
|
|
5
|
+
const card = (root, wave, state, tone, words, facts = []) => ({ root, wave, state, tone, words, short: state, facts });
|
|
6
|
+
const marks = {
|
|
7
|
+
cards: {
|
|
8
|
+
network: card("network", 1, "applied", "ok", "applied"),
|
|
9
|
+
"cluster-b": card("cluster-b", 2, "applied", "ok", "applied"),
|
|
10
|
+
"cluster-a": card("cluster-a", 2, "failed", "bad", "failed: queue name lacks .fifo"),
|
|
11
|
+
"app-02": card("app-02", 3, "blocked", "wait", "blocked by cluster-a"),
|
|
12
|
+
"app-01": card("app-01", 3, "blocked", "wait", "blocked by cluster-a", ["plans 1 create"]),
|
|
13
|
+
},
|
|
14
|
+
waves: {
|
|
15
|
+
1: { number: 1, state: "applied", tone: "ok", status: { words: "succeeded" } },
|
|
16
|
+
2: { number: 2, state: "failed", tone: "bad", status: { words: "1 failed, 1 applied" } },
|
|
17
|
+
3: { number: 3, state: "blocked", tone: "weird" },
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
describe("a phone's Watch as a list of waves and roots (behold#776)", () => {
|
|
22
|
+
it("lists the waves in the order they apply, each with its words and its roots by name", () => {
|
|
23
|
+
const list = waveListOf(marks);
|
|
24
|
+
expect(list.waves.map((w) => [w.wave, w.words, w.tone])).toEqual([
|
|
25
|
+
[1, "succeeded", "ok"],
|
|
26
|
+
[2, "1 failed, 1 applied", "bad"],
|
|
27
|
+
// A wave with no status says its state; a tone the kiosk has no bar for is idle.
|
|
28
|
+
[3, "blocked", "idle"],
|
|
29
|
+
]);
|
|
30
|
+
expect(list.waves[1].roots.map((r) => [r.root, r.words, r.tone])).toEqual([
|
|
31
|
+
["cluster-a", "failed: queue name lacks .fifo", "bad"],
|
|
32
|
+
["cluster-b", "applied", "ok"],
|
|
33
|
+
]);
|
|
34
|
+
expect(list.waves[2].roots[0]).toMatchObject({ root: "app-01", facts: ["plans 1 create"] });
|
|
35
|
+
});
|
|
36
|
+
it("carries each card's popover content when the frame has one", () => {
|
|
37
|
+
const details = { "cluster-a": { root: "cluster-a", head: "1 of 2 resources change.", rows: [{ address: "aws_sqs_queue.events", state: "change", words: "changes" }], more: 0, changed: 1 } };
|
|
38
|
+
const r = waveListOf(marks, details).waves[1].roots[0];
|
|
39
|
+
expect(r.detail).toEqual({ head: "1 of 2 resources change.", rows: [{ address: "aws_sqs_queue.events", state: "change", words: "changes" }], more: 0 });
|
|
40
|
+
expect(waveListOf(marks, details).waves[1].roots[1].detail).toBeUndefined();
|
|
41
|
+
});
|
|
42
|
+
it("is null with no cards, and keys equal lists alike", () => {
|
|
43
|
+
expect(waveListOf(null)).toBeNull();
|
|
44
|
+
expect(waveListOf({ cards: {} })).toBeNull();
|
|
45
|
+
expect(waveListKey(waveListOf(marks))).toBe(waveListKey(waveListOf(marks)));
|
|
46
|
+
});
|
|
47
|
+
it("heads each wave by its number and words", () => {
|
|
48
|
+
expect(waveHead({ wave: 2, words: "failed" })).toBe("Wave 2 · failed");
|
|
49
|
+
expect(waveHead({ wave: 1, words: "" })).toBe("Wave 1");
|
|
50
|
+
expect(waveHead({ wave: null, words: "" })).toBe("Other roots");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("drawing the list (behold#776)", () => {
|
|
55
|
+
// A small document: enough of the DOM for the list.
|
|
56
|
+
const fakeDocument = () => {
|
|
57
|
+
const make = (tag) => {
|
|
58
|
+
const n = {
|
|
59
|
+
tagName: tag.toUpperCase(),
|
|
60
|
+
className: "",
|
|
61
|
+
textContent: "",
|
|
62
|
+
children: [],
|
|
63
|
+
dataset: {},
|
|
64
|
+
attrs: {},
|
|
65
|
+
hidden: false,
|
|
66
|
+
listeners: {},
|
|
67
|
+
setAttribute(k, v) { this.attrs[k] = v; },
|
|
68
|
+
append(...xs) { for (const x of xs) this.appendChild(x); },
|
|
69
|
+
appendChild(x) { this.children.push(x); return x; },
|
|
70
|
+
replaceChildren() { this.children = []; },
|
|
71
|
+
addEventListener(t, f) { this.listeners[t] = f; },
|
|
72
|
+
};
|
|
73
|
+
return n;
|
|
74
|
+
};
|
|
75
|
+
return { createElement: make };
|
|
76
|
+
};
|
|
77
|
+
const all = (n, cls) => (n.className && n.className.split(" ").includes(cls) ? [n] : []).concat(...(n.children || []).map((c) => all(c, cls)));
|
|
78
|
+
|
|
79
|
+
it("draws a section a wave and a button a root, and opens a root's resources on a tap", () => {
|
|
80
|
+
const doc = fakeDocument();
|
|
81
|
+
const host = doc.createElement("section");
|
|
82
|
+
const list = waveListOf(marks, { "cluster-a": { head: "1 of 2 resources change.", rows: [{ address: "aws_sqs_queue.events", state: "change", words: "changes" }], more: 3 } });
|
|
83
|
+
const tapped = [];
|
|
84
|
+
drawWaveList(host, list, { doc, open: new Set(["cluster-a"]), onToggle: (r) => tapped.push(r) });
|
|
85
|
+
expect(host.hidden).toBe(false);
|
|
86
|
+
expect(all(host, "k-wl-wave-head").map((h) => h.textContent)).toEqual(["Wave 1 · succeeded", "Wave 2 · 1 failed, 1 applied", "Wave 3 · blocked"]);
|
|
87
|
+
const rows = all(host, "k-wl-row");
|
|
88
|
+
expect(rows).toHaveLength(5);
|
|
89
|
+
// The open root says it is open, and lists its resources under it.
|
|
90
|
+
const open = all(host, "k-wl-open");
|
|
91
|
+
expect(open.map((li) => li.dataset.kRoot)).toEqual(["cluster-a"]);
|
|
92
|
+
expect(all(open[0], "k-wl-res-head")[0].textContent).toBe("1 of 2 resources change.");
|
|
93
|
+
expect(all(open[0], "k-wl-res-more")[0].textContent).toBe("and 3 more");
|
|
94
|
+
rows[2].listeners.click();
|
|
95
|
+
expect(tapped).toEqual(["cluster-b"]);
|
|
96
|
+
});
|
|
97
|
+
it("hides itself with nothing to list", () => {
|
|
98
|
+
const doc = fakeDocument();
|
|
99
|
+
const host = doc.createElement("section");
|
|
100
|
+
drawWaveList(host, null, { doc });
|
|
101
|
+
expect(host.hidden).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
});
|