@skyhook-io/radar-app 1.20.0 → 1.20.3

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 (109) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +18 -11
  3. package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
  4. package/src/api/client.pauseDeployment.test.tsx +77 -0
  5. package/src/api/client.restartError.test.ts +14 -0
  6. package/src/api/client.revisionRefresh.test.tsx +44 -0
  7. package/src/api/client.rollbackError.test.ts +14 -0
  8. package/src/api/client.ts +287 -21
  9. package/src/api/helmInventory.test.tsx +108 -0
  10. package/src/api/networkAttachments.test.tsx +120 -0
  11. package/src/api/networkAttachments.ts +30 -0
  12. package/src/api/radarFeatures.test.ts +5 -0
  13. package/src/api/radarFeatures.ts +5 -0
  14. package/src/api/secretsStore.test.ts +33 -0
  15. package/src/api/secretsStore.ts +37 -0
  16. package/src/components/ConnectionErrorView.test.tsx +11 -0
  17. package/src/components/ConnectionErrorView.tsx +19 -0
  18. package/src/components/ContextSwitcher.tsx +9 -2
  19. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  20. package/src/components/applications/ApplicationsView.tsx +8 -11
  21. package/src/components/cost/CostView.tsx +27 -9
  22. package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
  23. package/src/components/curl/ServiceCurlButton.tsx +2 -2
  24. package/src/components/diagnose/InvestigationView.tsx +12 -3
  25. package/src/components/diagnose/investigationCase.test.tsx +41 -0
  26. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
  27. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  28. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +61 -16
  29. package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
  30. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
  31. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  32. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  33. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  34. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  35. package/src/components/dock/TerminalPreferences.tsx +73 -0
  36. package/src/components/gitops/GitOpsView.tsx +1 -9
  37. package/src/components/helm/HelmDrawerFrame.tsx +101 -0
  38. package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
  39. package/src/components/helm/HelmReleaseDrawer.tsx +47 -98
  40. package/src/components/helm/HelmView.tsx +215 -71
  41. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  42. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  43. package/src/components/helm/ObservedHelmNotice.tsx +146 -0
  44. package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
  45. package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
  46. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
  47. package/src/components/helm/OwnedResources.test.tsx +86 -0
  48. package/src/components/helm/OwnedResources.tsx +69 -10
  49. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  50. package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
  51. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  52. package/src/components/home/ClusterHealthCard.tsx +49 -14
  53. package/src/components/home/HelmSummary.tsx +38 -19
  54. package/src/components/home/HelmSummary.unread.test.ts +16 -0
  55. package/src/components/home/HomeAgentBlock.tsx +7 -0
  56. package/src/components/home/MCPSetupDialog.test.tsx +38 -12
  57. package/src/components/home/MCPSetupDialog.tsx +5 -2
  58. package/src/components/home/mcpToolCatalog.ts +45 -5
  59. package/src/components/issues/uncheckedSources.test.ts +2 -0
  60. package/src/components/issues/uncheckedSources.ts +3 -0
  61. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  62. package/src/components/resource/RightsizingStrip.tsx +53 -4
  63. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  64. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  65. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  66. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  67. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  68. package/src/components/resources/pod-file-upload.ts +266 -0
  69. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  70. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  71. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  72. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  73. package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
  74. package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
  75. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
  76. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
  77. package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
  78. package/src/components/rightsizing/model.test.ts +11 -0
  79. package/src/components/rightsizing/model.ts +3 -1
  80. package/src/components/rightsizing/presentation.test.ts +46 -0
  81. package/src/components/rightsizing/presentation.ts +17 -2
  82. package/src/components/traffic/TrafficView.tsx +27 -27
  83. package/src/components/traffic/trafficFilters.test.ts +18 -1
  84. package/src/components/traffic/trafficFilters.ts +30 -1
  85. package/src/components/ui/Omnibar.tsx +4 -1
  86. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  87. package/src/components/ui/RadarOmnibar.tsx +7 -1
  88. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  89. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  90. package/src/components/ui/UpdateNotification.test.tsx +23 -1
  91. package/src/components/ui/UpdateNotification.tsx +26 -2
  92. package/src/components/ui/omnibar-match.test.ts +7 -0
  93. package/src/components/ui/omnibar-match.ts +1 -0
  94. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  95. package/src/components/ui/searchCoverageNote.ts +31 -7
  96. package/src/components/useContextSwitchFlow.tsx +9 -1
  97. package/src/components/whats-new/releaseNotes.ts +1 -1
  98. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  99. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  100. package/src/components/workload/WorkloadView.tsx +51 -11
  101. package/src/context/ConnectionContext.test.ts +1 -0
  102. package/src/context/ConnectionContext.tsx +2 -2
  103. package/src/contexts/CapabilitiesContext.tsx +2 -0
  104. package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
  105. package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
  106. package/src/integrations/resourceHosts.test.tsx +2 -2
  107. package/src/integrations/resourceHosts.tsx +9 -0
  108. package/src/utils/namespacePick.test.ts +87 -0
  109. package/src/utils/namespacePick.ts +88 -0
