@intentius/behold 0.29.46 → 0.29.48

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.
@@ -15,7 +15,7 @@ import { readTerragucci } from "../src/terragucci-reports.ts";
15
15
  import { terragucciSource } from "../src/terragucci-source.ts";
16
16
  import { cycleFacts, ehSnapshot, storyTrail } from "./kiosk-event-help.js";
17
17
  import { componentMarks, reportStatus } from "./terragucci-components-live.js";
18
- import { resultWords, waveResultOf } from "./terragucci-change.js";
18
+ import { blockedOf, outcomesOf, resultWords, rootStates, waveResultOf } from "./terragucci-change.js";
19
19
 
20
20
  const FIXTURE = join(import.meta.dirname, "..", "src", "__fixtures__", "terragucci-wave-results");
21
21
  const CHANGE = "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab";
@@ -39,10 +39,12 @@ const changeView = runView(CHANGE, "2026-10-19T01:58:52.600Z", [[1, "applied", [
39
39
  const fixView = runView(FIX, "2026-10-19T02:01:47.800Z", [[1, "applied", ["network"]], [2, "applied", ["cluster-a", "cluster-b"]], [3, "applied", [...APPS_A, ...APPS_B]]]);
40
40
 
41
41
  let answer;
42
+ let read;
42
43
  beforeAll(async () => {
43
44
  const structural = { validation: { by: "structural" }, check: (_n, doc) => (doc && typeof doc === "object" ? undefined : "not an object") };
44
45
  const r = await readTerragucci(terragucciSource(FIXTURE), { validator: structural });
45
46
  answer = { roots: [], pull_request: null, results: r.results };
47
+ read = r;
46
48
  });
47
49
 
48
50
  const facts = (snap) => cycleFacts(ehSnapshot({ waves, ...snap }));
@@ -123,3 +125,56 @@ describe("the wave box's title (behold#751)", () => {
123
125
  expect(reportStatus(failed, null)).toBe(failed);
124
126
  });
125
127
  });
128
+
129
+ // behold#770: a tool page's replay of the cycle (kiosk-vendor.js) pins the
130
+ // change's run view (wave 2 failed) after the fix applied, so /api/terragucci's
131
+ // `outcomes` and `blocked` are the fix's, the newest apply's. The replay read
132
+ // cluster-b "failed" and wave 2 "2 failed" from the wave's state, where live it
133
+ // read cluster-b applied beside a failed cluster-a. The change's own reports,
134
+ // in `results`, say how each root came out.
135
+ describe("the replay of the failure, after the fix applied (behold#770)", () => {
136
+ const facets = {
137
+ jobs: [
138
+ { component: "network", jobName: "apply-wave-1", wave: 1 },
139
+ { component: "cluster-a", jobName: "apply-wave-2", wave: 2 },
140
+ { component: "cluster-b", jobName: "apply-wave-2", wave: 2 },
141
+ ...[...APPS_A, ...APPS_B].map((c) => ({ component: c, jobName: "apply-wave-3", wave: 3 })),
142
+ ],
143
+ };
144
+ // /api/terragucci as it answers after the fix's apply: its outcomes are the fix's, and nothing of it is blocked.
145
+ const replayAnswer = () => ({ roots: [], pull_request: null, ...(read.outcomes ? { outcomes: read.outcomes } : {}), ...(read.blocked ? { blocked: read.blocked } : {}), results: read.results });
146
+ const runs = { doc: { runs: [{ id: 6745, commit: CHANGE, jobs: run6745.jobs.map(({ name, status }) => ({ name, status })) }] } };
147
+
148
+ it("is the fixture's case: the read's outcomes are the fix's, not the change's", () => {
149
+ expect(read.outcomes.commit).toBe(FIX);
150
+ expect(read.blocked).toBeUndefined();
151
+ expect(Object.keys(read.results)).toEqual(expect.arrayContaining([CHANGE, FIX]));
152
+ });
153
+
154
+ it("reads each root of the change's run from the change's own reports", () => {
155
+ const o = outcomesOf(replayAnswer(), changeView);
156
+ expect(o.get("cluster-a")).toMatchObject({ wave: 2, outcome: "failed" });
157
+ expect(o.get("cluster-a").error).toMatch(/QueueAlreadyExists/);
158
+ expect(o.get("cluster-b")).toEqual({ wave: 2, outcome: "applied" });
159
+ expect([...blockedOf(replayAnswer(), changeView).keys()].sort()).toEqual(APPS_A);
160
+ expect(blockedOf(replayAnswer(), changeView).get("app-01")).toEqual({ wave: 3, by: "cluster-a" });
161
+ });
162
+
163
+ it("draws cluster-a failed, cluster-b applied, cluster-a's apps blocked and cluster-b's applied", () => {
164
+ const m = componentMarks(replayAnswer(), changeView, facets, { runs, story: { kiosk: true } });
165
+ expect(m.cards["cluster-a"]).toMatchObject({ state: "failed", tone: "bad" });
166
+ expect(m.cards["cluster-b"]).toMatchObject({ state: "applied", tone: "ok", words: "applied" });
167
+ for (const a of APPS_A) expect(m.cards[a]).toMatchObject({ state: "blocked", blockedBy: "cluster-a" });
168
+ for (const a of APPS_B) expect(m.cards[a]).toMatchObject({ state: "applied" });
169
+ expect(m.waves[2].status).toMatchObject({ status: "failed", words: "1 failed, 1 applied", tone: "bad" });
170
+ expect(m.waves[3].title).toBe("apply-wave-3 · 6 applied, 6 blocked by cluster-a");
171
+ });
172
+
173
+ it("holds a wave the paced replay hasn't started, and falls back to the wave's state for a commit the read kept no result of", () => {
174
+ const paced = { ...changeView, states: changeView.states.map((w) => (w.number === 3 ? { ...w, state: "not-started" } : w)) };
175
+ expect(blockedOf(replayAnswer(), paced).size).toBe(0);
176
+ expect(outcomesOf(replayAnswer(), paced).has("app-07")).toBe(false);
177
+ const gone = { ...replayAnswer(), results: { [FIX]: read.results[FIX] } };
178
+ expect(rootStates(gone, changeView, { story: true }).roots["cluster-b"].state).toBe("failed");
179
+ });
180
+ });