@intentius/behold 0.30.1 → 0.31.0

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 (129) hide show
  1. package/AGENTS.md +475 -16
  2. package/README.md +25 -19
  3. package/demos.json +14 -9
  4. package/dist/cli.js +54900 -26771
  5. package/example-carve/README.md +19 -23
  6. package/example-carve/app/package.json +1 -1
  7. package/example-carve/app/src/carved.ts +3 -3
  8. package/example-carve/carve-report.json +1 -1
  9. package/example-carve/{legacy-tf → tf-root}/terraform.tfstate +1 -1
  10. package/example-choudoufu-estate/README.md +7 -0
  11. package/example-choudoufu-estate/chant.workspace.json +1 -1
  12. package/example-choudoufu-estate/scripts/choudoufu-down.sh +2 -1
  13. package/example-choudoufu-estate/scripts/choudoufu-up.sh +10 -3
  14. package/example-terraform-estate/README.md +32 -5
  15. package/example-terraform-estate/chant.workspace.json +1 -1
  16. package/example-terraform-estate/recorded/adoption/platform.json +72 -0
  17. package/example-terraform-estate/recorded/adoption/prod.json +224 -0
  18. package/example-terralith/README.md +1 -1
  19. package/example-three-cloud/README.md +111 -18
  20. package/example-three-cloud/aws/Pulumi.yaml +15 -0
  21. package/example-three-cloud/aws/index.ts +174 -0
  22. package/example-three-cloud/aws/package-lock.json +2725 -0
  23. package/example-three-cloud/aws/package.json +14 -0
  24. package/example-three-cloud/aws/tsconfig.json +17 -0
  25. package/example-three-cloud/azure/main.tf +48 -0
  26. package/example-three-cloud/azure/site.tf +104 -0
  27. package/example-three-cloud/chant.config.json +9 -0
  28. package/example-three-cloud/chant.workspace.json +30 -4
  29. package/example-three-cloud/dns/chant.config.ts +26 -1
  30. package/example-three-cloud/dns/src/records.component.ts +32 -6
  31. package/example-three-cloud/package-lock.json +48 -27
  32. package/example-three-cloud/package.json +8 -6
  33. package/example-three-cloud/scripts/emulators-up.sh +28 -1
  34. package/example-three-cloud/scripts/front-door.ts +679 -86
  35. package/package.json +13 -6
  36. package/web/adopt-pulumi.js +114 -0
  37. package/web/adopt-pulumi.test.js +28 -0
  38. package/web/adopt.js +203 -0
  39. package/web/adopt.test.js +27 -0
  40. package/web/app.js +614 -19
  41. package/web/carve-steps.js +1 -1
  42. package/web/carve-steps.test.js +2 -2
  43. package/web/change-set-overlay.js +12 -5
  44. package/web/change-set-overlay.test.js +22 -0
  45. package/web/drift-stream.js +241 -0
  46. package/web/drift-stream.test.js +146 -0
  47. package/web/edge-weight.d.ts +1 -1
  48. package/web/edge-weight.js +5 -1
  49. package/web/edge-weight.test.js +19 -0
  50. package/web/embed.js +2 -2
  51. package/web/event-help-modal.js +18 -12
  52. package/web/event-help-modal.test.js +28 -1
  53. package/web/graph-query.js +180 -0
  54. package/web/graph-query.test.js +49 -0
  55. package/web/graph.html +107 -0
  56. package/web/index-diff.js +109 -0
  57. package/web/index-diff.test.js +39 -0
  58. package/web/index.html +55 -0
  59. package/web/kiosk-ask-layout.js +85 -0
  60. package/web/kiosk-ask-layout.test.js +83 -0
  61. package/web/kiosk-ask-tips.js +477 -0
  62. package/web/kiosk-ask-tips.test.js +372 -0
  63. package/web/kiosk-ask.js +774 -0
  64. package/web/kiosk-ask.test.js +593 -0
  65. package/web/kiosk-banner.js +108 -0
  66. package/web/kiosk-banner.test.js +72 -0
  67. package/web/kiosk-center-cards.test.js +110 -0
  68. package/web/kiosk-estate-scene.js +267 -0
  69. package/web/kiosk-estate-scene.test.js +21 -0
  70. package/web/kiosk-event-help.js +4 -1
  71. package/web/kiosk-graph-pane.js +63 -0
  72. package/web/kiosk-graph-pane.test.js +105 -0
  73. package/web/kiosk-light-frame.js +197 -0
  74. package/web/kiosk-light.js +547 -0
  75. package/web/kiosk-light.test.js +297 -0
  76. package/web/kiosk-member-kind.test.js +140 -0
  77. package/web/kiosk-metrics.js +7 -4
  78. package/web/kiosk-modal-sticky.test.js +2 -1
  79. package/web/kiosk-popover.js +4 -1
  80. package/web/kiosk-refit.test.js +81 -0
  81. package/web/kiosk-reset.js +49 -0
  82. package/web/kiosk-reset.test.js +11 -0
  83. package/web/kiosk-shot.js +40 -2
  84. package/web/kiosk-shot.test.js +23 -1
  85. package/web/kiosk-side.js +296 -0
  86. package/web/kiosk-side.test.js +249 -0
  87. package/web/kiosk-vendor.js +85 -7
  88. package/web/kiosk-vendor.test.js +9 -9
  89. package/web/kiosk-watch.js +20 -4
  90. package/web/kiosk-watch.test.js +15 -1
  91. package/web/kiosk.html +153 -1
  92. package/web/kiosk.js +252 -27
  93. package/web/kiosk.test.js +25 -1
  94. package/web/member-kind.js +31 -0
  95. package/web/small-stage.test.js +4 -0
  96. package/web/template-apps.js +245 -0
  97. package/web/template-apps.test.js +252 -0
  98. package/web/templates.js +285 -0
  99. package/web/templates.test.js +155 -0
  100. package/web/terragucci-change.js +30 -13
  101. package/web/terragucci-lifecycle.js +112 -62
  102. package/web/terragucci-lifecycle.test.js +29 -1
  103. package/web/terragucci-timeline.js +39 -2
  104. package/web/terragucci-timeline.test.js +42 -1
  105. package/web/tool-mark.js +4 -4
  106. package/web/tool-mark.test.js +1 -1
  107. package/web/vendors/atmos.svg +1 -0
  108. package/web/vendors/chant.svg +1 -0
  109. package/web/vendors/choudoufu.svg +1 -0
  110. package/web/vendors/terragrunt.svg +9 -0
  111. package/web/vendors/terragucci.svg +1 -0
  112. package/example-three-cloud/aws/chant.config.ts +0 -8
  113. package/example-three-cloud/aws/site.component.ts +0 -13
  114. package/example-three-cloud/aws/src/site.ts +0 -27
  115. package/example-three-cloud/azure/chant.config.ts +0 -1
  116. package/example-three-cloud/azure/src/site.component.ts +0 -13
  117. package/example-three-cloud/azure/src/site.ts +0 -18
  118. package/web/vendors/choudoufu-128.png +0 -0
  119. package/web/vendors/choudoufu-64.png +0 -0
  120. /package/example-carve/{legacy-tf → tf-root}/cdn.tf +0 -0
  121. /package/example-carve/{legacy-tf → tf-root}/compute.tf +0 -0
  122. /package/example-carve/{legacy-tf → tf-root}/floci-override.tf.disabled +0 -0
  123. /package/example-carve/{legacy-tf → tf-root}/modules/cdn/main.tf +0 -0
  124. /package/example-carve/{legacy-tf → tf-root}/naming.tf +0 -0
  125. /package/example-carve/{legacy-tf → tf-root}/network.tf +0 -0
  126. /package/example-carve/{legacy-tf → tf-root}/observability.tf +0 -0
  127. /package/example-carve/{legacy-tf → tf-root}/outputs.tf +0 -0
  128. /package/example-carve/{legacy-tf → tf-root}/storage.tf +0 -0
  129. /package/example-carve/{legacy-tf → tf-root}/versions.tf +0 -0
