@skyhook-io/radar-app 1.21.4 → 1.21.5

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 (29) hide show
  1. package/package.json +1 -1
  2. package/src/api/client.ts +42 -2
  3. package/src/api/radarFeatures.ts +1 -0
  4. package/src/components/applications/ApplicationsView.tsx +38 -8
  5. package/src/components/applications/ArgoSyncDetails.tsx +32 -0
  6. package/src/components/applications/RenderedChanges.test.tsx +179 -0
  7. package/src/components/applications/RenderedChanges.tsx +233 -0
  8. package/src/components/audit/AuditView.tsx +2 -1
  9. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +30 -0
  10. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +21 -1
  11. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +9 -0
  12. package/src/components/diagnose/investigationEvidence/types.ts +12 -0
  13. package/src/components/helm/HelmReleaseDrawer.test.ts +27 -0
  14. package/src/components/helm/HelmReleaseDrawer.tsx +24 -3
  15. package/src/components/helm/HelmView.tsx +16 -6
  16. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +3 -0
  17. package/src/components/helm/releaseController.test.tsx +26 -0
  18. package/src/components/helm/releaseController.tsx +98 -0
  19. package/src/components/resources/renderers/K3sHelmChartRenderer.tsx +18 -0
  20. package/src/components/traffic/TrafficGraph.export.test.tsx +1 -1
  21. package/src/components/traffic/TrafficGraph.tsx +3 -17
  22. package/src/components/traffic/traffic-export.test.ts +51 -0
  23. package/src/components/traffic/traffic-export.ts +114 -0
  24. package/src/components/traffic/trafficFilters.ts +16 -0
  25. package/src/components/workload/WorkloadRevisionsButton.test.tsx +34 -0
  26. package/src/components/workload/WorkloadRevisionsButton.tsx +31 -0
  27. package/src/components/workload/WorkloadView.tsx +11 -3
  28. package/src/integrations/resourceHosts.test.tsx +1 -1
  29. package/src/integrations/resourceHosts.tsx +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyhook-io/radar-app",
3
- "version": "1.21.4",
3
+ "version": "1.21.5",
4
4
  "description": "Radar's full web UI as a reusable React component. Used by Radar's own binary and by external consumers like Radar Cloud.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/api/client.ts CHANGED
@@ -589,6 +589,7 @@ export interface AuditResponse {
589
589
  missingInputs?: string[];
590
590
  // Absent on a Radar that predates the per-resource opt-out.
591
591
  ignoreChecksAnnotation?: string;
592
+ namespaceIgnoreChecks?: boolean;
592
593
  // checkID → namespace → resources whose findings the annotation hid.
593
594
  annotationIgnoredByNamespace?: Record<string, Record<string, number>>;
594
595
  summary: DashboardAudit;
@@ -2993,6 +2994,40 @@ export function useArgoResourceDiff(
2993
2994
  });
2994
2995
  }
2995
2996
 
2997
+ export interface RenderedFieldChange {
2998
+ path: string[];
2999
+ before?: unknown;
3000
+ after?: unknown;
3001
+ }
3002
+
3003
+ export interface RenderedResourceChange {
3004
+ group?: string;
3005
+ kind: string;
3006
+ namespace?: string;
3007
+ name: string;
3008
+ operation: "added" | "removed" | "modified";
3009
+ fields: RenderedFieldChange[];
3010
+ }
3011
+
3012
+ export interface RenderedSyncDiff {
3013
+ changes: RenderedResourceChange[];
3014
+ partial?: boolean;
3015
+ secretsMasked?: boolean;
3016
+ }
3017
+
3018
+ export function useArgoSyncDiff(namespace: string, name: string, syncID: string, previous: string, revision: string) {
3019
+ const params = new URLSearchParams({ syncID, previous, revision });
3020
+ return useQuery<RenderedSyncDiff>({
3021
+ queryKey: ["argo-sync-diff", getApiBase(), namespace, name, syncID, previous, revision],
3022
+ queryFn: ({ signal }) => fetchJSON(`/argo/applications/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}/sync-diff?${params}`, signal),
3023
+ // Results depend on today's render settings and the viewer's access.
3024
+ gcTime: 0,
3025
+ staleTime: 0,
3026
+ retry: false,
3027
+ refetchOnWindowFocus: false,
3028
+ });
3029
+ }
3030
+
2996
3031
  // Git commit metadata for one deployed revision of an Argo CD Application.
