@skyhook-io/radar-app 1.17.1 → 1.18.1

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 (146) hide show
  1. package/README.md +6 -0
  2. package/package.json +10 -11
  3. package/src/App.tsx +36 -36
  4. package/src/api/client.gitops-destination.test.tsx +55 -0
  5. package/src/api/client.gitopsPoll.test.ts +99 -0
  6. package/src/api/client.helmPreview.test.tsx +48 -0
  7. package/src/api/client.resource-list.test.ts +76 -0
  8. package/src/api/client.resourceAvailability.test.ts +24 -0
  9. package/src/api/client.ts +396 -105
  10. package/src/api/client.workloadRuns.test.ts +53 -0
  11. package/src/api/config.test.ts +23 -1
  12. package/src/api/config.ts +7 -3
  13. package/src/api/diagnose.ts +4 -1
  14. package/src/api/drain-plan.test.ts +70 -40
  15. package/src/api/policy.ts +5 -5
  16. package/src/api/quotas.ts +9 -20
  17. package/src/api/radarFeatures.ts +3 -0
  18. package/src/api/resourceLists.test.ts +84 -0
  19. package/src/api/resourceLists.ts +71 -0
  20. package/src/api/traffic.scope.render.test.tsx +60 -0
  21. package/src/api/traffic.ts +3 -1
  22. package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
  23. package/src/components/cnpg/CNPGView.tsx +1 -0
  24. package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
  25. package/src/components/compare/CompareViewRoute.tsx +5 -1
  26. package/src/components/compare/useCompareCandidates.ts +1 -1
  27. package/src/components/compare/useCompareLauncher.tsx +4 -2
  28. package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
  29. package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
  30. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
  31. package/src/components/diagnose/InvestigationView.tsx +2 -1
  32. package/src/components/diagnose/StoryExcerpt.tsx +24 -5
  33. package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
  34. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
  35. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
  36. package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
  37. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
  38. package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
  39. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
  40. package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
  41. package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
  42. package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
  43. package/src/components/diagnose/investigationEvidence/builder.ts +13 -1
  44. package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
  45. package/src/components/diagnose/investigationEvidence/observations.ts +21 -0
  46. package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
  47. package/src/components/diagnose/investigationEvidence/projection.test.ts +131 -1
  48. package/src/components/diagnose/investigationEvidence/types.ts +26 -0
  49. package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
  50. package/src/components/diagnose/investigationState.test.ts +36 -1
  51. package/src/components/diagnose/investigationState.ts +8 -0
  52. package/src/components/diagnose/launch.ts +2 -2
  53. package/src/components/diagnose/toolCallLabel.test.ts +9 -0
  54. package/src/components/diagnose/toolCallLabel.ts +2 -0
  55. package/src/components/dock/BottomDock.tsx +6 -3
  56. package/src/components/dock/WorkloadLogsTab.tsx +3 -0
  57. package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
  58. package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
  59. package/src/components/execution/BatchExecutionView.tsx +28 -11
  60. package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
  61. package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
  62. package/src/components/gitops/GitOpsView.tsx +69 -40
  63. package/src/components/gitops/useDestinationCluster.ts +2 -1
  64. package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
  65. package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
  66. package/src/components/helm/ChartBrowser.tsx +5 -4
  67. package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
  68. package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
  69. package/src/components/helm/HelmReleaseNotes.tsx +26 -0
  70. package/src/components/helm/OwnedResources.tsx +2 -2
  71. package/src/components/helm/TrackChartSourceDialog.render.test.tsx +295 -50
  72. package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
  73. package/src/components/helm/TrackChartSourceDialog.tsx +614 -85
  74. package/src/components/helm/ValuesDiffPreview.tsx +4 -1
  75. package/src/components/home/ClusterHealthCard.tsx +4 -4
  76. package/src/components/home/CostCard.test.tsx +100 -0
  77. package/src/components/home/CostCard.tsx +2 -2
  78. package/src/components/home/HelmSummary.tsx +2 -2
  79. package/src/components/home/HomeView.tsx +15 -6
  80. package/src/components/home/MCPSetupDialog.test.tsx +30 -0
  81. package/src/components/home/MCPSetupDialog.tsx +13 -6
  82. package/src/components/home/ProblemsPanel.test.tsx +1 -0
  83. package/src/components/home/mcpToolCatalog.ts +28 -2
  84. package/src/components/issues/IssuesPane.render.test.tsx +21 -0
  85. package/src/components/issues/IssuesPane.tsx +31 -7
  86. package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
  87. package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
  88. package/src/components/issues/uncheckedSources.test.ts +43 -0
  89. package/src/components/issues/uncheckedSources.ts +58 -5
  90. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
  91. package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
  92. package/src/components/resource/PrometheusCharts.tsx +2 -2
  93. package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
  94. package/src/components/resources/ImageFilesystemModal.tsx +11 -4
  95. package/src/components/resources/PodFilesystemModal.tsx +2 -2
  96. package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
  97. package/src/components/resources/ResourcesView.tsx +46 -69
  98. package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
  99. package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
  100. package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
  101. package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
  102. package/src/components/resources/renderers/PodRenderer.tsx +4 -1
  103. package/src/components/settings/MyPermissionsDialog.tsx +12 -9
  104. package/src/components/settings/SettingsDialog.tsx +21 -15
  105. package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
  106. package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
  107. package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
  108. package/src/components/traffic/TrafficSourcePill.tsx +111 -0
  109. package/src/components/traffic/TrafficView.tsx +21 -67
  110. package/src/components/traffic/trafficFilters.test.ts +20 -1
  111. package/src/components/traffic/trafficFilters.ts +13 -0
  112. package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
  113. package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
  114. package/src/components/ui/Omnibar.note.test.tsx +141 -0
  115. package/src/components/ui/Omnibar.tsx +89 -14
  116. package/src/components/ui/RadarOmnibar.test.tsx +183 -0
  117. package/src/components/ui/RadarOmnibar.tsx +38 -4
  118. package/src/components/ui/Toast.tsx +1 -1
  119. package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
  120. package/src/components/ui/UpdateNotification.test.tsx +2 -1
  121. package/src/components/ui/UpdateNotification.tsx +29 -5
  122. package/src/components/ui/omnibar-match.test.ts +37 -0
  123. package/src/components/ui/omnibar-match.ts +23 -0
  124. package/src/components/ui/searchCoverage.fixtures.ts +16 -0
  125. package/src/components/ui/searchCoverageNote.test.ts +245 -0
  126. package/src/components/ui/searchCoverageNote.ts +222 -0
  127. package/src/components/whats-new/WhatsNew.test.ts +10 -0
  128. package/src/components/whats-new/WhatsNew.tsx +5 -4
  129. package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
  130. package/src/components/whats-new/releaseNotes.ts +57 -5
  131. package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
  132. package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
  133. package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
  134. package/src/components/workload/NodeDrainStatus.tsx +55 -0
  135. package/src/components/workload/WorkloadView.tsx +43 -5
  136. package/src/context/ConnectionContext.test.ts +27 -1
  137. package/src/context/ConnectionContext.tsx +17 -7
  138. package/src/hooks/useResourceCounts.ts +2 -0
  139. package/src/index.css +2 -4
  140. package/src/index.ts +7 -0
  141. package/src/integrations/resourceHosts.test.tsx +1 -0
  142. package/src/integrations/resourceHosts.tsx +2 -0
  143. package/src/utils/artifacthub.test.ts +18 -0
  144. package/src/utils/artifacthub.ts +9 -0
  145. package/src/utils/navigation.ts +14 -0
  146. package/src/utils/wails-clipboard.ts +4 -2