@@ -0,0 +1,372 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { ATMOS_TIP, CHANT_TIPS, DEFAULT_TIPS, EDGE, LINK_RESUME_MS, PLAIN_FREE_TIP, TERRAGRUNT_TIP, TIP_FADE_MS, TIP_MIN_MS, TIP_QUIET_MS, TIP_WAIT_MS, actTip, actTips, createTipSequencer, dockCorner, holdMs, safeLink, shouldDismiss, tipArea } from "./kiosk-ask-tips.js";
3
+
4
+ function rig(opts = {}) {
5
+ const log = [];
6
+ let t = 0;
7
+ const timers = [];
8
+ const seq = createTipSequencer({
9
+ show: (tip) => log.push(["show", tip.title, t]),
10
+ hide: () => log.push(["hide", t]),
11
+ setTimer: (f, ms) => {
12
+ const x = { f, at: t + ms };
13
+ timers.push(x);
14
+ return x;
15
+ },
16
+ clearTimer: (x) => {
17
+ const i = timers.indexOf(x);
18
+ if (i >= 0) timers.splice(i, 1);
19
+ },
20
+ now: () => t,
21
+ ...opts,
22
+ });
23
+ const advance = (ms) => {
24
+ const to = t + ms;
25
+ for (;;) {
26
+ const next = timers.filter((x) => x.at <= to).sort((a, b) => a.at - b.at)[0];
27
+ if (!next) break;
28
+ timers.splice(timers.indexOf(next), 1);
29
+ t = next.at;
30
+ next.f();
31
+ }
32
+ t = to;
33
+ };
34
+ return { seq, log, advance };
35
+ }
36
+ const tips = [1, 2, 3].map((n) => ({ title: `T${n}`, body: `B${n}` }));
37
+ const busy = (id, extra = {}) => ({ busy: true, id, cycle: 1, scenario: "s", step: "applying", tips: null, ...extra });
38
+ const idle = { busy: false, id: null, tips: null };
39
+ const shows = (log) => log.filter((x) => x[0] === "show");
40
+
41
+ describe("tip cards: the terminal wins", () => {
42
+ it("waits for the busy line to have run 6 s, then shows the step's first tip", () => {
43
+ const { seq, log, advance } = rig();
44
+ seq.busy(busy("a", { tips }));
45
+ advance(TIP_WAIT_MS - 1);
46
+ expect(log).toEqual([]);
47
+ advance(1);
48
+ expect(log).toEqual([["show", "T1", TIP_WAIT_MS]]);
49
+ });
50
+ it("shows nothing for a busy line shorter than the wait (a prompt's 1.2 s think)", () => {
51
+ const { seq, log, advance } = rig();
52
+ seq.busy(busy("a", { tips }));
53
+ advance(1_200);
54
+ seq.busy(idle);
55
+ advance(60_000);
56
+ expect(log).toEqual([]);
57
+ });
58
+ it("takes the tip down the moment the busy line ends, or any new line starts", () => {
59
+ for (const end of [(s) => s.busy(idle), (s) => s.line(), (s) => s.busy(busy("b"))]) {
60
+ const { seq, log, advance } = rig();
61
+ seq.busy(busy("a", { tips }));
62
+ advance(TIP_WAIT_MS + 1_000);
63
+ end(seq);
64
+ expect(log).toEqual([["show", "T1", TIP_WAIT_MS], ["hide", TIP_WAIT_MS + 1_000]]);
65
+ }
66
+ });
67
+ it("starts no tip in the 2 s after a terminal event, even when the busy line is old enough", () => {
68
+ const { seq, log, advance } = rig({ pick: () => ({ title: "D", body: "d" }) });
69
+ seq.busy(busy("a"));
70
+ advance(TIP_WAIT_MS - 500);
71
+ seq.line();
72
+ advance(TIP_QUIET_MS - 1);
73
+ expect(log).toEqual([]);
74
+ advance(1);
75
+ expect(log).toEqual([["show", "D", TIP_WAIT_MS - 500 + TIP_QUIET_MS]]);
76
+ });
77
+ it("keeps a tip its reading time while the wait lasts, then hides it; a long wait then shows the second after a 2 s gap", () => {
78
+ const { seq, log, advance } = rig();
79
+ seq.busy(busy("a", { tips }));
80
+ advance(TIP_WAIT_MS + TIP_MIN_MS);
81
+ expect(log).toEqual([["show", "T1", TIP_WAIT_MS], ["hide", TIP_WAIT_MS + TIP_MIN_MS]]);
82
+ advance(TIP_QUIET_MS - 1);
83
+ expect(log).toHaveLength(2);
84
+ advance(1);
85
+ const at = TIP_WAIT_MS + TIP_MIN_MS + TIP_QUIET_MS;
86
+ expect(log).toEqual([["show", "T1", TIP_WAIT_MS], ["hide", TIP_WAIT_MS + TIP_MIN_MS], ["show", "T2", at]]);
87
+ advance(TIP_MIN_MS + 120_000);
88
+ expect(shows(log)).toHaveLength(2);
89
+ });
90
+ it("shows two tips per act, never at once: later waits of the same scenario show no third, the next scenario's do", () => {
91
+ const { seq, log, advance } = rig();
92
+ seq.busy(busy("a", { tips }));
93
+ advance(30_000);
94
+ seq.busy(busy("b", { tips }));
95
+ advance(30_000);
96
+ seq.busy(busy("c", { tips, step: "applied" }));
97
+ advance(30_000);
98
+ expect(shows(log).map((x) => x[1])).toEqual(["T1", "T2"]);
99
+ seq.busy(busy("d", { tips, scenario: "s2" }));
100
+ advance(30_000);
101
+ expect(shows(log)).toHaveLength(4);
102
+ seq.busy(busy("e", { tips, cycle: 2 }));
103
+ advance(TIP_WAIT_MS);
104
+ expect(shows(log)).toHaveLength(5);
105
+ // Never two up together.
106
+ let up = 0;
107
+ for (const x of log) {
108
+ up += x[0] === "show" ? 1 : -1;
109
+ expect(up).toBeLessThanOrEqual(1);
110
+ }
111
+ });
112
+ it("gives the second tip its own qualifying wait after the first was cut short by a terminal event", () => {
113
+ const { seq, log, advance } = rig();
114
+ seq.busy(busy("a", { tips }));
115
+ advance(TIP_WAIT_MS + 1_000);
116
+ seq.busy(busy("b", { tips }));
117
+ advance(TIP_WAIT_MS - 1);
118
+ expect(shows(log)).toHaveLength(1);
119
+ advance(1);
120
+ expect(shows(log).map((x) => x[1])).toEqual(["T1", "T2"]);
121
+ });
122
+ it("shows no second tip when the rest of the wait is shorter than its reading time", () => {
123
+ const { seq, log, advance } = rig();
124
+ seq.busy(busy("a", { tips, until: TIP_WAIT_MS + TIP_MIN_MS + TIP_QUIET_MS + TIP_MIN_MS - 1 }));
125
+ advance(60_000);
126
+ expect(shows(log).map((x) => x[1])).toEqual(["T1"]);
127
+ seq.busy(busy("b", { tips }));
128
+ advance(TIP_WAIT_MS);
129
+ expect(shows(log).map((x) => x[1])).toEqual(["T1", "T2"]);
130
+ });
131
+ it("shows no second tip once the viewer closed the first", () => {
132
+ const { seq, log, advance } = rig();
133
+ seq.busy(busy("a", { tips }));
134
+ advance(TIP_WAIT_MS);
135
+ seq.dismiss();
136
+ advance(120_000);
137
+ seq.busy(busy("b", { tips }));
138
+ advance(120_000);
139
+ expect(shows(log)).toHaveLength(1);
140
+ });
141
+ it("takes the second tip down the moment the terminal does anything", () => {
142
+ const { seq, log, advance } = rig();
143
+ seq.busy(busy("a", { tips }));
144
+ advance(TIP_WAIT_MS + TIP_MIN_MS + TIP_QUIET_MS + 500);
145
+ seq.line();
146
+ expect(log.slice(-2)).toEqual([["show", "T2", TIP_WAIT_MS + TIP_MIN_MS + TIP_QUIET_MS], ["hide", TIP_WAIT_MS + TIP_MIN_MS + TIP_QUIET_MS + 500]]);
147
+ });
148
+ it("keeps the act's tip for a later wait when there was no room for it", () => {
149
+ let room = false;
150
+ const { seq, log, advance } = rig();
151
+ const r = rig({ show: (tip) => (room ? (log.push(["show", tip.title]), true) : false) });
152
+ r.seq.busy(busy("a", { tips }));
153
+ r.advance(30_000);
154
+ expect(log).toEqual([]);
155
+ room = true;
156
+ r.seq.busy(busy("b", { tips }));
157
+ r.advance(TIP_WAIT_MS);
158
+ expect(log).toEqual([["show", "T1"]]);
159
+ expect(seq.current()).toBe(null);
160
+ advance(0);
161
+ });
162
+ it("holds a long card longer than the minimum: about 3 words a second", () => {
163
+ expect(holdMs({ title: "Hi", body: "short" })).toBe(TIP_MIN_MS);
164
+ const long = { title: "All at once", body: "word ".repeat(30).trim() };
165
+ expect(holdMs(long)).toBe(3_000 + 33 * 330);
166
+ });
167
+ it("ignores a repeat of the same busy line, and shows nothing while the Tips switch is off", () => {
168
+ let on = false;
169
+ const { seq, log, advance } = rig({ enabled: () => on });
170
+ seq.busy(busy("a", { tips }));
171
+ advance(30_000);
172
+ expect(log).toEqual([]);
173
+ on = true;
174
+ seq.busy(busy("b", { tips }));
175
+ advance(TIP_WAIT_MS - 1);
176
+ seq.busy(busy("b", { tips }));
177
+ advance(1);
178
+ expect(shows(log)).toHaveLength(1);
179
+ seq.off();
180
+ expect(log.at(-1)[0]).toBe("hide");
181
+ });
182
+ it("a card the viewer closed is gone without a second hide, and the act is spent", () => {
183
+ const { seq, log, advance } = rig();
184
+ seq.busy(busy("a", { tips }));
185
+ advance(TIP_WAIT_MS);
186
+ seq.dismiss();
187
+ seq.busy(idle);
188
+ seq.busy(busy("b", { tips }));
189
+ advance(60_000);
190
+ expect(log).toEqual([["show", "T1", TIP_WAIT_MS]]);
191
+ });
192
+ it("fades well inside 400 ms", () => {
193
+ expect(TIP_FADE_MS).toBeLessThan(400);
194
+ });
195
+ });
196
+
197
+ describe("tip cards: the built-in tips per act", () => {
198
+ it("follows an edit act's card with Free, nothing to host (choudoufu alone on Terragrunt and Atmos), a create act's with Inspect", () => {
199
+ expect(actTips("choudoufu-compose-edit")).toEqual([DEFAULT_TIPS[2], DEFAULT_TIPS[3]]);
200
+ for (const sc of ["terragrunt-choudoufu-edit", "atmos-choudoufu-edit"]) expect(actTips(sc)).toEqual([DEFAULT_TIPS[2], PLAIN_FREE_TIP]);
201
+ expect(actTips("choudoufu-compose-create")).toEqual([DEFAULT_TIPS[0], DEFAULT_TIPS[4]]);
202
+ expect(actTips("terragrunt-choudoufu-create")).toEqual([TERRAGRUNT_TIP, DEFAULT_TIPS[4]]);
203
+ expect(actTips("atmos-choudoufu-create")).toEqual([ATMOS_TIP, DEFAULT_TIPS[4]]);
204
+ expect(actTips("chant-compose-edit")).toEqual([CHANT_TIPS[0]]);
205
+ expect(actTips("chant-compose-create")).toEqual([CHANT_TIPS[1]]);
206
+ expect(DEFAULT_TIPS[4]).toEqual({ title: "Inspect", body: "Open Inspect to explore every resource and the plan behind it." });
207
+ expect(PLAIN_FREE_TIP.body).toBe("choudoufu is free and open source. There is no server or database to host. It runs in the CI pipeline you already have.");
208
+ expect(PLAIN_FREE_TIP.link.url).toBe("https://github.com/INTENTIUS/choudoufu");
209
+ expect(DEFAULT_TIPS[3].body).toBe("Both are free and open source. There is no server or database to host. Everything runs in CI pipelines.");
210
+ });
211
+ it("shows an edit act's two cards in turn", () => {
212
+ const { seq, log, advance } = rig();
213
+ seq.busy(busy("a", { scenario: "atmos-choudoufu-edit" }));
214
+ advance(120_000);
215
+ expect(shows(log).map((x) => x[1])).toEqual(["choudoufu", "Free, nothing to host"]);
216
+ });
217
+ it("gives a create act the known-after-apply card and any other act the tool's card", () => {
218
+ expect(actTip("choudoufu-compose-create")).toBe(DEFAULT_TIPS[0]);
219
+ expect(actTip("choudoufu-compose-edit")).toBe(DEFAULT_TIPS[2]);
220
+ expect(actTip("b-composed").title).toBe("choudoufu");
221
+ expect(actTip("chant-compose-create")).toBe(CHANT_TIPS[1]);
222
+ expect(actTip("chant-compose-edit")).toBe(CHANT_TIPS[0]);
223
+ expect(actTip("terragrunt-choudoufu-create")).toBe(TERRAGRUNT_TIP);
224
+ expect(actTip("atmos-choudoufu-create")).toBe(ATMOS_TIP);
225
+ expect(actTip("terragrunt-choudoufu-edit").title).toBe("choudoufu");
226
+ });
227
+ it("uses the act's built-in tip when the step has none of its own", () => {
228
+ const { seq, log, advance } = rig();
229
+ seq.busy(busy("a", { scenario: "chant-compose-edit" }));
230
+ advance(TIP_WAIT_MS);
231
+ expect(log).toEqual([["show", "One plan, one note", TIP_WAIT_MS]]);
232
+ });
233
+ it("keeps other products' names off the Terragrunt, Atmos and chant demos' cards", () => {
234
+ for (const sc of ["terragrunt-choudoufu-create", "terragrunt-choudoufu-edit", "atmos-choudoufu-create", "atmos-choudoufu-edit"]) for (const t of actTips(sc)) expect(`${t.title} ${t.body}`).not.toMatch(/terragucci/);
235
+ expect(`${ATMOS_TIP.body}`).not.toMatch(/terragrunt|same apply|one apply/i);
236
+ expect(`${TERRAGRUNT_TIP.body}`).not.toMatch(/atmos/i);
237
+ for (const sc of ["chant-compose-edit", "chant-compose-create"]) expect(`${actTip(sc).title} ${actTip(sc).body} ${actTip(sc).link.url}`).not.toMatch(/choudoufu|terragucci|terragrunt|atmos|opentofu/i);
238
+ });
239
+ it("shows a plain string tip as a body with no title, and drops a tip with no body", () => {
240
+ const shown = [];
241
+ const seq = createTipSequencer({ show: (t) => shown.push(t), hide() {}, pick: () => null, waitMs: 0, quietMs: 0, setTimer: (f) => (f(), 1), clearTimer() {}, now: () => 0 });
242
+ seq.busy({ busy: true, id: "b1", cycle: 1, scenario: "atmos-choudoufu-edit", tips: ["Plain words.", { title: "T", body: "B" }, { title: "No body" }, 4] });
243
+ expect(shown).toEqual([{ body: "Plain words." }, { title: "T", body: "B" }]);
244
+ });
245
+ });
246
+
247
+ describe("tip cards: links", () => {
248
+ it("allows only https on intentius.io or github.com/INTENTIUS in a step's own tips", () => {
249
+ expect(safeLink({ label: "L", url: "https://intentius.io/a/" })).toEqual({ label: "L", url: "https://intentius.io/a/" });
250
+ expect(safeLink({ url: "https://www.intentius.io/a" }).label).toBe("Read how");
251
+ expect(safeLink({ url: "https://github.com/INTENTIUS/choudoufu" })).not.toBeNull();
252
+ for (const url of ["http://intentius.io/", "https://evil.example/", "https://intentius.io.evil.example/", "https://github.com/other/x", "https://github.com/INTENTIUSX/x", "https://user@intentius.io/", "javascript:alert(1)", "nope"]) {
253
+ expect(safeLink({ label: "L", url })).toBeNull();
254
+ }
255
+ expect(safeLink(null)).toBeNull();
256
+ });
257
+ it("drops a bad link from a step's own tip and keeps the card", () => {
258
+ const shown = [];
259
+ const r = rig({ show: (tip) => shown.push(tip), waitMs: 0, quietMs: 0 });
260
+ r.seq.busy(busy("a", { tips: [{ title: "T", body: "b", link: { label: "x", url: "https://evil.example/" } }] }));
261
+ r.advance(0);
262
+ expect(shown).toEqual([{ title: "T", body: "b" }]);
263
+ });
264
+ it("gives the built-in links their exact URLs", () => {
265
+ const by = Object.fromEntries(DEFAULT_TIPS.map((t) => [t.title, t.link]));
266
+ expect(by["All at once"]).toEqual({ label: "How it plans across estates", url: "https://intentius.io/choudoufu/how-it-works/across-estates/" });
267
+ expect(by.choudoufu).toEqual({ label: "How the locking works", url: "https://intentius.io/choudoufu/how-it-works/locking/" });
268
+ expect(TERRAGRUNT_TIP.link.url).toBe("https://docs.terragrunt.com/features/stacks/run-queue/#saving-opentofuterraform-plan-output");
269
+ expect(ATMOS_TIP.link.url).toBe("https://atmos.tools/functions/yaml/terraform.output");
270
+ });
271
+ it("keeps the audited wording of the built-in bodies", () => {
272
+ const by = Object.fromEntries(DEFAULT_TIPS.map((t) => [t.title, t.body]));
273
+ expect(by["All at once"]).toBe("Every estate plans together. The plan marks where the new subnet's id goes, and the same apply fills it in. With separate state runs, a downstream root sees that id only after its upstream applies.");
274
+ expect(by.choudoufu).toBe("choudoufu is a fork of OpenTofu. A root that calls your estates as modules plans and applies them in one pass, and each estate keeps its own records. Resource-level locking at the cloud level.");
275
+ expect(TERRAGRUNT_TIP.body).toBe("Terragrunt plans a unit whose upstream isn't applied yet with mock outputs. With choudoufu, the plan shows the real subnet id as known after apply. One apply fills it in.");
276
+ expect(ATMOS_TIP.body).toBe("Atmos plans each component against its upstream's last applied outputs, or a mock default. With choudoufu, one plan covers every component. The merge applies each one exactly as reviewed.");
277
+ for (const t of [...DEFAULT_TIPS, TERRAGRUNT_TIP, ATMOS_TIP, ...CHANT_TIPS]) expect(t.body).not.toMatch(/atomic|transaction/i);
278
+ });
279
+ it("hover pauses a linked card; leaving resumes with at least 3 s left", () => {
280
+ const { seq, log, advance } = rig({ waitMs: 0, quietMs: 0 });
281
+ seq.busy(busy("a", { tips: [{ title: "A", body: "a", link: { label: "L", url: "https://intentius.io/a/" } }] }));
282
+ advance(2_000);
283
+ seq.pause();
284
+ advance(60_000);
285
+ expect(log).toHaveLength(1);
286
+ seq.resume();
287
+ advance(TIP_MIN_MS - 2_000 - 1);
288
+ expect(log).toHaveLength(1);
289
+ advance(1);
290
+ expect(log.at(-1)[0]).toBe("hide");
291
+ });
292
+ it("gives at least 3 s after leaving when little was left, and does not pause a card without a link", () => {
293
+ const { seq, log, advance } = rig({ waitMs: 0, quietMs: 0 });
294
+ seq.busy(busy("a", { tips: [{ title: "A", body: "a", link: { label: "L", url: "https://intentius.io/a/" } }] }));
295
+ advance(TIP_MIN_MS - 500);
296
+ seq.pause();
297
+ advance(5_000);
298
+ seq.resume();
299
+ advance(LINK_RESUME_MS - 1);
300
+ expect(log).toHaveLength(1);
301
+ advance(1);
302
+ expect(log).toHaveLength(2);
303
+ const r = rig({ waitMs: 0, quietMs: 0 });
304
+ r.seq.busy(busy("a", { tips: tips.slice(0, 1) }));
305
+ r.advance(0);
306
+ r.seq.pause();
307
+ r.advance(TIP_MIN_MS);
308
+ expect(r.log.at(-1)[0]).toBe("hide");
309
+ });
310
+ });
311
+
312
+ describe("tip cards: the dock", () => {
313
+ const area = { left: 0, top: 0, width: 1000, height: 500 };
314
+ it("docks top right when nothing lit is there", () => {
315
+ expect(dockCorner(area, 300, 100, [])).toEqual({ corner: "top-right", left: 1000 - EDGE - 300, top: EDGE });
316
+ });
317
+ it("moves to the next clear corner when a lit box (or its lines) is in the way", () => {
318
+ expect(dockCorner(area, 300, 100, [{ left: 800, top: 30, width: 100, height: 40 }]).corner).toBe("top-left");
319
+ expect(dockCorner(area, 300, 100, [{ left: 800, top: 30, width: 100, height: 40 }, { left: 50, top: 50, width: 60, height: 40 }]).corner).toBe("bottom-right");
320
+ // A box under the card's foot still counts: its attribute lines hang below it.
321
+ expect(dockCorner(area, 300, 100, [{ left: 800, top: 140, width: 100, height: 10 }]).corner).toBe("top-right");
322
+ expect(dockCorner(area, 300, 100, [{ left: 800, top: 70, width: 100, height: 10 }]).corner).toBe("top-left");
323
+ });
324
+ it("gives no corner when every one is covered or the card does not fit", () => {
325
+ expect(dockCorner(area, 300, 100, [{ left: 0, top: 0, width: 1000, height: 500 }])).toBeNull();
326
+ expect(dockCorner({ left: 0, top: 0, width: 200, height: 500 }, 300, 100, [])).toBeNull();
327
+ expect(dockCorner(null, 300, 100, [])).toBeNull();
328
+ });
329
+ });
330
+
331
+ describe("tip cards: a press outside closes", () => {
332
+ const host = {};
333
+ const inside = { closest: (sel) => (sel.includes(".eh-modal") ? {} : null) };
334
+ const outside = { closest: () => null };
335
+ it("closes on a press outside the card, not on one inside (its link)", () => {
336
+ expect(shouldDismiss(outside, host)).toBe(true);
337
+ expect(shouldDismiss(inside, host)).toBe(false);
338
+ expect(shouldDismiss(null, host)).toBe(false);
339
+ });
340
+ });
341
+
342
+ describe("tip cards: a wait about to end", () => {
343
+ it("shows no tip when the busy line is due to end before it could be read, and keeps the act's tip", () => {
344
+ const { seq, log, advance } = rig();
345
+ seq.busy(busy("a", { tips, until: TIP_WAIT_MS + 1_000 }));
346
+ advance(30_000);
347
+ expect(log).toEqual([]);
348
+ seq.busy(busy("b", { tips, until: 30_000 + TIP_WAIT_MS + TIP_MIN_MS + 1 }));
349
+ advance(TIP_WAIT_MS);
350
+ expect(shows(log)).toHaveLength(1);
351
+ });
352
+ it("shows the tip when the due time has passed (the driver is late) or is unknown", () => {
353
+ const { seq, log, advance } = rig();
354
+ advance(10_000);
355
+ seq.busy(busy("a", { tips, until: 5_000 }));
356
+ advance(TIP_WAIT_MS);
357
+ expect(shows(log)).toHaveLength(1);
358
+ });
359
+ });
360
+
361
+ describe("the room a tip docks in", () => {
362
+ const frame = { left: 5, top: 80, right: 1035, bottom: 900 };
363
+ it("is the graph frame above the prompt pane", () => {
364
+ expect(tipArea(frame, { top: 640 }, null)).toEqual({ left: 5, top: 80, width: 1030, height: 560 });
365
+ expect(tipArea(frame, null, null)).toEqual({ left: 5, top: 80, width: 1030, height: 820 });
366
+ });
367
+ it("ends where the side pane starts, open or folded to its tab", () => {
368
+ expect(tipArea(frame, { top: 640 }, { left: 1000, right: 1395, top: 80, bottom: 630 })).toEqual({ left: 5, top: 80, width: 995, height: 560 });
369
+ // A side pane beside the frame (the frame already narrowed for it) leaves the frame's room as it is.
370
+ expect(tipArea(frame, { top: 640 }, { left: 1045, right: 1395, top: 80, bottom: 630 }).width).toBe(1030);
371
+ });
372
+ });