2997
3032
  // Enabled only when a revision is known and the caller passes `enabled` (gated
2998
3033
  // on capabilities.revisionMetadataAvailable). Cached long — a resolved SHA's
@@ -5728,6 +5763,10 @@ export interface WorkloadRevision {
5728
5763
  // (serving traffic, what an abort reverts to) are different revisions.
5729
5764
  isStable?: boolean;
5730
5765
  podHash?: string;
5766
+ readyReplicas?: number;
5767
+ serving?: boolean;
5768
+ changeCause?: string;
5769
+ matchesDesired?: boolean;
5731
5770
  }
5732
5771
 
5733
5772
  export function useWorkloadRevisions(
@@ -5738,8 +5777,9 @@ export function useWorkloadRevisions(
5738
5777
  ) {
5739
5778
  return useQuery<WorkloadRevision[]>({
5740
5779
  queryKey: ["workload-revisions", kind, namespace, name],
5741
- queryFn: () =>
5742
- fetchJSON(`/workloads/${kind}/${namespace}/${name}/revisions`),
5780
+ queryFn: async () => (await fetchJSON<WorkloadRevision[] | null>(
5781
+ `/workloads/${kind}/${namespace}/${name}/revisions`,
5782
+ )) ?? [],
5743
5783
  enabled: Boolean(kind && namespace && name && enabled),
5744
5784
  });
5745
5785
  }
@@ -51,6 +51,7 @@ export const RADAR_FEATURES = {
51
51
  substrateHealthMetrics: { label: 'Agent Substrate charts', flag: 'substrateHealthMetrics', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
52
52
  cnpgWorkspace: { label: 'CloudNativePG views', flag: 'cnpgWorkspace', flagShippedWithEndpoint: true },
53
53
  sealedSecretsController: { label: 'Sealed Secrets controller status', flag: 'sealedSecretsController', flagShippedWithEndpoint: true },
54
+ sealedSecretsCert: { label: 'Sealed Secrets sealing certificate', flag: 'sealedSecretsCert', flagShippedWithEndpoint: true },
54
55
  cnpgProtectionSetup: { label: 'CloudNativePG backup setup', flag: 'cnpgProtectionSetup', flagShippedWithEndpoint: true },
55
56
  veleroWorkspace: { label: 'Velero views', flag: 'veleroWorkspace', flagShippedWithEndpoint: true },
56
57
  veleroBackupNow: { label: 'Back up now', flag: 'veleroBackupNow', flagShippedWithEndpoint: true },
@@ -3,6 +3,9 @@ import { useNavigate, useSearchParams } from "react-router-dom";
3
3
  import {
4
4
  ApplicationsList,
5
5
  ApplicationDetail,
6
+ ArgoSyncDetailsContext,
7
+ ApplicationDeploys,
8
+ applicationDeliveryRecords,
6
9
  CenteredEmpty,
7
10
  getRadarUpgradeRequirement,
8
11
  PageHeader,
@@ -55,6 +58,8 @@ import { useTimelineSource } from "../../context/TimelineSource";
55
58
  import { apiVersionToGroup, kindToPluralWithGroup, relatedResourcePath, withCrossViewParams } from "../../utils/navigation";
56
59
  import { WorkloadView } from "../workload/WorkloadView";
57
60
  import { ApplicationCostTab } from "../cost/ApplicationCostTab";
61
+ import { ArgoSyncDetails } from "./ArgoSyncDetails";
62
+ import { WorkloadRevisionsButton } from "../workload/WorkloadRevisionsButton";
58
63
  import { useTimelineRetentionNote } from "../../context/TimelineCustomization";
59
64
  import { isOpenCostWorkloadKind } from "../cost/kinds";
60
65
 
@@ -75,9 +80,10 @@ const APPLICATION_TIMELINE_FOCUS_MS = 60 * 60 * 1000;
75
80
  const APPLICATION_TIMELINE_AFTER_MS = 45 * 60 * 1000;
76
81
 
77
82
  const APPLICATION_VIEWS: ReadonlySet<ApplicationRouteView> =
78
- new Set<ApplicationRouteView>(["overview", "topology", "history", "cost"]);
83
+ new Set<ApplicationRouteView>(["overview", "deploys", "topology", "history", "cost"]);
79
84
 
80
85
  function parseApplicationView(value: string | null): ApplicationRouteView {
86
+ if (value === "timeline") return "history";
81
87
  if (!value || !APPLICATION_VIEWS.has(value as ApplicationRouteView))
82
88
  return "overview";
83
89
  return value as ApplicationRouteView;
@@ -278,8 +284,13 @@ function AppDetailRoute({
278
284
  const applicationCostSelected =
279
285
  selectedRouteView === "cost" && applicationCostAvailable;
280
286
  const historyQuery = useApplicationHistory(app.key, appHistoryNamespaces, {
281
- enabled: !selectedWorkloadKey,
287
+ enabled: !selectedWorkloadKey || Boolean(app.sourceRef),
282
288
  });
289
+ const readableHistory = historyQuery.isError ? undefined : historyQuery.data;
290
+ const deliveryRecords = useMemo(() => applicationDeliveryRecords(historyQuery.data), [historyQuery.data]);
291
+ const deliverySource = readableHistory?.sourceRef ?? app.sourceRef;
292
+ const requestedDeploys = selectedView === "deploys" || searchParams.get("tab") === "deploys";
293
+ const showDeploys = deliveryRecords.length > 0 || (requestedDeploys && Boolean(deliverySource));
283
294
  const [retainedHistoryRange, setRetainedHistoryRange] =
284
295
  useState<ApplicationHistoryRange>("7d");
285
296
  const historyRangeOptions = useMemo(
@@ -355,8 +366,8 @@ function AppDetailRoute({
355
366
  [historyMembership, historyTimelineQuery.data, topology],
356
367
  );
357
368
  const historyItems = useMemo(
358
- () => buildApplicationHistoryItems(historyQuery.data, applicationEvents),
359
- [applicationEvents, historyQuery.data],
369
+ () => buildApplicationHistoryItems(readableHistory, applicationEvents),
370
+ [applicationEvents, readableHistory],
360
371
  );
361
372
  const sourceInventoryEnabled =
362
373
  !selectedWorkloadKey && selectedView === "topology";
@@ -383,16 +394,28 @@ function AppDetailRoute({
383
394
  [deploymentTreeQuery.data, helmReleaseQuery.data?.resources],
384
395
  );
385
396
  useEffect(() => {
397
+ // Deploys belongs to the app scope, including its single-workload shell.
398
+ if (requestedDeploys && (!deliverySource || (!singleWorkloadKey && selectedWorkloadParam))) {
399
+ const params = new URLSearchParams(searchParams);
400
+ if (viewParam === "deploys") params.delete("view");
401
+ if (params.get("tab") === "deploys") params.delete("tab");
402
+ if (singleWorkloadKey) params.set("workload", singleWorkloadKey);
403
+ setSearchParams(params, { replace: true });
404
+ return;
405
+ }
386
406
  if (!singleWorkloadKey) return;
387
407
  if (selectedWorkloadParam === singleWorkloadKey && !viewParam) return;
388
408
  const params = new URLSearchParams(searchParams);
389
409
  params.delete("view");
390
410
  params.delete("run");
391
411
  params.set("workload", singleWorkloadKey);
392
- if (selectedRouteView === "cost") params.set("tab", "cost");
412
+ if (selectedRouteView === "cost" || selectedRouteView === "deploys") params.set("tab", selectedRouteView);
413
+ if (selectedRouteView === "history") params.set("tab", "timeline");
393
414
  setSearchParams(params, { replace: true });
394
415
  }, [
395
416
  searchParams,
417
+ requestedDeploys,
418
+ deliverySource,
396
419
  selectedRouteView,
397
420
  selectedWorkloadParam,
398
421
  setSearchParams,
@@ -431,7 +454,7 @@ function AppDetailRoute({
431
454
  params.delete("view");
432
455
  params.delete("workload");
433
456
  } else {
434
- params.set("view", view);
457
+ params.set("view", view === "history" ? "timeline" : view);
435
458
  params.delete("workload");
436
459
  }
437
460
  setSearchParams(params);
@@ -642,6 +665,7 @@ function AppDetailRoute({
642
665
 
643
666
  return (
644
667
  <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
668
+ <ArgoSyncDetailsContext.Provider value={ArgoSyncDetails}>
645
669
  <ApplicationDetail
646
670
  app={app}
647
671
  onBack={onBack}
@@ -653,8 +677,9 @@ function AppDetailRoute({
653
677
  discoveredEnvs={discoveredEnvs}
654
678
  onNavigateToResource={onOpenResource}
655
679
  onSelectWorkloadRun={selectWorkloadRun}
656
- history={historyQuery.data}
680
+ history={readableHistory}
657
681
  historyLoading={historyQuery.isLoading}
682
+ historySourceError={historyQuery.isError}
658
683
  historyItems={historyItems}
659
684
  historyRuntimeLoading={historyTimelineQuery.isLoading}
660
685
  historyRuntimeError={historyTimelineQuery.isError}
@@ -672,6 +697,9 @@ function AppDetailRoute({
672
697
  onSelectWorkload={selectWorkload}
673
698
  selectedView={selectedView}
674
699
  onSelectView={selectView}
700
+ renderDeploys={deliverySource && showDeploys ? () =>
701
+ <ApplicationDeploys source={deliverySource} records={historyQuery.isError ? [] : deliveryRecords} loading={historyQuery.isLoading} unavailable={historyQuery.isError} partialSources={historyQuery.data?.partialSources} onOpenSource={openSource} /> : undefined}
702
+ renderWorkloadRevisions={(workload) => <WorkloadRevisionsButton {...workload} />}
675
703
  costViewSelected={applicationCostSelected}
676
704
  onSelectCostView={() => selectView("cost")}
677
705
  renderCostView={
@@ -697,9 +725,10 @@ function AppDetailRoute({
697
725
  />
698
726
  )}
699
727
  hasOverviewIssues={appIssues.length > 0}
700
- renderWorkload={(workload: SelectedAppWorkload) => (
728
+ renderWorkload={(workload: SelectedAppWorkload, context) => (
701
729
  <div className="h-full overflow-hidden">
702
730
  <WorkloadView
731
+ {...context}
703
732
  kind={kindToPluralWithGroup(workload.kind, workload.group ?? "")}
704
733
  group={workload.group}
705
734
  namespace={workload.namespace}
@@ -713,6 +742,7 @@ function AppDetailRoute({
713
742
  </div>
714
743
  )}
715
744
  />
745
+ </ArgoSyncDetailsContext.Provider>
716
746
  </div>
717
747
  );
718
748
  }
@@ -0,0 +1,32 @@
1
+ import type { ArgoSyncDetailsProps } from "@skyhook-io/k8s-ui";
2
+ import { useArgoStatus, useArgoSyncDiff, useGitOpsInsights } from "../../api/client";
3
+ import { RevisionMetaChip } from "../gitops/RevisionMetaChip";
4
+ import { RenderedChanges } from "./RenderedChanges";
5
+
6
+ function SyncComparison({ namespace, name, syncID, previous, revision }: {
7
+ namespace: string; name: string; syncID: string; previous: string; revision: string;
8
+ }) {
9
+ const query = useArgoSyncDiff(namespace, name, syncID, previous, revision);
10
+ if (query.isError) return <p role="status">Rendered changes unavailable. {query.error.message}</p>;
11
+ if (query.isFetching || !query.data) return <p role="status">Comparing rendered resources…</p>;
12
+ return <RenderedChanges diff={query.data} />;
13
+ }
14
+
15
+ export function ArgoSyncDetails({ source, revision, git }: ArgoSyncDetailsProps) {
16
+ const status = useArgoStatus();
17
+ const connected = !status.isError && status.data?.connected;
18
+ const insights = useGitOpsInsights("applications", source.namespace, connected ? source.name : "", source.group);
19
+ const commitAvailable = connected && !insights.isError && insights.data?.capabilities?.revisionMetadataAvailable &&
20
+ insights.data.summary?.source?.split(" · ")[0] === git.repoURL;
21
+ return <>
22
+ {git.historyID && git.previousRevision && git.previousRevision !== revision && (
23
+ connected
24
+ ? <SyncComparison namespace={source.namespace} name={source.name} syncID={git.historyID} previous={git.previousRevision} revision={revision} />
25
+ : <p className="text-xs" role="status">{status.isPending ? "Checking Argo CD connection…" :
26
+ status.isError ? "Rendered changes unavailable. Radar could not check the Argo CD connection." :
27
+ <>To compare rendered resources, <button type="button" className="font-medium text-accent-text hover:underline"
28
+ onClick={() => window.dispatchEvent(new CustomEvent("radar:open-settings", { detail: { section: "argocd" } }))}>connect the Argo CD API in Settings</button>.</>}</p>
29
+ )}
30
+ {commitAvailable && <div className="flex flex-wrap items-center gap-2"><RevisionMetaChip appNamespace={source.namespace} appName={source.name} revision={revision} /></div>}
31
+ </>;
32
+ }
@@ -0,0 +1,179 @@
1
+ // @vitest-environment jsdom
2
+ import { act, type ReactNode } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+ import { ArgoSyncDetails } from "./ArgoSyncDetails";
6
+ import { RenderedChanges } from "./RenderedChanges";
7
+ import type { RenderedFieldChange, RenderedResourceChange } from "../../api/client";
8
+
9
+ const hooks = vi.hoisted(() => ({
10
+ useArgoStatus: vi.fn(), useArgoSyncDiff: vi.fn(), useGitOpsInsights: vi.fn(),
11
+ }));
12
+ vi.mock("../../api/client", () => hooks);
13
+ const source = { type: "gitops", kind: "Application", namespace: "argo", name: "checkout" } as const;
14
+ const git = { repoURL: "https://git.example/repo", historyID: "5", previousRevision: "a".repeat(40) };
15
+ const revision = "b".repeat(40);
16
+ const template = ["spec", "template"];
17
+ const annotation = (key: string, prefix: string[] = []): RenderedFieldChange => ({
18
+ path: [...prefix, "metadata", "annotations", key], before: "old", after: "new",
19
+ });
20
+ const resource = (fields: RenderedFieldChange[]): RenderedResourceChange => ({
21
+ group: "apps", kind: "Deployment", namespace: "prod", name: "checkout", operation: "modified", fields,
22
+ });
23
+
24
+ let container: HTMLDivElement;
25
+ let root: ReturnType<typeof createRoot>;
26
+ beforeEach(() => {
27
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
28
+ container = document.createElement("div");
29
+ root = createRoot(container);
30
+ hooks.useArgoStatus.mockReturnValue({ data: { connected: true } });
31
+ hooks.useGitOpsInsights.mockReturnValue({});
32
+ });
33
+ afterEach(async () => {
34
+ await act(async () => root.unmount());
35
+ vi.resetAllMocks();
36
+ vi.unstubAllGlobals();
37
+ });
38
+ async function render(node: ReactNode) { await act(async () => root.render(node)); }
39
+ async function open(disclosure: HTMLDetailsElement) {
40
+ await act(async () => { disclosure.open = true; disclosure.dispatchEvent(new Event("toggle")); });
41
+ }
42
+
43
+ describe("rendered resource changes", () => {
44
+ it("shows the requested image and functional changes ahead of exact, inspectable deployment annotations", async () => {
45
+ const image = { path: [...template, "spec", "containers", "[name=checkout]", "image"], before: "checkout:02", after: "checkout:01" };
46
+ const changes = [resource([
47
+ annotation("deployment-id"), annotation("deployment-timestamp", template),
48
+ { ...annotation("build.run.url"), after: "https://ci.example/build/4" },
49
+ annotation("checksum/config", template), image, { path: ["spec", "replicas"], before: 2, after: 3 },
50
+ ])];
51
+ await render(<RenderedChanges diff={{ changes }} />);
52
+ expect(container.textContent).toContain("Image change");
53
+ expect(container.textContent).toContain("checkout:02");
54
+ expect(container.textContent).toContain("checkout:01");
55
+ const imageRow = container.querySelector("tbody tr")!;
56
+ expect(imageRow.querySelector("del")?.textContent).toBe("02");
57
+ expect(imageRow.querySelector("ins")?.textContent).toBe("01");
58
+ expect(container.textContent).toContain("checksum/config");
59
+ expect(container.textContent).toContain("spec.replicas");
60
+ expect(container.textContent).toContain("Deployment metadata (3 changes)");
61
+ expect(container.textContent).not.toContain("deployment-timestamp");
62
+ expect(container.querySelector("a")?.href).toBe("https://ci.example/build/4");
63
+ await open(container.querySelector("details")!);
64
+ expect(container.textContent).toContain("deployment-id");
65
+ expect(container.textContent).toContain("deployment-timestamp");
66
+ });
67
+
68
+ it("preserves the complete values and highlights separated edits and one-sided changes", async () => {
69
+ await render(<RenderedChanges diff={{ changes: [resource([
70
+ { path: ["data", "url"], before: "https://old.example/runs/1042", after: "https://new.example/runs/1041" },
71
+ { path: ["spec", "flag"], before: false },
72
+ ])] }} />);
73
+ const [url, flag] = container.querySelectorAll("tbody tr");
74
+ expect([...url.querySelectorAll("del")].map(mark => mark.textContent)).toEqual(["old", "1042"]);
75
+ expect([...url.querySelectorAll("ins")].map(mark => mark.textContent)).toEqual(["new", "1041"]);
76
+ expect([...url.querySelectorAll("code")].map(code => code.textContent)).toEqual([
77
+ "https://old.example/runs/1042", "https://new.example/runs/1041",
78
+ ]);
79
+ expect(flag.querySelector("del")?.textContent).toBe("false");
80
+ expect(flag.querySelector("ins")).toBeNull();
81
+ });
82
+
83
+ it("groups only repeated version label transitions and preserves all their resource paths", async () => {
84
+ const version = (prefix: string[] = [], before = "v1"): RenderedFieldChange => ({
85
+ path: [...prefix, "metadata", "labels", "app.kubernetes.io/version"], before, after: "v2",
86
+ });
87
+ const changes = [
88
+ resource([
89
+ version(), version(template), { path: ["spec", "replicas"], before: 4, after: 5 },
90
+ { path: ["spec", "selector", "matchLabels", "app.kubernetes.io/version"], before: "v1", after: "v2" },
91
+ ]),
92
+ { ...resource([version()]), kind: "Service", group: "" },
93
+ { ...resource([version([], "v0")]), kind: "ConfigMap", group: "" },
94
+ ];
95
+ await render(<RenderedChanges diff={{ changes }} />);
96
+ expect(container.textContent).toContain("spec.replicas");
97
+ expect(container.textContent).toContain('spec.selector.matchLabels["app.kubernetes.io/version"]');
98
+ expect(container.textContent).toContain("v0");
99
+ const group = [...container.querySelectorAll("details")].find(d => d.querySelector("summary")?.textContent?.includes("Version label"))!;
100
+ expect(group.querySelector("summary")?.textContent).toBe("Version label Previous sync: v1 → Selected sync: v2 on 2 resources");
101
+ await open(group);
102
+ expect(group.querySelectorAll("li")).toHaveLength(3);
103
+ expect(group.textContent).toContain('spec.template.metadata.labels["app.kubernetes.io/version"]');
104
+ expect(group.textContent).toContain("Service prod/checkout");
105
+ });
106
+
107
+ it("names existing containers and distinguishes adding a sidecar from changing an existing image", async () => {
108
+ const path = (name: string) => [...template, "spec", "containers", `[name=${name}]`, "image"];
109
+ await render(<RenderedChanges diff={{ changes: [resource([
110
+ { path: path("checkout"), before: "shop:v1", after: "shop:v2" },
111
+ { path: path("proxy"), after: "envoy:v1" },
112
+ { path: [...template, "spec", "containers", "[order]"], before: ["checkout"], after: ["proxy", "checkout"] },
113
+ ])] }} />);
114
+ const imageRows = container.querySelectorAll("table")[0].querySelectorAll("tbody tr");
115
+ expect(imageRows[0].querySelector("del")?.textContent).toBe("1");
116
+ expect(imageRows[0].querySelector("ins")?.textContent).toBe("2");
117
+ expect(imageRows[1].textContent).toContain("Image added");
118
+ expect(imageRows[1].querySelector("del")).toBeNull();
119
+ expect(imageRows[1].querySelector("ins")?.textContent).toBe("envoy:v1");
120
+ expect(container.textContent).toContain("spec.template.spec.containers[order]");
121
+ });
122
+
123
+ it("keeps ConfigMap data, unrelated CR fields and annotation-like keys out of deployment metadata", async () => {
124
+ const changes = [
125
+ { ...resource([{ path: ["data", "deployment-id"], after: "set" }, { path: ["data", "config"], before: "3", after: 3 }]), kind: "ConfigMap", group: "" },
126
+ { ...resource([annotation("deployment-id", template)]), kind: "Custom", group: "example.io" },
127
+ resource([{ path: ["metadata/annotations", "deployment-id"], before: null }, annotation("deployment-id-extra")]),
128
+ ];
129
+ await render(<RenderedChanges diff={{ changes }} />);
130
+ expect(container.textContent).not.toContain("Deployment metadata (");
131
+ expect(container.textContent).toContain('data["deployment-id"]');
132
+ expect(container.textContent).toContain('"3"');
133
+ expect(container.querySelector("del")?.textContent).toBe('"3"');
134
+ expect(container.textContent).toContain("null");
135
+ });
136
+
137
+ it("groups all three CronJob metadata locations and makes metadata-only and partial results distinct", async () => {
138
+ const resourceChange = { ...resource([
139
+ annotation("deployment-id"), annotation("deployment-timestamp", ["spec", "jobTemplate"]),
140
+ { ...annotation("build.run.url", ["spec", "jobTemplate", "spec", "template"]), after: "javascript:alert(1)" },
141
+ ]), kind: "CronJob", group: "batch" };
142
+ await render(<RenderedChanges diff={{ changes: [resourceChange] }} />);
143
+ expect(container.textContent).toContain("Only deployment metadata changed.");
144
+ expect(container.textContent).toContain("Deployment metadata (3 changes)");
145
+ expect(container.querySelector("a")).toBeNull();
146
+ await render(<RenderedChanges diff={{ changes: [resourceChange], partial: true }} />);
147
+ expect(container.textContent).toContain("Partial comparison");
148
+ expect(container.textContent).not.toContain("Only deployment metadata changed.");
149
+ await render(<RenderedChanges diff={{ changes: [], secretsMasked: true }} />);
150
+ expect(container.textContent).toContain("Secret values are masked");
151
+ expect(container.textContent).toContain("No visible field changes");
152
+ await render(<RenderedChanges diff={{ changes: [resource([annotation("deployment-id", template)])] }} />);
153
+ expect(container.textContent).toContain("Pod template annotations changed and can trigger a rollout.");
154
+ await render(<RenderedChanges diff={{ changes: [resource([annotation("deployment-id")])] }} />);
155
+ expect(container.textContent).not.toContain("can trigger a rollout");
156
+ await render(<RenderedChanges diff={{ changes: [] }} />);
157
+ expect(container.textContent).toContain("No rendered resource changes.");
158
+ });
159
+
160
+ it("offers Argo settings when disconnected, keeps stale or denied results hidden and skips same-revision comparisons", async () => {
161
+ hooks.useArgoStatus.mockReturnValue({ data: { connected: false } });
162
+ await render(<ArgoSyncDetails source={source} git={git} revision={revision} />);
163
+ const settings = vi.fn();
164
+ window.addEventListener("radar:open-settings", settings, { once: true });
165
+ container.querySelector("button")!.click();
166
+ expect(settings.mock.calls[0][0].detail.section).toBe("argocd");
167
+ expect(hooks.useArgoSyncDiff).not.toHaveBeenCalled();
168
+
169
+ hooks.useArgoStatus.mockReturnValue({ data: { connected: true } });
170
+ hooks.useArgoSyncDiff.mockReturnValue({ data: { changes: [] }, isError: true, error: Error("Access denied.") });
171
+ await render(<ArgoSyncDetails source={source} git={git} revision={revision} />);
172
+ expect(hooks.useArgoSyncDiff).toHaveBeenCalledWith("argo", "checkout", "5", git.previousRevision, revision);
173
+ expect(container.textContent).toContain("Access denied");
174
+ expect(container.textContent).not.toContain("No rendered resource changes");
175
+ hooks.useArgoSyncDiff.mockClear();
176
+ await render(<ArgoSyncDetails source={source} git={{ ...git, previousRevision: revision }} revision={revision} />);
177
+ expect(hooks.useArgoSyncDiff).not.toHaveBeenCalled();
178
+ });
179
+ });