Skip to content

Commit 78aea57

Browse files
committed
test(webapp): assert the card and the text report stay one report
Landmarks derived from the layout spec must appear in the same order in the server-rendered card and in the markdown, over healthy, degraded, untrustworthy and empty reports.
1 parent 880d94a commit 78aea57

3 files changed

Lines changed: 445 additions & 19 deletions

File tree

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`ANSI surface > paints the same layout (degraded) 1`] = `
4+
"/report health <grey>prod · last 1h · vs your 7d normal</>
5+
6+
<red>✕</> Flow stalled — at your env concurrency limit <amber>for the last 38 min</>
7+
8+
concurrency 50/50 <green>▁</><green>▂</><green>▃</><green>▄</><green>▅</><amber>▆</><amber>▇</><amber>█</> 38 min at limit
9+
10+
pending 4,812 <amber>↑ 120×</> <green>▁</><green>▂</><green>▃</><green>▄</><green>▅</><amber>▆</><amber>▇</><amber>█</> <grey>(normal ~40)</>
11+
12+
start latency p95 43s <amber>↑ 6×</> <green>▁</><green>▂</><green>▃</><green>▄</><green>▅</><amber>▆</><amber>▇</><amber>█</> <grey>(normal ~7s)</>
13+
14+
throughput −180/min
15+
done 820/min
16+
triggered 1,000/min
17+
18+
<grey> why: 71% of pending is demo-email-sends</>
19+
<grey> not your code — failures and durations normal</>
20+
<grey> runs are finishing at ~820/min</>
21+
22+
<green>✓</> EXECUTION the runs that DO start are fine
23+
24+
<green>✓</> LIVENESS fresh — telemetry current, updated 18s ago
25+
26+
<grey> read: limit saturated → incoming work exceeds capacity → backlog grows</>
27+
<grey> NOT a code problem</>
28+
29+
→ Contact us to raise the limit
30+
Read concurrency docs
31+
or do nothing — backlog drains in ~26.7 min once triggers ease"
32+
`;
33+
34+
exports[`ANSI surface > paints the same layout (empty) 1`] = `
35+
"/report health <grey>prod · last 1h</>
36+
37+
<green>✓</> health ok
38+
39+
<green>✓</> data fresh
40+
41+
→ nothing to do"
42+
`;
43+
44+
exports[`ANSI surface > paints the same layout (healthy) 1`] = `
45+
"/report health <grey>prod · last 1h · vs your 7d normal</>
46+
47+
<green>✓</> Flow healthy — starting normally
48+
49+
start latency p95 6.8s <grey>→ flat</> <amber>▇</><amber>▆</><green>▁</><green>▅</><amber>█</><green>▂</><green>▃</><amber>█</> <grey>(normal ~7s)</>
50+
51+
pending 34 <grey>→ flat</> <amber>▇</><amber>▆</><green>▁</><green>▅</><amber>█</><green>▂</><green>▃</><amber>█</> <grey>(normal ~40)</>
52+
53+
throughput +12/min
54+
done 842/min
55+
triggered 830/min
56+
57+
<green>✓</> EXECUTION the runs that DO start are fine
58+
59+
<green>✓</> LIVENESS fresh — telemetry current, updated 21s ago
60+
61+
<grey> read: runs are starting on time</>
62+
<grey> runs are completing normally</>
63+
64+
→ nothing to do"
65+
`;
66+
67+
exports[`ANSI surface > paints the same layout (untrustworthy) 1`] = `
68+
"/report health <amber>⚑</> stale data <grey>prod · last 1h · vs your 7d normal</>
69+
70+
<red>✕</> Flow unknown — data stale
71+
72+
<amber>⚑</> The telemetry behind this report is stale, so the numbers below are informational only.
73+
74+
<red>✕</> EXECUTION execution can't be assessed — the telemetry is stale
75+
76+
<red>✕</> LIVENESS stale — no telemetry in 21m
77+
78+
liveness 21m
79+
80+
→ Check control plane"
81+
`;
82+
83+
exports[`markdown surface > renders (degraded) 1`] = `
84+
"/report health prod · last 1h · vs your 7d normal
85+
86+
🔴 Flow stalled — at your env concurrency limit for the last 38 min
87+
88+
concurrency 50/50 ▁▂▃▄▅▆▇█ 38 min at limit
89+
90+
pending 4,812 ↑ 120× ▁▂▃▄▅▆▇█ (normal ~40)
91+
92+
start latency p95 43s ↑ 6× ▁▂▃▄▅▆▇█ (normal ~7s)
93+
94+
throughput −180/min
95+
done 820/min
96+
triggered 1,000/min
97+
98+
why: 71% of pending is demo-email-sends
99+
not your code — failures and durations normal
100+
runs are finishing at ~820/min
101+
102+
🟢 EXECUTION the runs that DO start are fine
103+
104+
🟢 LIVENESS fresh — telemetry current, updated 18s ago
105+
106+
read: limit saturated → incoming work exceeds capacity → backlog grows
107+
NOT a code problem
108+
109+
→ Contact us to raise the limit
110+
Read concurrency docs
111+
or do nothing — backlog drains in ~26.7 min once triggers ease"
112+
`;
113+
114+
exports[`markdown surface > renders (empty) 1`] = `
115+
"/report health prod · last 1h
116+
117+
🟢 health ok
118+
119+
🟢 data fresh
120+
121+
→ nothing to do"
122+
`;
123+
124+
exports[`markdown surface > renders (healthy) 1`] = `
125+
"/report health prod · last 1h · vs your 7d normal
126+
127+
🟢 Flow healthy — starting normally
128+
129+
start latency p95 6.8s → flat ▇▆▁▅█▂▃█ (normal ~7s)
130+
131+
pending 34 → flat ▇▆▁▅█▂▃█ (normal ~40)
132+
133+
throughput +12/min
134+
done 842/min
135+
triggered 830/min
136+
137+
🟢 EXECUTION the runs that DO start are fine
138+
139+
🟢 LIVENESS fresh — telemetry current, updated 21s ago
140+
141+
read: runs are starting on time
142+
runs are completing normally
143+
144+
→ nothing to do"
145+
`;
146+
147+
exports[`markdown surface > renders (untrustworthy) 1`] = `
148+
"/report health 🚩 stale data prod · last 1h · vs your 7d normal
149+
150+
🔴 Flow unknown — data stale
151+
152+
🚩 The telemetry behind this report is stale, so the numbers below are informational only.
153+
154+
🔴 EXECUTION execution can't be assessed — the telemetry is stale
155+
156+
🔴 LIVENESS stale — no telemetry in 21m
157+
158+
liveness 21m
159+
160+
→ Check control plane"
161+
`;