@@ -0,0 +1,146 @@
1
+ import type { ReactNode } from 'react'
2
+ import { Info } from 'lucide-react'
3
+ import { Disclosure } from '@skyhook-io/k8s-ui/components/ui/Disclosure'
4
+ import { gapReasonText } from '@skyhook-io/k8s-ui/utils/read-actions'
5
+ import type { HelmInventory, ObservedHelmReleaseDetail } from '../../types'
6
+
7
+ const TITLE = 'Built from labels and annotations, not Helm’s own records'
8
+
9
+ function Code({ children }: { children: string }) {
10
+ return <code className="inline-block max-w-full rounded bg-theme-elevated px-1 font-mono text-xs [overflow-wrap:anywhere] text-theme-text-primary">{children}</code>
11
+ }
12
+
13
+ const AFFECTED: { heading: string; items: { term: ReactNode; detail?: ReactNode }[] }[] = [
14
+ {
15
+ heading: 'Where this comes from',
16
+ items: [
17
+ {
18
+ term: <><Code>meta.helm.sh/release-name</Code> and <Code>meta.helm.sh/release-namespace</Code></>,
19
+ detail: 'annotations name the release.',
20
+ },
21
+ { term: <Code>helm.sh/chart</Code>, detail: 'label gives the chart and version.' },
22
+ { term: <Code>app.kubernetes.io/version</Code>, detail: 'label gives the app version.' },
23
+ ],
24
+ },
25
+ {
26
+ heading: 'Not shown',
27
+ items: [
28
+ { term: 'Status, revision and last update.', detail: 'A listed release may be failed or part-way through an upgrade.' },
29
+ {
30
+ term: 'History, compare, values, manifest, notes and hooks.',
31
+ detail: 'Helm keeps these in the same Secrets. For a Flux-managed release, you’ll see the history Flux recorded if you can read its HelmRelease.',
32
+ },
33
+ { term: 'Install, upgrade, rollback and uninstall.', detail: 'Helm records each of them in those Secrets.' },
34
+ ],
35
+ },
36
+ {
37
+ heading: 'Not listed',
38
+ items: [
39
+ { term: 'Releases that failed before creating any object.' },
40
+ { term: 'Releases with no object you can read.' },
41
+ { term: <>Charts that deploy only CRDs from <Code>crds/</Code>.</>, detail: 'Helm doesn’t label those.' },
42
+ { term: 'Releases whose objects all have a controller owner,', detail: 'as Helm operators arrange. Radar skips owned objects.' },
43
+ ],
44
+ },
45
+ {
46
+ heading: 'Can differ from Helm',
47
+ items: [
48
+ {
49
+ term: 'A row is a claim, not proof.',
50
+ detail: 'Anyone who can edit an object can set these annotations, so a listed release may not exist.',
51
+ },
52
+ {
53
+ term: 'Objects kept after an uninstall',
54
+ detail: <>can still show up as a release, for example with <Code>helm.sh/resource-policy: keep</Code>.</>,
55
+ },
56
+ {
57
+ term: <>Charts without <Code>helm.sh/chart</Code></>,
58
+ detail: <>show no chart or version. App version needs <Code>app.kubernetes.io/version</Code>.</>,
59
+ },
60
+ { term: 'A release can show a subchart as its chart', detail: 'if it’s named like one, or a subchart is all you can read.' },
61
+ { term: 'Several charts on one release.', detail: 'If none matches the release name, Radar shows them all rather than pick one.' },
62
+ { term: 'Object counts and health', detail: 'cover only what you can read, leaving out Secrets and kinds Radar isn’t watching.' },
63
+ ],
64
+ },
65
+ ]
66
+
67
+ /** Where Helm's storage couldn't be read, for the opening sentence. */
68
+ function deniedScope(inventory: HelmInventory): string {
69
+ const denied = inventory.storageDenied
70
+ if (!denied || denied.extent === 'all') return 'Radar can’t read Helm’s release Secrets here'
71
+ if (denied.extent === 'unknown') return 'Radar can’t read Helm’s release Secrets in some namespaces'
72
+ const names = denied.names ?? []
73
+ if (names.length > 0 && names.length <= 3) return `Radar can’t read Helm’s release Secrets in ${names.join(', ')}`
74
+ return `Radar can’t read Helm’s release Secrets in ${denied.count} namespaces`
75
+ }
76
+
77
+ /** What the object read itself didn't reach, on top of what stamps can't say. */
78
+ function coverageSentence(coverage: HelmInventory['objectCoverage'], subject: string): string | null {
79
+ const gaps = coverage?.gaps ?? []
80
+ if (gaps.length === 0) return null
81
+ const reasons = [...new Set(gaps.map((gap) => gapReasonText(gap.code)))]
82
+ return `Some objects weren’t read (${reasons.join(', ')}), so ${subject} may be missing more than usual.`
83
+ }
84
+
85
+ function NoticeCard({ children }: { children: ReactNode }) {
86
+ return (
87
+ <section aria-label={TITLE} className="mx-4 mt-4 rounded-xl border border-theme-border bg-theme-surface p-4 shadow-theme-sm [contain:inline-size]">
88
+ <div className="flex items-start gap-3">
89
+ <Info className="mt-0.5 h-4 w-4 shrink-0 text-accent" aria-hidden />
90
+ <div className="min-w-0 flex-1">
91
+ <h2 className="text-sm font-semibold text-theme-text-primary">{TITLE}</h2>
92
+ <div className="mt-1 text-sm text-theme-text-secondary">{children}</div>
93
+ </div>
94
+ </div>
95
+ </section>
96
+ )
97
+ }
98
+
99
+ /** The callout above a Helm list that isn't entirely from Helm's storage. */
100
+ export function ObservedHelmNotice({ inventory }: { inventory: HelmInventory }) {
101
+ const coverage = coverageSentence(inventory.objectCoverage, 'this list')
102
+ const mixed = inventory.releases.length > 0
103
+ return (
104
+ <NoticeCard>
105
+ <p>
106
+ {deniedScope(inventory)}, so {mixed ? 'releases there come' : 'this list comes'} from labels and annotations on deployed
107
+ objects. Those Secrets are the source of truth Helm itself uses, so this view can miss things, and a failed release can look fine.
108
+ </p>
109
+ {coverage && <p className="mt-1">{coverage}</p>}
110
+ <p className="mt-2">
111
+ <span className="font-medium text-theme-text-primary">How to get the full view:</span> get and list access to Secrets in the
112
+ namespace where Helm stores a release, usually the release’s namespace. That opens every Secret there to whoever holds it. Without
113
+ sign-in, Radar’s own identity holds it, so it reaches everyone who can open Radar.
114
+ </p>
115
+ <Disclosure summary="What’s affected" className="mt-3" summaryClassName="font-medium text-accent-text">
116
+ <div className="mt-3 grid grid-cols-[repeat(auto-fit,minmax(15rem,1fr))] gap-x-8 gap-y-5 border-t border-theme-border pt-3">
117
+ {AFFECTED.map(({ heading, items }) => (
118
+ <section key={heading} aria-label={heading}>
119
+ <h3 className="mb-2 font-semibold text-theme-text-primary">{heading}</h3>
120
+ <ul className="space-y-2 text-xs leading-5">
121
+ {items.map(({ term, detail }, index) => (
122
+ <li key={index}>
123
+ <span className="font-medium text-theme-text-primary">{term}</span>{detail && <> {detail}</>}
124
+ </li>
125
+ ))}
126
+ </ul>
127
+ </section>
128
+ ))}
129
+ </div>
130
+ </Disclosure>
131
+ </NoticeCard>
132
+ )
133
+ }
134
+
135
+ /** The drawer's short form: the list carries the detail. */
136
+ export function ObservedHelmDrawerNote({ coverage, refreshFailed }: { coverage?: ObservedHelmReleaseDetail['objectCoverage']; refreshFailed?: boolean }) {
137
+ const gaps = coverageSentence(coverage, 'this release')
138
+ return (
139
+ <NoticeCard>
140
+ Radar can’t read Helm’s release Secrets here, Helm’s source of truth, so this view can miss things, and a failed release can look
141
+ fine. Helm’s history, manifest, values and hooks aren’t available.
142
+ {gaps && <p className="mt-1">{gaps}</p>}
143
+ {refreshFailed && <p className="mt-1">Radar couldn’t refresh this, so it shows the last read.</p>}
144
+ </NoticeCard>
145
+ )
146
+ }
@@ -0,0 +1,261 @@
1
+ // @vitest-environment jsdom
2
+ import { act, type ReactElement } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
+ import { MemoryRouter } from 'react-router-dom'
6
+ import { afterEach, describe, expect, it, vi } from 'vitest'
7
+ import type { HelmInventory, ObservedHelmRelease } from '../../types'
8
+ import { ApiError, isHelmReleaseReadDenied } from '../../api/client'
9
+ import { compareRows, HelmView } from './HelmView'
10
+ import { ObservedHelmNotice } from './ObservedHelmNotice'
11
+
12
+ const inventoryState = vi.hoisted(() => ({
13
+ current: { data: undefined, isPending: false, error: null } as { data?: unknown; isPending: boolean; error: unknown },
14
+ refetchUpgrades: vi.fn(),
15
+ }))
16
+
17
+ vi.mock('../../api/client', async (importOriginal) => ({
18
+ ...(await importOriginal<typeof import('../../api/client')>()),
19
+ useHelmInventory: () => ({ ...inventoryState.current, dataUpdatedAt: 0, isFetching: false, refetch: vi.fn() }),
20
+ useHelmBatchUpgradeInfo: () => ({ data: undefined, isLoading: false, error: null, refetch: inventoryState.refetchUpgrades }),
21
+ }))
22
+ vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
23
+ vi.mock('../../hooks/useKeyboardShortcuts', () => ({ useRegisterShortcuts: () => undefined }))
24
+ vi.mock('./ChartBrowser', () => ({ ChartBrowser: () => null }))
25
+ vi.mock('@skyhook-io/k8s-ui', async (importOriginal) => ({
26
+ ...(await importOriginal<typeof import('@skyhook-io/k8s-ui')>()),
27
+ FreshnessControl: ({ onRefresh }: { onRefresh: () => void }) => <button onClick={onRefresh}>Refresh</button>,
28
+ }))
29
+ vi.mock('./InstallWizard', () => ({ InstallWizard: () => null }))
30
+
31
+ ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
32
+
33
+ let root: Root | undefined
34
+
35
+ function mount(element: ReactElement): HTMLElement {
36
+ const container = document.createElement('div')
37
+ document.body.appendChild(container)
38
+ root = createRoot(container)
39
+ act(() => root!.render(element))
40
+ return container
41
+ }
42
+
43
+ afterEach(() => {
44
+ act(() => root?.unmount())
45
+ root = undefined
46
+ document.body.innerHTML = ''
47
+ })
48
+
49
+ const observed: ObservedHelmRelease = { name: 'api', namespace: 'team-b', chart: 'api', chartVersion: '1.2.3', appVersion: '9.9', resourceCount: 3, resourceHealth: 'healthy', healthSummary: '1/1 ready' }
50
+
51
+ function denied(rows: ObservedHelmRelease[]): HelmInventory {
52
+ return { releases: [], observed: rows, storageDenied: { count: 2, names: ['team-a', 'team-b'] }, objectCoverage: { status: 'complete', gaps: [] } }
53
+ }
54
+
55
+ function renderView(state: Partial<typeof inventoryState.current>) {
56
+ inventoryState.current = { data: undefined, isPending: false, error: null, ...state }
57
+ return mount(
58
+ <QueryClientProvider client={new QueryClient()}>
59
+ <MemoryRouter>
60
+ <HelmView namespaces={[]} />
61
+ </MemoryRouter>
62
+ </QueryClientProvider>,
63
+ )
64
+ }
65
+
66
+ function row(container: HTMLElement, name: string): string {
67
+ const match = [...container.querySelectorAll('tbody tr')].find((tr) => tr.textContent?.startsWith(name))
68
+ expect(match).toBeDefined()
69
+ return match!.textContent ?? ''
70
+ }
71
+
72
+ describe('Helm list without Secret access', () => {
73
+ it('never shows a status, revision or update time for an observed row', () => {
74
+ const text = row(renderView({ data: denied([observed]) }), 'api')
75
+ expect(text).toContain('Unknown')
76
+ expect(text).toContain('api-1.2.3')
77
+ expect(text).not.toMatch(/deployed/i)
78
+ })
79
+
80
+ it('names several charts instead of picking one, and an unlabelled chart as unknown', () => {
81
+ const container = renderView({ data: denied([
82
+ { name: 'umbrella', namespace: 'team-b', otherCharts: ['parent-2.0.0', 'sub-0.5.0'], resourceCount: 4 },
83
+ { name: 'plain', namespace: 'team-b', resourceCount: 1 },
84
+ ]) })
85
+ expect(row(container, 'umbrella')).toContain('Several charts')
86
+ expect(row(container, 'plain').match(/Unknown/g)).toHaveLength(2)
87
+ })
88
+
89
+ it('says versions are mixed rather than picking one', () => {
90
+ const text = row(renderView({ data: denied([
91
+ { name: 'api', namespace: 'team-b', chart: 'api', chartVersions: ['1.0.0', '2.0.0'], appVersions: ['1', '2'], resourceCount: 4 },
92
+ ]) }), 'api')
93
+ expect(text).toContain('api, mixed versions')
94
+ expect(text).toContain('Mixed')
95
+ expect(text).toContain('versions differ')
96
+ expect(text).not.toContain('api-2.0.0')
97
+ expect(row(renderView({ data: denied([observed]) }), 'api')).not.toContain('versions differ')
98
+ })
99
+
100
+ it('finds a release with several charts by any of their names', () => {
101
+ const container = renderView({ data: denied([
102
+ { name: 'umbrella', namespace: 'team-b', otherCharts: ['parent-2.0.0', 'sub-0.5.0'], resourceCount: 4 },
103
+ observed,
104
+ ]) })
105
+ const search = container.querySelector<HTMLInputElement>('input[placeholder="Search releases..."]')!
106
+ const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!
107
+ act(() => {
108
+ setValue.call(search, 'parent')
109
+ search.dispatchEvent(new Event('input', { bubbles: true }))
110
+ })
111
+ const names = [...container.querySelectorAll('tbody tr')].map((tr) => tr.textContent ?? '')
112
+ expect(names.some((text) => text.startsWith('umbrella'))).toBe(true)
113
+ expect(names.some((text) => text.startsWith('api'))).toBe(false)
114
+ })
115
+
116
+ it('does not let an empty list read as no releases', () => {
117
+ const text = renderView({ data: denied([]) }).textContent
118
+ expect(text).toContain('No releases found on the objects you can read')
119
+ expect(text).toContain('doesn’t mean there are no releases')
120
+ expect(text).not.toContain('No Helm releases found')
121
+ expect(text).not.toContain('Browse charts to install')
122
+ })
123
+
124
+ it('shows no callout when everything came from Helm', () => {
125
+ const text = renderView({ data: { releases: [], observed: [] } }).textContent
126
+ expect(text).toContain('No Helm releases found')
127
+ expect(text).not.toContain('Built from labels and annotations')
128
+ })
129
+
130
+ it('does not refresh upgrade checks when no row came from Helm', () => {
131
+ inventoryState.refetchUpgrades.mockClear()
132
+ const container = renderView({ data: denied([observed]) })
133
+ const refresh = [...container.querySelectorAll('button')].find((b) => b.textContent === 'Refresh')!
134
+ act(() => refresh.click())
135
+ expect(inventoryState.refetchUpgrades).not.toHaveBeenCalled()
136
+ })
137
+
138
+ it('still refreshes upgrade checks for rows from Helm', () => {
139
+ inventoryState.refetchUpgrades.mockClear()
140
+ const release = { name: 'x', namespace: 'ns', chart: 'c', chartVersion: '1', appVersion: '1', status: 'deployed', revision: 1, updated: '2026-01-01T00:00:00Z' }
141
+ const container = renderView({ data: { releases: [release], observed: [] } })
142
+ const refresh = [...container.querySelectorAll('button')].find((b) => b.textContent === 'Refresh')!
143
+ act(() => refresh.click())
144
+ expect(inventoryState.refetchUpgrades).toHaveBeenCalledOnce()
145
+ })
146
+
147
+ it('waits rather than saying there are no releases while the read has not started', () => {
148
+ expect(renderView({ isPending: true }).textContent).not.toContain('No Helm releases found')
149
+ })
150
+
151
+ it('keeps the restricted state for a Radar without the inventory', () => {
152
+ expect(renderView({ error: new ApiError('forbidden', 403) }).textContent).toContain('Access Restricted')
153
+ })
154
+ })
155
+
156
+ describe('columns only Helm can fill', () => {
157
+ const headers = (container: HTMLElement) => [...container.querySelectorAll('th')].map((th) => th.textContent)
158
+
159
+ it('drops revision and update time when no row has them', () => {
160
+ const labels = headers(renderView({ data: denied([observed]) }))
161
+ expect(labels.join()).toContain('Status')
162
+ expect(labels.join()).not.toMatch(/Rev|Updated/)
163
+ })
164
+
165
+ it('keeps them when any row came from Helm', () => {
166
+ const data = { ...denied([observed]), releases: [{ name: 'web', namespace: 'team-a', chart: 'web', chartVersion: '1', appVersion: '1', status: 'deployed', revision: 2, updated: '2026-01-01T00:00:00Z' }] }
167
+ expect(headers(renderView({ data })).join()).toMatch(/Rev.*Updated/)
168
+ })
169
+ })
170
+
171
+ describe('health on an observed row', () => {
172
+ it('states healthy objects as a count, with no green mark beside an unknown status', () => {
173
+ const container = renderView({ data: denied([observed]) })
174
+ expect(row(container, 'api')).toContain('1/1 ready')
175
+ expect(container.querySelector('tbody .badge-sm .rounded-full')).toBeNull()
176
+ })
177
+
178
+ it('keeps the mark on a real problem', () => {
179
+ const container = renderView({ data: denied([{ ...observed, resourceHealth: 'unhealthy', healthSummary: '0/1 ready' }]) })
180
+ expect(row(container, 'api')).toContain('0/1 ready')
181
+ expect(container.querySelector('tbody .badge-sm .rounded-full')).not.toBeNull()
182
+ })
183
+ })
184
+
185
+ describe('ObservedHelmNotice', () => {
186
+ it('names what it reads and that it can miss things, before any expanding', () => {
187
+ const text = mount(<ObservedHelmNotice inventory={denied([observed])} />).textContent
188
+ expect(text).toContain('Built from labels and annotations, not Helm’s own records')
189
+ for (const name of ['meta.helm.sh/release-name', 'meta.helm.sh/release-namespace', 'helm.sh/chart', 'app.kubernetes.io/version']) {
190
+ expect(text).toContain(name)
191
+ }
192
+ expect(text).toContain('source of truth Helm itself uses, so this view can miss things, and a failed release can look fine')
193
+ expect(text).toContain('in team-a, team-b')
194
+ })
195
+
196
+ it('keeps the detail behind the disclosure', () => {
197
+ const container = mount(<ObservedHelmNotice inventory={denied([observed])} />)
198
+ const toggle = container.querySelector('button')!
199
+ expect(toggle.textContent).toContain('What’s affected')
200
+ expect(toggle.getAttribute('aria-expanded')).toBe('false')
201
+ expect(container.textContent).toContain('How to get the full view: get and list access to Secrets')
202
+ expect(container.textContent).toContain('That opens every Secret there')
203
+ act(() => toggle.click())
204
+ expect(toggle.getAttribute('aria-expanded')).toBe('true')
205
+ expect(container.textContent).toContain('Releases that failed before creating any object.')
206
+ for (const heading of ['Not shown', 'Not listed', 'Can differ from Helm']) {
207
+ expect(container.querySelector(`section[aria-label="${heading}"]`)).not.toBeNull()
208
+ }
209
+ })
210
+
211
+ it('counts namespaces it cannot name', () => {
212
+ const text = mount(<ObservedHelmNotice inventory={{ ...denied([]), storageDenied: { count: 80 } }} />).textContent
213
+ expect(text).toContain('in 80 namespaces')
214
+ })
215
+
216
+ it('speaks of the whole view when everything was denied', () => {
217
+ const text = mount(<ObservedHelmNotice inventory={{ ...denied([]), storageDenied: { extent: 'all' } }} />).textContent
218
+ expect(text).toContain('Radar can’t read Helm’s release Secrets here')
219
+ })
220
+
221
+ it('says where the rows come from when only some are observed', () => {
222
+ const inventory = { ...denied([observed]), releases: [{ name: 'x' } as HelmInventory['releases'][number]], storageDenied: { count: 1, names: ['team-b'] } }
223
+ expect(mount(<ObservedHelmNotice inventory={inventory} />).textContent).toContain('releases there come from')
224
+ })
225
+
226
+ it('adds what the object read itself did not reach', () => {
227
+ const inventory: HelmInventory = { ...denied([]), objectCoverage: { status: 'partial', gaps: [{ code: 'kind_sync_pending', action: 'retry' }] } }
228
+ expect(mount(<ObservedHelmNotice inventory={inventory} />).textContent).toContain('Some objects weren’t read (still loading)')
229
+ })
230
+ })
231
+
232
+ describe('compareRows', () => {
233
+ const full = (name: string, status: string, revision: number) => ({
234
+ observed: false as const,
235
+ release: { name, namespace: 'ns', chart: 'c', chartVersion: '1', appVersion: '1', status, revision, updated: '2026-01-01T00:00:00Z' } as HelmInventory['releases'][number],
236
+ })
237
+ const seen = (name: string) => ({ observed: true as const, release: { name, namespace: 'ns', resourceCount: 1 } })
238
+
239
+ it('sorts an unknown value last in both directions', () => {
240
+ for (const direction of [1, -1] as const) {
241
+ const sorted = [seen('b'), full('a', 'deployed', 2), seen('a'), full('b', 'failed', 1)]
242
+ .sort((x, y) => compareRows(x, y, 'revision', direction))
243
+ .map((r) => r.observed)
244
+ expect(sorted).toEqual([false, false, true, true])
245
+ }
246
+ })
247
+
248
+ it('sorts what an observed row does know alongside the rest', () => {
249
+ const sorted = [seen('b'), full('a', 'deployed', 2)].sort((x, y) => compareRows(x, y, 'name', 1))
250
+ expect(sorted[0].release.name).toBe('a')
251
+ })
252
+ })
253
+
254
+ describe('isHelmReleaseReadDenied', () => {
255
+ it('matches only the caller being refused Helm storage', () => {
256
+ expect(isHelmReleaseReadDenied(new ApiError('no', 403, { error_code: 'release_read_denied' }))).toBe(true)
257
+ expect(isHelmReleaseReadDenied(new ApiError('no', 403))).toBe(false)
258
+ expect(isHelmReleaseReadDenied(new ApiError('no', 403, { error_code: 'other' }))).toBe(false)
259
+ expect(isHelmReleaseReadDenied(new ApiError('no', 500, { error_code: 'release_read_denied' }))).toBe(false)
260
+ })
261
+ })
@@ -0,0 +1,80 @@
1
+ // @vitest-environment jsdom
2
+ import { act, type ReactElement } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { MemoryRouter } from 'react-router-dom'
5
+ import { afterEach, describe, expect, it, vi } from 'vitest'
6
+ import { ApiError } from '../../api/client'
7
+ import type { ObservedHelmReleaseDetail, SelectedHelmRelease } from '../../types'
8
+ import { ObservedHelmReleaseDrawer } from './ObservedHelmReleaseDrawer'
9
+
10
+ const detail = vi.hoisted(() => ({ current: {} as { data?: unknown; error?: unknown } }))
11
+
12
+ vi.mock('../../api/client', async (importOriginal) => ({
13
+ ...(await importOriginal<typeof import('../../api/client')>()),
14
+ useObservedHelmRelease: () => ({ ...detail.current, isLoading: false, refetch: vi.fn() }),
15
+ }))
16
+
17
+ const release = { namespace: 'team-a', name: 'web', observed: true } as SelectedHelmRelease
18
+ const seen = { name: 'web', namespace: 'team-a', chart: 'web', resources: [] } as unknown as ObservedHelmReleaseDetail
19
+
20
+ let root: Root | undefined
21
+
22
+ function mount(element: ReactElement): HTMLElement {
23
+ const container = document.createElement('div')
24
+ document.body.appendChild(container)
25
+ root = createRoot(container)
26
+ act(() => root!.render(<MemoryRouter>{element}</MemoryRouter>))
27
+ return container
28
+ }
29
+
30
+ afterEach(() => {
31
+ act(() => root?.unmount())
32
+ root = undefined
33
+ document.body.innerHTML = ''
34
+ })
35
+
36
+ describe('a refresh that fails while the drawer shows a release', () => {
37
+ it('stops showing a release that is gone', () => {
38
+ detail.current = { data: seen, error: new ApiError('not found', 404) }
39
+ const text = mount(<ObservedHelmReleaseDrawer release={release} onClose={vi.fn()} />).textContent
40
+ expect(text).toContain('No release found on the objects you can read')
41
+ expect(text).not.toContain('Object health')
42
+ })
43
+
44
+ it('keeps what it has through a passing failure, and says it did', () => {
45
+ detail.current = { data: seen, error: new ApiError('unavailable', 503) }
46
+ const text = mount(<ObservedHelmReleaseDrawer release={release} onClose={vi.fn()} />).textContent
47
+ expect(text).toContain('Object health')
48
+ expect(text).toContain('couldn’t refresh this, so it shows the last read')
49
+ })
50
+ })
51
+
52
+ describe('tabs on an observed release', () => {
53
+ const tabLabels = (container: HTMLElement) => [...container.querySelectorAll('button')].map((b) => b.textContent?.trim()).filter(Boolean)
54
+
55
+ it('offers only what can hold data', () => {
56
+ detail.current = { data: seen }
57
+ const labels = tabLabels(mount(<ObservedHelmReleaseDrawer release={release} onClose={vi.fn()} />))
58
+ expect(labels).toEqual(expect.arrayContaining(['Overview', 'Resources']))
59
+ for (const gone of ['History', 'Manifest', 'Values', 'Hooks']) expect(labels).not.toContain(gone)
60
+ })
61
+
62
+ it('adds History where Flux recorded one', () => {
63
+ detail.current = { data: { ...seen, fluxHistory: [{ revision: 1 }] } }
64
+ expect(tabLabels(mount(<ObservedHelmReleaseDrawer release={release} onClose={vi.fn()} />))).toContain('History')
65
+ })
66
+
67
+ it('says what the read missed', () => {
68
+ detail.current = { data: { ...seen, objectCoverage: { gaps: [{ code: 'kind_sync_pending' }] } } }
69
+ expect(mount(<ObservedHelmReleaseDrawer release={release} onClose={vi.fn()} />).textContent).toContain('so this release may be missing more than usual')
70
+ })
71
+ })
72
+
73
+ describe('versions on an observed release', () => {
74
+ it('shows versions that disagree rather than calling them unknown', () => {
75
+ detail.current = { data: { ...seen, chartVersions: ['1.0.0', '2.0.0'], appVersions: ['1.0', '2.0'] } }
76
+ const text = mount(<ObservedHelmReleaseDrawer release={release} onClose={vi.fn()} />).textContent
77
+ expect(text).toContain('Mixed: 1.0.0, 2.0.0')
78
+ expect(text).toContain('Mixed: 1.0, 2.0')
79
+ })
80
+ })