@@ -2,14 +2,21 @@
2
2
  import { act, type InputHTMLAttributes, type ReactNode } from 'react'
3
3
  import { createRoot, type Root } from 'react-dom/client'
4
4
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
5
- import type { ChartSourceStatus, HelmRepository } from '../../types'
5
+ import type { ArtifactHubChart, ChartSourceStatus, HelmRepository, SourceUpgradeSelection } from '../../types'
6
6
  import { TrackChartSourceDialog } from './TrackChartSourceDialog'
7
7
 
8
8
  const state = vi.hoisted(() => ({
9
9
  status: undefined as ChartSourceStatus | undefined,
10
10
  repositories: [] as HelmRepository[],
11
11
  isOwner: true,
12
+ configManaged: false,
13
+ statusFetching: false,
14
+ featureSupported: true,
15
+ associateSource: vi.fn(),
12
16
  addRepository: vi.fn(),
17
+ addOCI: vi.fn(),
18
+ searchCharts: [] as ArtifactHubChart[],
19
+ ociSources: [] as string[],
13
20
  }))
14
21
 
15
22
  vi.mock('@skyhook-io/k8s-ui/components/ui/DialogPortal', () => ({
@@ -17,21 +24,24 @@ vi.mock('@skyhook-io/k8s-ui/components/ui/DialogPortal', () => ({
17
24
  }))
18
25
  vi.mock('@skyhook-io/k8s-ui', () => ({
19
26
  Input: (props: InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
27
+ Badge: ({ children }: { children: ReactNode }) => <span>{children}</span>,
20
28
  }))
21
29
  vi.mock('../settings/OperatorManagedNotice', () => ({ OperatorManagedNotice: () => null }))
22
30
  vi.mock('../../api/client', () => {
23
31
  const idle = { mutate: vi.fn(), mutateAsync: vi.fn(), isPending: false }
24
32
  return {
25
- useHelmSourceStatus: () => ({ data: state.status, error: null, refetch: vi.fn() }),
33
+ useRadarFeature: () => ({ support: state.featureSupported ? 'supported' : 'unsupported' }),
34
+ useHelmSourceStatus: () => ({ data: state.status, error: null, isFetching: state.statusFetching, refetch: vi.fn() }),
26
35
  useHelmRepositories: () => ({ data: state.repositories, isLoading: false }),
27
- useHelmOCISources: () => ({ data: [] }),
36
+ useHelmOCISources: () => ({ data: state.ociSources }),
28
37
  useClusterInfo: () => ({ data: { inCluster: false } }),
29
- useCapabilities: () => ({ data: { configManagement: 'local' } }),
38
+ useCapabilities: () => ({ data: { configManagement: state.configManaged ? 'operator' : 'local' } }),
30
39
  useCloudRole: () => ({ canAtLeast: () => state.isOwner }),
31
40
  useAddHelmRepository: () => ({ mutate: state.addRepository, isPending: false }),
32
- useAddOCISource: () => idle,
41
+ useAddOCISource: () => ({ ...idle, mutate: state.addOCI }),
42
+ useArtifactHubSearch: () => ({ data: { charts: state.searchCharts }, isFetching: false, error: null, refetch: vi.fn() }),
33
43
  useRemoveOCISource: () => idle,
34
- useSetHelmSource: () => idle,
44
+ useSetHelmSource: () => ({ ...idle, mutate: state.associateSource }),
35
45
  }
36
46
  })
37
47
 
@@ -49,8 +59,15 @@ let root: Root
49
59
  beforeEach(() => {
50
60
  state.status = movedMachine
51
61
  state.repositories = []
62
+ state.configManaged = false
63
+ state.statusFetching = false
52
64
  state.isOwner = true
65
+ state.featureSupported = true
66
+ state.associateSource.mockReset()
53
67
  state.addRepository.mockReset()
68
+ state.addOCI.mockReset()
69
+ state.searchCharts = []
70
+ state.ociSources = []
54
71
  const element = document.createElement('div')
55
72
  document.body.appendChild(element)
56
73
  root = createRoot(element)
@@ -61,60 +78,288 @@ afterEach(async () => {
61
78
  document.body.replaceChildren()
62
79
  })
63
80
 
64
- async function renderDialog() {
65
- await act(async () => root.render(<TrackChartSourceDialog open onClose={() => undefined} chartName="podinfo" namespace="web" releaseName="storefront" />))
81
+ async function renderDialog(onSelectUpgradeSource?: (selection: SourceUpgradeSelection) => void, open = true, onClose = () => undefined) {
82
+ await act(async () => root.render(<TrackChartSourceDialog onSelectUpgradeSource={onSelectUpgradeSource} open={open} onClose={onClose} chartName="podinfo" namespace="web" releaseName="storefront" />))
66
83
  }
67
84
 
68
- function addRecordedButton() {
69
- return Array.from(document.querySelectorAll('button')).find(button => button.textContent?.includes('and use it'))
85
+ function button(text: string) {
86
+ const result = Array.from(document.querySelectorAll('button')).find(item => item.textContent === text)
87
+ if (!result) throw new Error(`Missing button: ${text}`)
88
+ return result
70
89
  }
71
90
 
72
- describe('TrackChartSourceDialog one-click add of the recorded repository', () => {
73
- it('adds the recorded URL under the recorded name when that name is free', async () => {
91
+ async function click(text: string) { await act(async () => button(text).click()) }
92
+
93
+ async function fill(input: HTMLInputElement, value: string) {
94
+ await act(async () => {
95
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, value)
96
+ input.dispatchEvent(new Event('input', { bubbles: true }))
97
+ })
98
+ }
99
+
100
+ async function chooseRecorded() {
101
+ const item = document.querySelector<HTMLButtonElement>(`button[aria-label="Choose configured source: ${recordedURL}"]`)
102
+ expect(item).not.toBeNull()
103
+ await act(async () => item?.click())
104
+ }
105
+
106
+ async function searchPublic() {
107
+ await click('ArtifactHub')
108
+ await click('Search ArtifactHub')
109
+ }
110
+
111
+ async function choosePublic(url: string) {
112
+ const item = document.querySelector<HTMLButtonElement>(`button[aria-label="Choose source: ${url}"]`)
113
+ expect(item).not.toBeNull()
114
+ await act(async () => item?.click())
115
+ }
116
+
117
+ describe('compact source picker', () => {
118
+ it.each(['public HTTP', 'public OCI', 'manual HTTP', 'manual OCI', 'recorded restore', 'source check'])('ignores a stale %s completion after closing and reopening the same release', async scenario => {
119
+ const onClose = vi.fn()
120
+ let complete: () => void = () => { throw new Error('Mutation was not started') }
121
+ const capture = (_input: unknown, callbacks: { onSuccess: (result: { name: string }) => void }) => {
122
+ complete = () => callbacks.onSuccess({ name: 'podinfo' })
123
+ }
124
+ state.addRepository.mockImplementation(capture)
125
+ state.addOCI.mockImplementation(capture)
126
+ state.associateSource.mockImplementation(capture)
127
+ if (scenario === 'source check') state.status = { ...movedMachine, recorded: undefined, revision: 1, candidates: [{ type: 'repository', reference: 'podinfo', url: recordedURL }] }
128
+ await renderDialog(vi.fn(), true, onClose)
129
+ if (scenario.startsWith('public')) {
130
+ const url = scenario === 'public OCI' ? 'oci://ghcr.io/stefanprodan/charts/podinfo' : recordedURL
131
+ state.searchCharts = [{ packageId: 'podinfo', name: 'podinfo', version: '6.15.0', stars: 0, repository: { name: 'podinfo', url } }]
132
+ await searchPublic()
133
+ await choosePublic(url)
134
+ await click(scenario === 'public OCI' ? 'Register OCI source' : 'Add repository')
135
+ } else if (scenario.startsWith('manual')) {
136
+ await click('Add manually')
137
+ if (scenario === 'manual OCI') {
138
+ await click('OCI registry')
139
+ const input = document.querySelector<HTMLInputElement>('input')
140
+ if (!input) throw new Error('Missing OCI prefix input')
141
+ await fill(input, 'oci://ghcr.io/stefanprodan/charts')
142
+ } else {
143
+ const fields = document.querySelectorAll<HTMLInputElement>('input')
144
+ await fill(fields[0], 'podinfo')
145
+ await fill(fields[1], recordedURL)
146
+ }
147
+ await act(async () => document.querySelector('form')?.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true })))
148
+ } else {
149
+ await chooseRecorded()
150
+ await click(scenario === 'recorded restore' ? 'Add repository and use it' : 'Check and record source')
151
+ }
152
+ await renderDialog(vi.fn(), false, onClose)
153
+ await renderDialog(vi.fn(), true, onClose)
154
+ if (document.querySelector('form')) await click('Back to sources')
155
+ await click('Add manually')
156
+ await click('Helm repository')
157
+ const field = document.querySelector<HTMLInputElement>('input')
158
+ if (!field) throw new Error('Missing repository name')
159
+ await fill(field, 'new-session-input')
160
+ await act(async () => complete())
161
+ expect(document.querySelector('form')).not.toBeNull()
162
+ expect(document.querySelector<HTMLInputElement>('input')?.value).toBe('new-session-input')
163
+ expect(onClose).not.toHaveBeenCalled()
164
+ })
165
+ it('shows one source list and keeps setup and search behind their own views', async () => {
166
+ state.status = { ...movedMachine, revision: 1 }
167
+ await renderDialog(vi.fn())
168
+ expect(document.querySelectorAll('button[aria-label^="Choose configured source:"]')).toHaveLength(1)
169
+ expect(document.querySelector('input')).toBeNull()
170
+ expect(document.body.textContent).not.toContain('Search ArtifactHub')
171
+ expect(button('Select for upgrade').disabled).toBe(true)
172
+ await click('Add manually')
173
+ expect(document.querySelectorAll('form')).toHaveLength(1)
174
+ expect(document.querySelector('[role="tablist"]')).toBeNull()
175
+ expect(document.querySelector('[placeholder="Repository name"]')).not.toBeNull()
176
+ expect(document.querySelector('[placeholder^="oci://"]')).toBeNull()
177
+ await click('OCI registry')
178
+ expect(document.querySelector('[placeholder="Repository name"]')).toBeNull()
179
+ expect(document.querySelector('[placeholder^="oci://"]')).not.toBeNull()
180
+ })
181
+
182
+ it('restores a recorded source only after selection, retaining the existing associate shortcut', async () => {
74
183
  await renderDialog()
75
- const button = addRecordedButton()
76
- expect(button?.textContent).toBe('Add stefanprodan.github.io/podinfo and use it')
77
- expect(button?.disabled).toBe(false)
78
- expect(document.body.textContent).toContain('Saved in Helm as podinfo, the name it was recorded under.')
79
-
80
- await act(async () => button?.click())
81
- expect(state.addRepository).toHaveBeenCalledWith(
82
- { name: 'podinfo', url: recordedURL, namespace: 'web', releaseName: 'storefront' },
83
- expect.anything(),
84
- )
85
- })
86
-
87
- it('never reuses a recorded name that points at a different repository here', async () => {
88
- state.repositories = [
89
- { name: 'podinfo', url: 'https://impostor.example.test/charts' },
90
- { name: 'podinfo-2', url: 'https://other.example.test' },
91
- ]
184
+ expect(state.addRepository).not.toHaveBeenCalled()
185
+ await chooseRecorded()
186
+ await click('Add repository and use it')
187
+ expect(state.addRepository).toHaveBeenCalledWith({ name: 'podinfo', url: recordedURL, namespace: 'web', releaseName: 'storefront' }, expect.anything())
188
+ })
189
+
190
+ it('picks a free alias and adds without binding when the recorded source needs confirmation', async () => {
191
+ state.status = { ...movedMachine, confirmed: false }
192
+ state.repositories = [{ name: 'podinfo', url: 'https://other.example.test' }]
193
+ await renderDialog()
194
+ await chooseRecorded()
195
+ expect(document.body.textContent).toContain('podinfo-2')
196
+ await click('Add repository')
197
+ expect(state.addRepository).toHaveBeenCalledWith({ name: 'podinfo-2', url: recordedURL }, expect.anything())
198
+ expect(state.associateSource).not.toHaveBeenCalled()
199
+ })
200
+
201
+ it.each(['owner', 'operator'])('prevents configuration writes when restricted by %s policy', async policy => {
202
+ state.isOwner = policy !== 'owner'
203
+ state.configManaged = policy === 'operator'
92
204
  await renderDialog()
93
- expect(document.body.textContent).toContain('Saved in Helm as podinfo-3. The name podinfo already points to a different repository here.')
205
+ await chooseRecorded()
206
+ expect(button('Add repository and use it').disabled).toBe(true)
207
+ await click('Add manually')
208
+ expect(button('Add repository').disabled).toBe(true)
209
+ expect(document.querySelector<HTMLInputElement>('input')?.disabled).toBe(true)
210
+ await click('OCI registry')
211
+ expect(document.querySelector<HTMLInputElement>('input')?.disabled).toBe(true)
212
+ expect(button('Register OCI source').disabled).toBe(true)
213
+ })
214
+
215
+ it('links the active source tab to its panel and supports keyboard navigation', async () => {
216
+ await renderDialog()
217
+ const tabs = document.querySelectorAll<HTMLButtonElement>('[role="tab"]')
218
+ const panel = document.querySelector('[role="tabpanel"]')
219
+ expect(tabs[0].getAttribute('aria-controls')).toBe(panel?.id)
220
+ expect(panel?.getAttribute('aria-labelledby')).toBe(tabs[0].id)
221
+ await act(async () => tabs[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true })))
222
+ expect(tabs[1].getAttribute('aria-selected')).toBe('true')
223
+ expect(document.activeElement).toBe(tabs[1])
224
+ expect(document.querySelector('[role="tabpanel"]')?.getAttribute('aria-labelledby')).toBe(tabs[1].id)
225
+ await act(async () => tabs[1].dispatchEvent(new KeyboardEvent('keydown', { key: 'Home', bubbles: true })))
226
+ expect(tabs[0].getAttribute('aria-selected')).toBe('true')
227
+ expect(document.activeElement).toBe(tabs[0])
228
+ })
229
+
230
+ it('keeps explicit source selection and revision expectations without associating the release', async () => {
231
+ const current = { type: 'repository' as const, reference: 'current', url: recordedURL }
232
+ const other = { type: 'repository' as const, reference: 'other', url: 'https://other.example.test' }
233
+ state.status = { recorded: current, configured: true, available: true, confirmed: true, revision: 4, suggestions: [
234
+ { source: current, current: true, hasInstalledVersion: true, state: 'available' },
235
+ { source: other, current: false, hasInstalledVersion: false, state: 'available' },
236
+ ] }
237
+ const select = vi.fn()
238
+ await renderDialog(select)
239
+ await act(async () => document.querySelector<HTMLButtonElement>(`button[aria-label="Choose configured source: ${other.url}"]`)?.click())
240
+ await click('Select for upgrade')
241
+ expect(select).toHaveBeenCalledWith({ source: other, expectedRevision: 4, expectedSource: current })
242
+ expect(state.associateSource).not.toHaveBeenCalled()
243
+ })
94
244
 
95
- await act(async () => addRecordedButton()?.click())
96
- expect(state.addRepository).toHaveBeenCalledWith(
97
- { name: 'podinfo-3', url: recordedURL, namespace: 'web', releaseName: 'storefront' },
98
- expect.anything(),
99
- )
245
+ it('preserves installed-version verification as a separate selected-source action', async () => {
246
+ const source = { type: 'repository' as const, reference: 'podinfo', url: recordedURL }
247
+ state.status = { configured: false, available: false, confirmed: false, revision: 1, candidates: [source] }
248
+ await renderDialog(vi.fn())
249
+ await chooseRecorded()
250
+ await click('Check and record source')
251
+ expect(state.associateSource).toHaveBeenCalledWith(source, expect.anything())
100
252
  })
101
253
 
102
- it('is disabled for a non-owner, who is told who can add sources', async () => {
254
+ it('allows original-source verification for unchecked OCI and blocks it after a failed source change', async () => {
255
+ const source = { type: 'oci' as const, reference: 'oci://registry.example.test/team/podinfo' }
256
+ state.status = { configured: false, available: false, confirmed: false, revision: 1, suggestions: [{ source, current: false, hasInstalledVersion: false, state: 'unchecked' }] }
257
+ await renderDialog(vi.fn())
258
+ await act(async () => document.querySelector<HTMLButtonElement>('button[aria-label^="Choose configured source:"]')?.click())
259
+ await click('Check and record source')
260
+ expect(state.associateSource).toHaveBeenCalledWith(source, expect.anything())
261
+ state.status = { ...state.status, sourceChangeRequired: true }
262
+ await renderDialog(vi.fn())
263
+ expect(document.body.textContent).not.toContain('Check and record source')
264
+ })
265
+
266
+ it('disables release actions while source status is refreshing', async () => {
267
+ state.status = { ...movedMachine, configured: true, revision: 1 }
268
+ state.statusFetching = true
269
+ await renderDialog(vi.fn())
270
+ await chooseRecorded()
271
+ expect(button('Select for upgrade').disabled).toBe(true)
272
+ })
273
+
274
+ it('does not expose public discovery or source switching on an unsupported backend', async () => {
275
+ state.featureSupported = false
276
+ await renderDialog(vi.fn())
277
+ expect(document.body.textContent).not.toContain('ArtifactHub')
278
+ expect(document.body.textContent).not.toContain('Select for upgrade')
279
+ })
280
+
281
+ it('resets a selected source and the active view when the release changes', async () => {
282
+ await renderDialog(vi.fn())
283
+ await chooseRecorded()
284
+ await click('Add manually')
285
+ await act(async () => root.render(<TrackChartSourceDialog open onClose={() => undefined} chartName="podinfo" namespace="web" releaseName="another-release" onSelectUpgradeSource={vi.fn()} />))
286
+ expect(document.querySelector('form')).toBeNull()
287
+ expect(document.querySelector('[aria-pressed="true"]')).toBeNull()
288
+ })
289
+
290
+ it('filters a long configured list without hiding an off-page selection in the action footer', async () => {
291
+ state.status = { configured: false, available: false, revision: 1, suggestions: Array.from({ length: 60 }, (_, i) => ({ source: { type: 'repository' as const, reference: `repo-${i}`, url: `https://repo-${i}.example.test` }, current: false, hasInstalledVersion: true, state: 'available' })) }
292
+ await renderDialog(vi.fn())
293
+ const filter = document.querySelector<HTMLInputElement>('input[aria-label="Filter configured sources"]')
294
+ expect(filter).not.toBeNull()
295
+ expect(document.querySelector('[aria-label="Configured chart sources"]')?.className).toContain('overflow-y-auto')
296
+ await act(async () => document.querySelector<HTMLButtonElement>('button[aria-label^="Choose configured source:"]')?.click())
297
+ expect(button('Select for upgrade').disabled).toBe(false)
298
+ if (!filter) throw new Error('Missing configured-source filter')
299
+ await fill(filter, 'repo-59.')
300
+ expect(document.querySelectorAll('button[aria-label^="Choose configured source:"]')).toHaveLength(1)
301
+ expect(button('Select for upgrade').disabled).toBe(true)
302
+ })
303
+ })
304
+
305
+ describe('public discovery keeps the existing configuration contract', () => {
306
+ const chart: ArtifactHubChart = { packageId: 'podinfo', name: 'podinfo', version: '6.15.0', stars: 0, repository: { name: 'podinfo', url: recordedURL } }
307
+
308
+ it('adds only the selected HTTP result without binding or selecting an upgrade', async () => {
309
+ state.searchCharts = [chart]
310
+ state.repositories = [{ name: 'podinfo', url: 'https://other.example.test' }]
311
+ const select = vi.fn()
312
+ await renderDialog(select)
313
+ await searchPublic()
314
+ expect(button('Add repository').disabled).toBe(true)
315
+ await choosePublic(recordedURL)
316
+ await click('Add repository')
317
+ expect(state.addRepository).toHaveBeenCalledWith({ name: 'podinfo-2', url: recordedURL }, expect.anything())
318
+ expect(state.associateSource).not.toHaveBeenCalled()
319
+ expect(select).not.toHaveBeenCalled()
320
+ })
321
+
322
+ it('registers the OCI parent rather than duplicating the chart name', async () => {
323
+ const url = 'oci://ghcr.io/stefanprodan/charts/podinfo'
324
+ state.searchCharts = [{ ...chart, repository: { name: 'podinfo', url } }]
325
+ await renderDialog()
326
+ await searchPublic()
327
+ await choosePublic(url)
328
+ await click('Register OCI source')
329
+ expect(state.addOCI).toHaveBeenCalledWith('oci://ghcr.io/stefanprodan/charts', expect.anything())
330
+ expect(state.associateSource).not.toHaveBeenCalled()
331
+ })
332
+
333
+ it('sends an already configured result back to its existing source instead of adding it again', async () => {
334
+ state.searchCharts = [chart]
335
+ state.repositories = [{ name: 'existing', url: `${recordedURL}/` }]
336
+ await renderDialog()
337
+ await searchPublic()
338
+ await choosePublic(recordedURL)
339
+ await click('Show in My Repos')
340
+ expect(document.querySelector('[role="tab"][aria-selected="true"]')?.textContent).toBe('My Repos')
341
+ expect(state.addRepository).not.toHaveBeenCalled()
342
+ })
343
+
344
+ it('does not let non-owners add a discovered source', async () => {
345
+ state.searchCharts = [chart]
103
346
  state.isOwner = false
104
347
  await renderDialog()
105
- expect(addRecordedButton()?.disabled).toBe(true)
106
- expect(document.body.textContent).toContain('Only organization owners can add or remove chart sources.')
107
- })
108
-
109
- it('is not offered when the recorded source is configured, OCI, or not recorded', async () => {
110
- for (const status of [
111
- { ...movedMachine, configured: true },
112
- { recorded: { type: 'oci' as const, reference: 'oci://ghcr.io/example/charts' }, configured: false, available: false },
113
- { configured: false, available: false },
114
- ]) {
115
- state.status = status
116
- await renderDialog()
117
- expect(addRecordedButton()).toBeUndefined()
118
- }
348
+ await searchPublic()
349
+ await choosePublic(recordedURL)
350
+ expect(button('Add repository').disabled).toBe(true)
351
+ })
352
+
353
+ it('recognizes equivalent OCI hosts while keeping repository path case significant', async () => {
354
+ const url = 'oci://registry.example.test/Team/podinfo'
355
+ state.searchCharts = [{ ...chart, repository: { name: 'podinfo', url } }]
356
+ state.ociSources = ['oci://REGISTRY.example.test/Team/']
357
+ await renderDialog()
358
+ await searchPublic()
359
+ await choosePublic(url)
360
+ expect(button('Show in My Repos')).toBeDefined()
361
+ state.ociSources = ['oci://registry.example.test/team']
362
+ await renderDialog()
363
+ expect(button('Register OCI source')).toBeDefined()
119
364
  })
120
365
  })
@@ -5,7 +5,7 @@ describe('chart source recovery presentation', () => {
5
5
  it('keeps recorded, configured, and available states distinct', () => {
6
6
  expect(sourceStateLabel(false, false, false)).toBe('Not recorded')
7
7
  expect(sourceStateLabel(true, false, false)).toBe('Recorded · not configured here')
8
- expect(sourceStateLabel(true, true, false)).toBe('Recorded and configured · unavailable or version missing')
8
+ expect(sourceStateLabel(true, true, false)).toBe('Recorded and configured · source unavailable')
9
9
  expect(sourceStateLabel(true, true, true)).toBe('Recorded · configured · available')
10
10
  })
11
11
 
@@ -17,7 +17,8 @@ describe('chart source recovery presentation', () => {
17
17
  })
18
18
 
19
19
  it('makes ambiguity explicit rather than selecting a source', () => {
20
- expect(getSourceIssueCopy('ambiguous_source')?.body).toContain('will not guess')
20
+ expect(getSourceIssueCopy('ambiguous_source')?.title).toBe('Chart source unresolved')
21
+ expect(getSourceIssueCopy('ambiguous_source')?.body).toContain('choose a source for the next upgrade')
21
22
  })
22
23
 
23
24
  it('accepts only HTTP repository URLs', () => {