@skyhook-io/radar-app 1.17.1 → 1.18.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.
- package/package.json +9 -9
- package/src/App.tsx +14 -30
- package/src/api/client.gitopsPoll.test.ts +99 -0
- package/src/api/client.helmPreview.test.tsx +48 -0
- package/src/api/client.resourceAvailability.test.ts +24 -0
- package/src/api/client.ts +337 -87
- package/src/api/client.workloadRuns.test.ts +53 -0
- package/src/api/config.test.ts +23 -1
- package/src/api/config.ts +7 -3
- package/src/api/diagnose.ts +4 -1
- package/src/api/drain-plan.test.ts +70 -40
- package/src/api/policy.ts +5 -5
- package/src/api/radarFeatures.ts +1 -0
- package/src/api/traffic.scope.render.test.tsx +60 -0
- package/src/api/traffic.ts +3 -1
- package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
- package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
- package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
- package/src/components/diagnose/InvestigationView.tsx +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
- package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
- package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
- package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
- package/src/components/diagnose/investigationEvidence/observations.ts +20 -0
- package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +107 -0
- package/src/components/diagnose/investigationEvidence/types.ts +11 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
- package/src/components/diagnose/investigationState.test.ts +36 -1
- package/src/components/diagnose/investigationState.ts +8 -0
- package/src/components/diagnose/launch.ts +2 -2
- package/src/components/dock/BottomDock.tsx +6 -3
- package/src/components/dock/WorkloadLogsTab.tsx +3 -0
- package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
- package/src/components/execution/BatchExecutionView.tsx +23 -8
- package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
- package/src/components/gitops/GitOpsView.tsx +7 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
- package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
- package/src/components/helm/HelmReleaseNotes.tsx +26 -0
- package/src/components/helm/OwnedResources.tsx +2 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +76 -4
- package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
- package/src/components/helm/TrackChartSourceDialog.tsx +41 -15
- package/src/components/helm/ValuesDiffPreview.tsx +4 -1
- package/src/components/home/ClusterHealthCard.tsx +4 -4
- package/src/components/home/CostCard.test.tsx +100 -0
- package/src/components/home/CostCard.tsx +2 -2
- package/src/components/home/HelmSummary.tsx +2 -2
- package/src/components/home/HomeView.tsx +15 -6
- package/src/components/home/MCPSetupDialog.test.tsx +30 -0
- package/src/components/home/MCPSetupDialog.tsx +13 -6
- package/src/components/home/ProblemsPanel.test.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +18 -2
- package/src/components/issues/IssuesPane.render.test.tsx +21 -0
- package/src/components/issues/IssuesPane.tsx +31 -7
- package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
- package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
- package/src/components/issues/uncheckedSources.test.ts +43 -0
- package/src/components/issues/uncheckedSources.ts +58 -5
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
- package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
- package/src/components/resources/ImageFilesystemModal.tsx +11 -4
- package/src/components/resources/PodFilesystemModal.tsx +2 -2
- package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
- package/src/components/resources/ResourcesView.tsx +18 -3
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
- package/src/components/settings/SettingsDialog.tsx +21 -15
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
- package/src/components/traffic/TrafficView.tsx +12 -12
- package/src/components/traffic/trafficFilters.test.ts +20 -1
- package/src/components/traffic/trafficFilters.ts +13 -0
- package/src/components/ui/Omnibar.tsx +13 -2
- package/src/components/ui/Toast.tsx +1 -1
- package/src/components/ui/omnibar-match.test.ts +30 -0
- package/src/components/ui/omnibar-match.ts +18 -0
- package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
- package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
- package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
- package/src/components/workload/NodeDrainStatus.tsx +55 -0
- package/src/components/workload/WorkloadView.tsx +37 -5
- package/src/context/ConnectionContext.test.ts +27 -1
- package/src/context/ConnectionContext.tsx +17 -7
- package/src/integrations/resourceHosts.test.tsx +1 -0
- package/src/integrations/resourceHosts.tsx +2 -0
- package/src/utils/navigation.ts +14 -0
- package/src/utils/wails-clipboard.ts +4 -2
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import {
|
|
5
|
+
DiffViewer,
|
|
6
|
+
ResourceLink,
|
|
7
|
+
formatRelativeAgeTime,
|
|
8
|
+
type IssueRecentChange,
|
|
9
|
+
} from "@skyhook-io/k8s-ui";
|
|
10
|
+
import { ChangesBody } from "./investigationEvidence/bodies/streams";
|
|
11
|
+
import { EvidenceNavigationContext } from "./investigationEvidence/navigation";
|
|
12
|
+
import { recentChange } from "./investigationEvidence/parse";
|
|
13
|
+
import { projectInvestigationEvidence } from "./investigationEvidence";
|
|
14
|
+
|
|
15
|
+
vi.mock("@skyhook-io/k8s-ui", async (importOriginal) => {
|
|
16
|
+
const actual = await importOriginal<typeof import("@skyhook-io/k8s-ui")>();
|
|
17
|
+
return {
|
|
18
|
+
...actual,
|
|
19
|
+
ResourceLink: vi.fn(actual.ResourceLink),
|
|
20
|
+
DiffViewer: vi.fn((props: ComponentProps<typeof actual.DiffViewer>) => (
|
|
21
|
+
<actual.DiffViewer {...props} />
|
|
22
|
+
)),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const annotation = {
|
|
27
|
+
workloads: ["Deployment/env-reader", "Deployment/envfrom-reader"],
|
|
28
|
+
pods: 2,
|
|
29
|
+
keys: ["password"],
|
|
30
|
+
note: "These Pods started before Radar observed this write and read the changed keys as env vars. Env values are set when a container starts, so they likely still hold the earlier value until they restart.",
|
|
31
|
+
};
|
|
32
|
+
const secretChange: IssueRecentChange = {
|
|
33
|
+
kind: "Secret",
|
|
34
|
+
apiVersion: "v1",
|
|
35
|
+
namespace: "secret-feed-proof",
|
|
36
|
+
name: "db-conn",
|
|
37
|
+
changeType: "update",
|
|
38
|
+
summary: "data modified keys: [password]",
|
|
39
|
+
timestamp: "2026-10-19T17:52:12+03:00",
|
|
40
|
+
change_category: "spec_config",
|
|
41
|
+
rank_reason:
|
|
42
|
+
"Secret data changed; 2 Pods likely still hold the earlier value",
|
|
43
|
+
application_configuration_change: true,
|
|
44
|
+
fields: [
|
|
45
|
+
{
|
|
46
|
+
path: "data (modified keys)",
|
|
47
|
+
oldValue: ["password"],
|
|
48
|
+
newValue: ["password"],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
consumed_by: [
|
|
52
|
+
"Deployment/env-reader",
|
|
53
|
+
"Deployment/envfrom-reader",
|
|
54
|
+
"Deployment/mount-reader",
|
|
55
|
+
],
|
|
56
|
+
running_previous_value: annotation,
|
|
57
|
+
};
|
|
58
|
+
const onOpenResource = vi.fn();
|
|
59
|
+
|
|
60
|
+
function render(change: unknown = secretChange): string {
|
|
61
|
+
const projection = projectInvestigationEvidence(
|
|
62
|
+
[
|
|
63
|
+
{
|
|
64
|
+
timeline: [
|
|
65
|
+
{
|
|
66
|
+
kind: "tool",
|
|
67
|
+
id: "changes",
|
|
68
|
+
tool: "get_changes",
|
|
69
|
+
status: "done",
|
|
70
|
+
summary: JSON.stringify({ namespace: "secret-feed-proof" }),
|
|
71
|
+
result: JSON.stringify({ changes: [change] }),
|
|
72
|
+
isError: false,
|
|
73
|
+
radarEvidence: true,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
{
|
|
79
|
+
kind: "Secret",
|
|
80
|
+
group: "",
|
|
81
|
+
namespace: "secret-feed-proof",
|
|
82
|
+
name: "db-conn",
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
const data = projection.groups.find((group) => group.kind === "changes")
|
|
86
|
+
?.latest.data;
|
|
87
|
+
expect(data?.type).toBe("changes");
|
|
88
|
+
if (data?.type !== "changes") throw new Error("Expected a changes card");
|
|
89
|
+
return renderToStaticMarkup(
|
|
90
|
+
<EvidenceNavigationContext.Provider value={{ onOpenResource }}>
|
|
91
|
+
<ChangesBody data={data} />
|
|
92
|
+
</EvidenceNavigationContext.Provider>,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
beforeEach(() => vi.clearAllMocks());
|
|
97
|
+
|
|
98
|
+
describe("Secret and ConfigMap change evidence", () => {
|
|
99
|
+
it.each([1, 2])("renders the stale-reader fact for %i Pods", (pods) => {
|
|
100
|
+
const html = render({
|
|
101
|
+
...secretChange,
|
|
102
|
+
running_previous_value: {
|
|
103
|
+
...annotation,
|
|
104
|
+
pods,
|
|
105
|
+
keys: ["password", "username"],
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
expect(html).toContain(
|
|
109
|
+
pods === 1
|
|
110
|
+
? "1 Pod likely still holds the earlier value"
|
|
111
|
+
: "2 Pods likely still hold the earlier value",
|
|
112
|
+
);
|
|
113
|
+
expect(html).toMatch(
|
|
114
|
+
/Changed keys read as env: <span[^>]*font-mono[^>]*>password<\/span>, <span[^>]*>username<\/span><\/p>/,
|
|
115
|
+
);
|
|
116
|
+
expect(html).toContain(annotation.note);
|
|
117
|
+
expect(html).toMatch(/<button[^>]*>Deployment\/env-reader<\/button>/);
|
|
118
|
+
expect(html).toMatch(/<button[^>]*>Deployment\/envfrom-reader<\/button>/);
|
|
119
|
+
expect(html.indexOf(secretChange.summary!)).toBeLessThan(
|
|
120
|
+
html.indexOf("likely still"),
|
|
121
|
+
);
|
|
122
|
+
expect(html.indexOf(annotation.note)).toBeLessThan(
|
|
123
|
+
html.indexOf("1 changed field"),
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it.each([{ workloads: [] }, { workloads: null }])(
|
|
128
|
+
"keeps the Pod count when workload names are hidden (%j)",
|
|
129
|
+
({ workloads }) => {
|
|
130
|
+
const html = render({
|
|
131
|
+
...secretChange,
|
|
132
|
+
consumed_by: [],
|
|
133
|
+
running_previous_value: { ...annotation, workloads },
|
|
134
|
+
});
|
|
135
|
+
expect(html).toContain("2 Pods likely still hold the earlier value");
|
|
136
|
+
expect(html).toContain("workload names hidden by your permissions");
|
|
137
|
+
expect(html).not.toContain("Deployment/env-reader");
|
|
138
|
+
expect(
|
|
139
|
+
recentChange({
|
|
140
|
+
...secretChange,
|
|
141
|
+
running_previous_value: { ...annotation, workloads },
|
|
142
|
+
})?.running_previous_value?.workloads,
|
|
143
|
+
).toEqual([]);
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
it("marks a full list of five references and stale workloads as capped", () => {
|
|
148
|
+
const five = ["a", "b", "c", "d", "e"].map((name) => `Deployment/${name}`);
|
|
149
|
+
const html = render({
|
|
150
|
+
...secretChange,
|
|
151
|
+
consumed_by: five,
|
|
152
|
+
running_previous_value: { ...annotation, pods: 7, workloads: five },
|
|
153
|
+
});
|
|
154
|
+
expect(html.match(/\(first 5\)/g)).toHaveLength(2);
|
|
155
|
+
expect(html).toContain("In workloads you can view:");
|
|
156
|
+
expect(render(secretChange)).not.toContain("(first 5)");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("renders references as text when the row has no namespace", () => {
|
|
160
|
+
render({ ...secretChange, namespace: undefined });
|
|
161
|
+
expect(
|
|
162
|
+
vi
|
|
163
|
+
.mocked(ResourceLink)
|
|
164
|
+
.mock.calls.filter(([props]) =>
|
|
165
|
+
String(props.label).startsWith("Deployment/"),
|
|
166
|
+
),
|
|
167
|
+
).toHaveLength(0);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("counts names the caller can't view instead of hiding them silently", () => {
|
|
171
|
+
const withheld = { count: 2, reason: "user_forbidden" };
|
|
172
|
+
const some = render({
|
|
173
|
+
...secretChange,
|
|
174
|
+
consumed_by: ["Deployment/env-reader"],
|
|
175
|
+
consumed_by_withheld: withheld,
|
|
176
|
+
running_previous_value: {
|
|
177
|
+
...annotation,
|
|
178
|
+
workloads: ["Deployment/env-reader"],
|
|
179
|
+
withheld,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
expect(some.match(/\+2 more you can('|')t view/g)).toHaveLength(2);
|
|
183
|
+
const none = render({
|
|
184
|
+
...secretChange,
|
|
185
|
+
consumed_by: undefined,
|
|
186
|
+
consumed_by_withheld: withheld,
|
|
187
|
+
running_previous_value: { ...annotation, workloads: [], withheld },
|
|
188
|
+
});
|
|
189
|
+
expect(none).toContain("Referenced by");
|
|
190
|
+
expect(none).toContain("2 workloads you can't view");
|
|
191
|
+
expect(none).toContain("In 2 workloads you can't view");
|
|
192
|
+
expect(none).not.toContain("hidden by your permissions");
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it.each([{ count: 0, reason: "user_forbidden" }, { count: 1 }, "two", null])(
|
|
196
|
+
"drops a malformed withheld marker (%j) and keeps the row",
|
|
197
|
+
(marker) => {
|
|
198
|
+
const row = recentChange({
|
|
199
|
+
...secretChange,
|
|
200
|
+
consumed_by_withheld: marker,
|
|
201
|
+
running_previous_value: { ...annotation, withheld: marker },
|
|
202
|
+
});
|
|
203
|
+
expect(row).not.toHaveProperty("consumed_by_withheld");
|
|
204
|
+
expect(row?.running_previous_value).not.toHaveProperty("withheld");
|
|
205
|
+
expect(row?.summary).toBe(secretChange.summary);
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
it("renders a reference of a kind with no known group as text, not a link", () => {
|
|
210
|
+
const html = render({
|
|
211
|
+
...secretChange,
|
|
212
|
+
consumed_by: ["Cluster/database"],
|
|
213
|
+
running_previous_value: { ...annotation, workloads: ["Cluster/database"] },
|
|
214
|
+
});
|
|
215
|
+
expect(html).toContain("Cluster/database");
|
|
216
|
+
expect(
|
|
217
|
+
vi
|
|
218
|
+
.mocked(ResourceLink)
|
|
219
|
+
.mock.calls.filter(([props]) => props.label === "Cluster/database"),
|
|
220
|
+
).toHaveLength(0);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it.each([
|
|
224
|
+
["Deployment", "apps"],
|
|
225
|
+
["StatefulSet", "apps"],
|
|
226
|
+
["DaemonSet", "apps"],
|
|
227
|
+
["ReplicaSet", "apps"],
|
|
228
|
+
["Job", "batch"],
|
|
229
|
+
["CronJob", "batch"],
|
|
230
|
+
["Rollout", "argoproj.io"],
|
|
231
|
+
["Pod", ""],
|
|
232
|
+
])("links %s references to the correct API group", (kind, group) => {
|
|
233
|
+
render({
|
|
234
|
+
...secretChange,
|
|
235
|
+
consumed_by: [`${kind}/reader`],
|
|
236
|
+
running_previous_value: { ...annotation, workloads: [`${kind}/reader`] },
|
|
237
|
+
});
|
|
238
|
+
const links = vi
|
|
239
|
+
.mocked(ResourceLink)
|
|
240
|
+
.mock.calls.map(([props]) => props)
|
|
241
|
+
.filter((props) => props.label === `${kind}/reader`);
|
|
242
|
+
expect(links).toHaveLength(2);
|
|
243
|
+
for (const props of links) {
|
|
244
|
+
expect(props).toMatchObject({
|
|
245
|
+
kind,
|
|
246
|
+
name: "reader",
|
|
247
|
+
namespace: "secret-feed-proof",
|
|
248
|
+
group,
|
|
249
|
+
onNavigate: onOpenResource,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("renders Referenced by for a ConfigMap", () => {
|
|
255
|
+
const html = render({
|
|
256
|
+
...secretChange,
|
|
257
|
+
kind: "ConfigMap",
|
|
258
|
+
running_previous_value: undefined,
|
|
259
|
+
});
|
|
260
|
+
expect(html).toContain("Referenced by");
|
|
261
|
+
expect(html).toMatch(/<button[^>]*>Deployment\/mount-reader<\/button>/);
|
|
262
|
+
expect(html).not.toContain("likely still");
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("shows collapsed updates and the first update's age beside the timestamp", () => {
|
|
266
|
+
const first = "2026-10-19T17:50:00+03:00";
|
|
267
|
+
const html = render({
|
|
268
|
+
...secretChange,
|
|
269
|
+
updates_in_window: 4,
|
|
270
|
+
first_update_at: first,
|
|
271
|
+
});
|
|
272
|
+
const label = `4 updates, first ${formatRelativeAgeTime(first)}`;
|
|
273
|
+
expect(html).toContain(label);
|
|
274
|
+
expect(html.indexOf(label)).toBeLessThan(html.indexOf("<time"));
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it.each([undefined, 1])(
|
|
278
|
+
"omits the collapsed-update label for %s",
|
|
279
|
+
(updates_in_window) => {
|
|
280
|
+
expect(render({ ...secretChange, updates_in_window })).not.toContain(
|
|
281
|
+
" updates",
|
|
282
|
+
);
|
|
283
|
+
},
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
it.each(
|
|
287
|
+
[
|
|
288
|
+
null,
|
|
289
|
+
[],
|
|
290
|
+
"malformed",
|
|
291
|
+
{ ...annotation, workloads: "Deployment/env-reader" },
|
|
292
|
+
{ ...annotation, workloads: [1] },
|
|
293
|
+
{ ...annotation, pods: "2" },
|
|
294
|
+
{ ...annotation, pods: -1 },
|
|
295
|
+
{ ...annotation, pods: 1.5 },
|
|
296
|
+
{ ...annotation, keys: null },
|
|
297
|
+
{ ...annotation, keys: [1] },
|
|
298
|
+
{ ...annotation, note: false },
|
|
299
|
+
{ pods: 2, keys: ["password"], note: annotation.note },
|
|
300
|
+
].map((running_previous_value) => ({ running_previous_value })),
|
|
301
|
+
)(
|
|
302
|
+
"drops only a malformed stale-reader annotation (%j)",
|
|
303
|
+
({ running_previous_value }) => {
|
|
304
|
+
const row = { ...secretChange, running_previous_value };
|
|
305
|
+
expect(recentChange(row)).not.toHaveProperty("running_previous_value");
|
|
306
|
+
const html = render(row);
|
|
307
|
+
expect(html).toContain(secretChange.summary);
|
|
308
|
+
expect(html).toContain("Referenced by");
|
|
309
|
+
expect(html).not.toContain("likely still");
|
|
310
|
+
},
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
it.each([0, -1, 1.5, "4", null, Infinity, NaN])(
|
|
314
|
+
"drops an invalid update count (%j) without losing the row",
|
|
315
|
+
(updates_in_window) => {
|
|
316
|
+
const row = { ...secretChange, updates_in_window };
|
|
317
|
+
expect(recentChange(row)).not.toHaveProperty("updates_in_window");
|
|
318
|
+
const html = render(row);
|
|
319
|
+
expect(html).toContain(secretChange.summary);
|
|
320
|
+
expect(html).toContain(annotation.note);
|
|
321
|
+
expect(html).not.toMatch(/\d updates/);
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
it.each([null, 3, {}, [], "not a time"].map((first_update_at) => ({ first_update_at })))(
|
|
326
|
+
"drops a non-string first update time (%j)",
|
|
327
|
+
({ first_update_at }) => {
|
|
328
|
+
const row = { ...secretChange, updates_in_window: 3, first_update_at };
|
|
329
|
+
expect(recentChange(row)).not.toHaveProperty("first_update_at");
|
|
330
|
+
expect(render(row)).toMatch(/>3 updates</);
|
|
331
|
+
},
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
it("renders only key-name lists in the example Secret diff", () => {
|
|
335
|
+
const html = render();
|
|
336
|
+
expect(secretChange.fields).toEqual([
|
|
337
|
+
{
|
|
338
|
+
path: "data (modified keys)",
|
|
339
|
+
oldValue: ["password"],
|
|
340
|
+
newValue: ["password"],
|
|
341
|
+
},
|
|
342
|
+
]);
|
|
343
|
+
expect(vi.mocked(DiffViewer).mock.calls[0][0].diff.fields).toEqual(
|
|
344
|
+
secretChange.fields,
|
|
345
|
+
);
|
|
346
|
+
// The key list reads as a key change, not a struck-through old→new pair.
|
|
347
|
+
expect(html).not.toContain("["password"]");
|
|
348
|
+
expect(html).toContain("keys changed: ");
|
|
349
|
+
expect(html).toContain(">password</span>");
|
|
350
|
+
expect(html).not.toMatch(/oldValue|newValue|stringData/);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
@@ -2922,6 +2922,107 @@ describe("InvestigationEvidencePane metrics cards", () => {
|
|
|
2922
2922
|
};
|
|
2923
2923
|
}
|
|
2924
2924
|
|
|
2925
|
+
it.each([true, false, "true"])(
|
|
2926
|
+
"validates partial=%s while keeping valid charts",
|
|
2927
|
+
(partial) => {
|
|
2928
|
+
const projection = project(
|
|
2929
|
+
tool("prom", "query_prometheus", {
|
|
2930
|
+
...rangeResult(targetSelectors),
|
|
2931
|
+
partial,
|
|
2932
|
+
}),
|
|
2933
|
+
);
|
|
2934
|
+
if (typeof partial !== "boolean") {
|
|
2935
|
+
expect(projection.groups).toHaveLength(0);
|
|
2936
|
+
expect(projection.limitations).toHaveLength(1);
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
expect(render(projection)).toContain("Memory working set");
|
|
2940
|
+
expect(projection.limitations).toHaveLength(partial ? 1 : 0);
|
|
2941
|
+
if (partial) {
|
|
2942
|
+
expect(projection.limitations[0]).toMatchObject({
|
|
2943
|
+
kind: "unknown",
|
|
2944
|
+
message:
|
|
2945
|
+
"The metrics backend returned a partial result, so some series may be missing.",
|
|
2946
|
+
});
|
|
2947
|
+
}
|
|
2948
|
+
},
|
|
2949
|
+
);
|
|
2950
|
+
|
|
2951
|
+
it.each([
|
|
2952
|
+
[
|
|
2953
|
+
{ infos: ["PromQL info: metric might not be a counter"] },
|
|
2954
|
+
[
|
|
2955
|
+
"Prometheus noted about this query: PromQL info: metric might not be a counter",
|
|
2956
|
+
],
|
|
2957
|
+
],
|
|
2958
|
+
[
|
|
2959
|
+
{ warnings: ["a", "b"], annotationsOmitted: 2 },
|
|
2960
|
+
[
|
|
2961
|
+
"The metrics backend returned 2 warnings with this result: a; b",
|
|
2962
|
+
"2 more backend messages were left out to keep the result small.",
|
|
2963
|
+
],
|
|
2964
|
+
],
|
|
2965
|
+
[
|
|
2966
|
+
{ warnings: ["store down"], infos: ["note"] },
|
|
2967
|
+
[
|
|
2968
|
+
"The metrics backend returned a warning with this result: store down",
|
|
2969
|
+
"Prometheus noted about this query: note",
|
|
2970
|
+
],
|
|
2971
|
+
],
|
|
2972
|
+
[
|
|
2973
|
+
{ annotationsOmitted: 1 },
|
|
2974
|
+
["1 more backend message was left out to keep the result small."],
|
|
2975
|
+
],
|
|
2976
|
+
])(
|
|
2977
|
+
"keeps the chart and surfaces backend annotations %j",
|
|
2978
|
+
(extra, messages) => {
|
|
2979
|
+
const projection = project(
|
|
2980
|
+
tool("prom", "query_prometheus", {
|
|
2981
|
+
...rangeResult(targetSelectors),
|
|
2982
|
+
...extra,
|
|
2983
|
+
}),
|
|
2984
|
+
);
|
|
2985
|
+
const html = render(projection);
|
|
2986
|
+
expect(html).toContain("Memory working set");
|
|
2987
|
+
const annotated = extra as { warnings?: string[]; infos?: string[] };
|
|
2988
|
+
for (const text of [
|
|
2989
|
+
...(annotated.warnings ?? []),
|
|
2990
|
+
...(annotated.infos ?? []),
|
|
2991
|
+
]) {
|
|
2992
|
+
expect(html).toContain(text);
|
|
2993
|
+
}
|
|
2994
|
+
if (annotated.warnings?.length) expect(html).toContain("Backend warning");
|
|
2995
|
+
if (annotated.infos?.length) expect(html).toContain("Prometheus noted:");
|
|
2996
|
+
const omitted = (extra as { annotationsOmitted?: number })
|
|
2997
|
+
.annotationsOmitted;
|
|
2998
|
+
if (omitted)
|
|
2999
|
+
expect(html).toContain(
|
|
3000
|
+
`${omitted} more backend ${omitted === 1 ? "message" : "messages"} left out.`,
|
|
3001
|
+
);
|
|
3002
|
+
expect(projection.limitations.map((item) => item.message)).toEqual(
|
|
3003
|
+
messages,
|
|
3004
|
+
);
|
|
3005
|
+
for (const item of projection.limitations)
|
|
3006
|
+
expect(item.kind).toBe("unknown");
|
|
3007
|
+
},
|
|
3008
|
+
);
|
|
3009
|
+
|
|
3010
|
+
it.each([
|
|
3011
|
+
{ warnings: "x" },
|
|
3012
|
+
{ warnings: [1] },
|
|
3013
|
+
{ infos: [true] },
|
|
3014
|
+
{ annotationsOmitted: "1" },
|
|
3015
|
+
])("rejects a malformed annotation field %j", (extra) => {
|
|
3016
|
+
const projection = project(
|
|
3017
|
+
tool("prom", "query_prometheus", {
|
|
3018
|
+
...rangeResult(targetSelectors),
|
|
3019
|
+
...extra,
|
|
3020
|
+
}),
|
|
3021
|
+
);
|
|
3022
|
+
expect(projection.groups).toHaveLength(0);
|
|
3023
|
+
expect(projection.limitations).toHaveLength(1);
|
|
3024
|
+
});
|
|
3025
|
+
|
|
2925
3026
|
it("keeps an uncited target-scoped chart in the workload collection", () => {
|
|
2926
3027
|
const projection = project(
|
|
2927
3028
|
tool("prom", "query_prometheus", rangeResult(targetSelectors)),
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
investigationPaneCenteredScrollTop,
|
|
42
42
|
canStopInvestigation,
|
|
43
43
|
canContinueInvestigation,
|
|
44
|
+
readOnlyNotice,
|
|
44
45
|
canInvestigateFurther,
|
|
45
46
|
} from "./investigationState";
|
|
46
47
|
import type { AssessmentExplanation } from "./parts";
|
|
@@ -1761,7 +1762,7 @@ export function InvestigationView({
|
|
|
1761
1762
|
)}
|
|
1762
1763
|
</>
|
|
1763
1764
|
) : (
|
|
1764
|
-
|
|
1765
|
+
readOnlyNotice(run)
|
|
1765
1766
|
)}
|
|
1766
1767
|
</div>
|
|
1767
1768
|
) : (
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { groupsOf, project, tool } from "../evidenceFixtures";
|
|
3
|
+
import fixture from "./testdata/get-changes-created.json";
|
|
4
|
+
import { createdChanges } from "./changes";
|
|
5
|
+
|
|
6
|
+
// The fixture is written by the Go test TestCompactCreatesSharedFixture from
|
|
7
|
+
// the producer's own CompactCreates, so this checks both ends of the contract.
|
|
8
|
+
function cardChanges(result: unknown) {
|
|
9
|
+
const projection = project([tool("changes", "get_changes", result)]);
|
|
10
|
+
const group = groupsOf(projection.groups, "changes")[0];
|
|
11
|
+
const data = group?.latest.data;
|
|
12
|
+
return { projection, changes: data?.type === "changes" ? data.changes : [] };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe("get_changes created runs", () => {
|
|
16
|
+
it("expand into the exact rows and order the producer replaced", () => {
|
|
17
|
+
const original = cardChanges(fixture.original);
|
|
18
|
+
const compacted = cardChanges(fixture.compacted);
|
|
19
|
+
expect(compacted.changes).toEqual(original.changes);
|
|
20
|
+
expect(compacted.changes).toHaveLength(fixture.original.changes.length);
|
|
21
|
+
expect(compacted.projection.limitations).toEqual(
|
|
22
|
+
original.projection.limitations,
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("rebuilds each timestamp in the zone of first", () => {
|
|
27
|
+
const rows = createdChanges([
|
|
28
|
+
{
|
|
29
|
+
namespace: "shop",
|
|
30
|
+
first: "2026-10-16T23:59:30+03:00",
|
|
31
|
+
count: 1,
|
|
32
|
+
objects: ["+41s Service/cart"],
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
expect(rows).toEqual([
|
|
36
|
+
{
|
|
37
|
+
changeType: "add",
|
|
38
|
+
summary: "add",
|
|
39
|
+
change_category: "lifecycle",
|
|
40
|
+
rank_reason: "resource create/delete for config or desired state",
|
|
41
|
+
kind: "Service",
|
|
42
|
+
namespace: "shop",
|
|
43
|
+
name: "cart",
|
|
44
|
+
timestamp: "2026-10-17T00:00:11+03:00",
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("expands an absent created field to no rows", () => {
|
|
50
|
+
expect(createdChanges(undefined)).toEqual([]);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("rejects a malformed run instead of dropping its objects", () => {
|
|
54
|
+
for (const created of [
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
namespace: "shop",
|
|
58
|
+
first: "2026-10-16T04:43:24+03:00",
|
|
59
|
+
count: 1,
|
|
60
|
+
objects: ["Service/cart"],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
{
|
|
65
|
+
namespace: "shop",
|
|
66
|
+
first: "not a time",
|
|
67
|
+
count: 1,
|
|
68
|
+
objects: ["+0s Service/cart"],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
{
|
|
73
|
+
first: "2026-10-16T04:43:24+03:00",
|
|
74
|
+
count: 1,
|
|
75
|
+
objects: ["+0s Service/cart"],
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
{
|
|
80
|
+
namespace: "shop",
|
|
81
|
+
first: "2026-10-16T04:43:24+03:00",
|
|
82
|
+
count: 1,
|
|
83
|
+
objects: ["+0s Service/cart"],
|
|
84
|
+
apiVersions: { Service: "" },
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
{
|
|
89
|
+
namespace: "shop",
|
|
90
|
+
first: "2026-10-16T04:43:24+03:00",
|
|
91
|
+
count: 5,
|
|
92
|
+
objects: ["+0s Service/cart"],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
{
|
|
97
|
+
namespace: "shop",
|
|
98
|
+
first: "2026-02-30T04:43:24+03:00",
|
|
99
|
+
count: 1,
|
|
100
|
+
objects: ["+0s Service/cart"],
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
{
|
|
105
|
+
namespace: "shop",
|
|
106
|
+
first: "2026-10-16T04:43:24+03:00",
|
|
107
|
+
count: 1,
|
|
108
|
+
objects: ["+99999999999999999999s Service/cart"],
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
{ namespace: "shop" },
|
|
112
|
+
]) {
|
|
113
|
+
expect(createdChanges(created)).toBeUndefined();
|
|
114
|
+
const { projection } = cardChanges({ changes: [], created });
|
|
115
|
+
expect(groupsOf(projection.groups, "changes")).toHaveLength(0);
|
|
116
|
+
expect(projection.limitations).toEqual(
|
|
117
|
+
expect.arrayContaining([
|
|
118
|
+
expect.objectContaining({ source: "Recent changes" }),
|
|
119
|
+
]),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|