apps/webapp/test/reportHealth.test.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,24 @@ describe("health cause tree (Golden A — env limit saturation)", () => {
105105
expect(renderReportMarkdown(vm)).toMatchInlineSnapshot(`
106106
"/report health prod · last 1h · vs your 7d normal
107107
108-
🟡 Flow slowing · 🟢 Execution healthy · 🟢 data fresh
109-
110-
FLOW 🟡 at your env concurrency limit (last 40 min)
108+
🟡 Flow slowing — at your env concurrency limit for the last 40 min
111109
112110
concurrency 100/100 ▁▅▆█████ 40 min at limit
113111
114112
pending 1,910 ↑ 16× ▁▁▂▃▅▅▇█ (normal ~120)
115113
116114
start latency p95 42s ↑ 6× ▁▁▂▄▆▆▇█ (normal ~7s)
117115
118-
worst queue email-sends — 82% of pending
119-
120-
read: limit saturated → incoming work exceeds capacity → backlog grows
116+
why: 82% of pending is email-sends
121117
runs are finishing at ~820/min
122118
nothing dead-lettered
123119
124-
EXECUTION 🟢 the runs that DO start are fine
120+
🟢 EXECUTION the runs that DO start are fine
125121
126-
failures 1.3% (normal ~1.1%) · durations normal
127-
read: runs are completing normally
122+
🟢 LIVENESS fresh — telemetry current, updated 4s ago
128123
129-
LIVENESS 🟢 fresh — telemetry current, updated 4s ago
124+
read: limit saturated → incoming work exceeds capacity → backlog grows
125+
runs are completing normally
130126
131127
→ Raise the env concurrency limit
132128
Read concurrency docs
@@ -148,13 +144,22 @@ describe("health (Golden B — healthy)", () => {
148144
expect(renderReportMarkdown(vm)).toMatchInlineSnapshot(`
149145
"/report health prod · last 1h · vs your 7d normal
150146
151-
🟢 Flow healthy · 🟢 Execution healthy · 🟢 data fresh
147+
🟢 Flow healthy — starting normally
148+
149+
start latency p95 6s → flat ██▅▅▂▁▁▂ (normal ~7s)
150+
151+
pending 84 → flat ██▄▄▂▃▃▁ (normal ~120)
152+
153+
throughput 0/min
154+
done 1,000/min
155+
triggered 1,000/min
152156
153-
FLOW 🟢 starting normally — pending 84 (normal ~120) · starts p95 6s
157+
🟢 EXECUTION the runs that DO start are fine
154158
155-
EXECUTION 🟢 completing normallyfailures 0.9% (normal ~1.1%) · durations normal
159+
🟢 LIVENESS freshtelemetry current, updated 2s ago
156160
157-
LIVENESS 🟢 fresh — telemetry current, updated 2s ago
161+
read: runs are starting on time
162+
runs are completing normally
158163
159164
→ nothing to do"
160165
`);
@@ -176,11 +181,12 @@ describe("snapshot fallback path flags the estimated backlog trend", () => {
176181
},
177182
};
178183

179-
it("renders an (estimated) caveat on the proxy series, not a bare sparkline", () => {
184+
it("renders an estimated caveat on the proxy series, not a bare sparkline", () => {
180185
const vm = interpret(snapshot);
181186
expect(vm.findings.find((f) => f.type === "flow")!.reason).toBe("backlog");
182187
const md = renderReportMarkdown(vm);
183-
expect(md).toContain("(estimated)"); // the human surface signals the trend is a proxy
188+
// the human surface signals the trend is a proxy
189+
expect(md).toContain("(estimated from a proxy signal)");
184190
});
185191
});
186192

@@ -509,7 +515,8 @@ describe("stale-telemetry trust guard covers flow (not just execution)", () => {
509515
// just repeat that), and no stale causal evidence (anomaly window) survives.
510516
const md = renderReportMarkdown(stale);
511517
expect(md).toContain("🔴 Flow unknown — data stale");
512-
expect(md).toContain("🔴 flow can't be assessed");
518+
expect(md).toContain("🔴 EXECUTION execution can't be assessed");
519+
expect(md).toContain("🚩 stale data"); // the report flags itself untrustworthy
513520
expect(md).not.toContain("(last 40 min)"); // anomaly window gone
514521
});
515522

@@ -530,9 +537,9 @@ describe("stale-telemetry trust guard covers flow (not just execution)", () => {
530537
});
531538

532539
describe("freshness unknown is distinct from lagging", () => {
533-
it("renders 'data freshness unknown' in the summary, not 'data lagging'", () => {
540+
it("renders the liveness section as 'freshness unknown', not 'data lagging'", () => {
534541
const md = renderReportMarkdown(interpret({ ...INPUT_A, liveness: { telemetryAgeMs: null } }));
535-
expect(md).toContain("data freshness unknown");
542+
expect(md).toContain("⚪ LIVENESS freshness unknown");
536543
expect(md).not.toContain("data lagging");
537544
});
538545

0 commit comments

Comments
 (0)