Skip to content

Commit d6e1b4e

Browse files
committed
fix(webapp): a self-evident finding keeps its line and drops the echo row
1 parent df020b1 commit d6e1b4e

3 files changed

Lines changed: 62 additions & 1 deletion

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { describe, expect, it } from "vitest";
2+
import { buildReportLayout, type LayoutViewModel } from "./report-layout";
3+
import { reportMessages } from "./report-messages";
4+
5+
const livenessMetric = {
6+
id: "liveness",
7+
value: 21 * 60 * 1000,
8+
unit: "ms" as const,
9+
severity: "crit" as const,
10+
};
11+
12+
function vmWith(findings: LayoutViewModel["findings"]): LayoutViewModel {
13+
return {
14+
title: "health",
15+
scope: "prod",
16+
period: "last 60 min",
17+
windowMinutes: 60,
18+
summary: { severity: "crit", statements: [] },
19+
findings,
20+
metrics: [livenessMetric],
21+
footer: [],
22+
};
23+
}
24+
25+
const livenessFinding = {
26+
type: "liveness",
27+
severity: "crit" as const,
28+
reason: "stale",
29+
metricIds: ["liveness"],
30+
};
31+
32+
describe("buildReportLayout self-evident findings", () => {
33+
it("drops the metric row of a non-hero finding whose only metric is its own line", () => {
34+
const layout = buildReportLayout(
35+
vmWith([
36+
{ type: "execution", severity: "crit", reason: "failures_up", metricIds: [] },
37+
livenessFinding,
38+
]),
39+
reportMessages("health")
40+
);
41+
42+
const liveness = layout.findings.find((f) => f.type === "liveness");
43+
expect(liveness?.text).toContain("no telemetry in 21m");
44+
expect(liveness?.expanded).toBe(false);
45+
expect(liveness?.metrics).toEqual([]);
46+
});
47+
48+
it("keeps the metric row when that finding is the hero", () => {
49+
const layout = buildReportLayout(vmWith([livenessFinding]), reportMessages("health"));
50+
51+
expect(layout.hero?.type).toBe("liveness");
52+
expect(layout.hero?.expanded).toBe(true);
53+
expect(layout.hero?.metrics.map((m) => m.id)).toEqual(["liveness"]);
54+
});
55+
});

apps/webapp/app/presenters/v3/reports/report-layout.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,12 @@ function findingLayout(
445445
): LayoutFinding {
446446
// A finding whose reason says "we can't say" shows no evidence: the numbers behind it are
447447
// placeholders. Otherwise the hero is always expanded, and the rest only when degraded.
448-
const expanded = !UNASSESSABLE_REASONS.has(finding.reason) && (hero || finding.severity !== "ok");
448+
// A self-evident finding's one metric only repeats its own line ("stale — no telemetry in 21m"
449+
// over "liveness 21m"); as the hero that line is the headline, so the row is its only evidence.
450+
const selfEvident = finding.metricIds.length === 1 && finding.metricIds[0] === finding.type;
451+
const expanded =
452+
!UNASSESSABLE_REASONS.has(finding.reason) &&
453+
(hero || (finding.severity !== "ok" && !selfEvident));
449454

450455
const metrics = expanded
451456
? finding.metricIds

apps/webapp/vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default defineConfig({
1919
"app/runEngine/services/**/*.test.ts",
2020
"app/utils/**/*.test.ts",
2121
"app/components/dashboard-agent/**/*.test.ts",
22+
"app/presenters/v3/reports/**/*.test.ts",
2223
],
2324
// *.e2e.test.ts: smoke matrix, run via vitest.e2e.config.ts.
2425
// *.e2e.full.test.ts: full auth suite, runs via vitest.e2e.full.config.ts

0 commit comments

Comments
 (0)