@skyhook-io/radar-app 1.19.0 → 1.20.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.
- package/README.md +1 -1
- package/package.json +5 -5
- package/src/App.tsx +37 -9
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +353 -64
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +42 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/AIMarkdown.tsx +3 -0
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
- package/src/components/diagnose/DiagnoseContext.tsx +68 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +26 -0
- package/src/components/diagnose/Home.tsx +20 -1
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
- package/src/components/diagnose/InvestigationView.tsx +94 -26
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.tsx +8 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.test.tsx +50 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/helm/HelmDrawerFrame.tsx +101 -0
- package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
- package/src/components/helm/HelmView.tsx +213 -71
- package/src/components/helm/ObservedHelmNotice.tsx +146 -0
- package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
- package/src/components/helm/OwnedResources.tsx +4 -2
- package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
- package/src/components/home/ClusterHealthCard.tsx +28 -5
- package/src/components/home/HelmSummary.tsx +23 -4
- package/src/components/home/HelmSummary.unread.test.ts +16 -0
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +20 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- package/src/components/home/MCPSetupDialog.test.tsx +126 -10
- package/src/components/home/MCPSetupDialog.tsx +33 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +67 -14
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +22 -1
- package/src/components/issues/uncheckedSources.ts +21 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
- package/src/components/whats-new/releaseNotes.ts +77 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +8 -4
- package/src/hooks/useElementSize.ts +30 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +17 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ This package is source-only — it ships TypeScript + TSX files under `src/`. Co
|
|
|
10
10
|
npm install @skyhook-io/radar-app
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Peer deps: `react >=19`, `react-dom >=19`, `react-router-dom >=7`, `@tanstack/react-query >=5`, `@skyhook-io/k8s-ui >=1.
|
|
13
|
+
Peer deps: `react >=19`, `react-dom >=19`, `react-router-dom >=7`, `@tanstack/react-query >=5`, `@skyhook-io/k8s-ui >=1.18.2`, plus `clsx`, `tailwind-merge`, `lucide-react`, `@xyflow/react`, `elkjs`.
|
|
14
14
|
|
|
15
15
|
## Use
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyhook-io/radar-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.1",
|
|
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",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"yaml": "^2.9.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@skyhook-io/k8s-ui": ">=1.
|
|
45
|
+
"@skyhook-io/k8s-ui": ">=1.19.1",
|
|
46
46
|
"@tanstack/react-query": ">=5",
|
|
47
47
|
"@xyflow/react": ">=12.0.0",
|
|
48
48
|
"clsx": ">=2",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@eslint/js": "^10.0.1",
|
|
58
|
-
"@playwright/test": "^1.
|
|
58
|
+
"@playwright/test": "^1.64.1",
|
|
59
59
|
"@skyhook-io/k8s-ui": "*",
|
|
60
60
|
"@tailwindcss/vite": "^4.3.3",
|
|
61
|
-
"@tanstack/react-query": "^5.
|
|
62
|
-
"@types/node": "^26.6.
|
|
61
|
+
"@tanstack/react-query": "^5.105.0",
|
|
62
|
+
"@types/node": "^26.6.6",
|
|
63
63
|
"@types/react": "^19.3.0",
|
|
64
64
|
"@types/react-dom": "^19.3.0",
|
|
65
65
|
"@vitejs/plugin-react": "^6.1.2",
|
package/src/App.tsx
CHANGED
|
@@ -46,7 +46,7 @@ import { useNavRailPinned } from './hooks/useNavRailPinned'
|
|
|
46
46
|
import { useMediaQuery } from './hooks/useMediaQuery'
|
|
47
47
|
import { ContextSwitchProvider, useContextSwitch } from './context/ContextSwitchContext'
|
|
48
48
|
import { ConnectionProvider, useConnection, refreshQueriesAfterReconnect } from './context/ConnectionContext'
|
|
49
|
-
import {
|
|
49
|
+
import { DisconnectedView, FailedSwitchView } from './components/SwitchAwareConnectionError'
|
|
50
50
|
import { SyncProgressPanel } from './components/SyncProgressPanel'
|
|
51
51
|
import { NoClusterAccessBanner } from './components/NoClusterAccessBanner'
|
|
52
52
|
import { CapabilitiesProvider, useCapabilitiesContext } from './contexts/CapabilitiesContext'
|
|
@@ -89,7 +89,7 @@ import type { ContextSwitcherHandle } from './components/ContextSwitcher'
|
|
|
89
89
|
const ALL_NODE_KINDS: NodeKind[] = [
|
|
90
90
|
'Internet', 'Ingress', 'Gateway', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute', 'UDPRoute',
|
|
91
91
|
'Service', 'Deployment', 'Rollout', 'DaemonSet', 'StatefulSet',
|
|
92
|
-
'ReplicaSet', 'Pod', 'PodGroup', 'ConfigMap', 'Secret', 'ServiceAccount', 'SealedSecret', 'ServiceMonitor', 'PodMonitor', 'HorizontalPodAutoscaler', 'Job', 'CronJob', 'PersistentVolumeClaim', 'Namespace',
|
|
92
|
+
'ReplicaSet', 'Pod', 'PodGroup', 'ConfigMap', 'Secret', 'ServiceAccount', 'SealedSecret', 'ServiceMonitor', 'PodMonitor', 'HorizontalPodAutoscaler', 'Job', 'CronJob', 'JobSet', 'PersistentVolumeClaim', 'Namespace',
|
|
93
93
|
'Application', 'Kustomization', 'HelmRelease', 'GitRepository',
|
|
94
94
|
'KnativeService', 'KnativeConfiguration', 'KnativeRevision', 'KnativeRoute',
|
|
95
95
|
'Broker', 'Trigger', 'PingSource', 'ApiServerSource', 'ContainerSource', 'SinkBinding', 'Channel',
|
|
@@ -821,7 +821,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
821
821
|
navigate({ pathname: `/resources/${pluralKind}`, search: newParams.toString() })
|
|
822
822
|
}, [searchParams, navigate])
|
|
823
823
|
|
|
824
|
-
const navigateToHelmRelease = useCallback((namespace: string, name: string, storageNamespace?: string, investigationRunID?: string | null) => {
|
|
824
|
+
const navigateToHelmRelease = useCallback((namespace: string, name: string, storageNamespace?: string, investigationRunID?: string | null, observed?: boolean) => {
|
|
825
825
|
const newParams = new URLSearchParams()
|
|
826
826
|
const globalNamespaces = searchParams.get('namespaces')
|
|
827
827
|
if (globalNamespaces) {
|
|
@@ -832,7 +832,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
832
832
|
newParams.set('releaseStorage', storageNamespace)
|
|
833
833
|
}
|
|
834
834
|
if (investigationRunID) newParams.set('ai-run', investigationRunID)
|
|
835
|
-
setSelectedHelmRelease({ namespace, name, storageNamespace })
|
|
835
|
+
setSelectedHelmRelease({ namespace, name, storageNamespace, observed })
|
|
836
836
|
if (mainView === 'helm') {
|
|
837
837
|
setSearchParams(newParams, { replace: true })
|
|
838
838
|
return
|
|
@@ -1042,7 +1042,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
1042
1042
|
const { data: namespaceScope } = useNamespaceScope()
|
|
1043
1043
|
|
|
1044
1044
|
// Context switch state
|
|
1045
|
-
const { isSwitching, targetContext, progressMessage, updateProgress, endSwitch, takeOpenAfterSwitch } = useContextSwitch()
|
|
1045
|
+
const { isSwitching, failedSwitch, setFailedSwitch, targetContext, progressMessage, updateProgress, endSwitch, takeOpenAfterSwitch } = useContextSwitch()
|
|
1046
1046
|
|
|
1047
1047
|
// Connection state (for graceful startup)
|
|
1048
1048
|
const { connection, retry: retryConnection, isRetrying, updateFromSSE: updateConnectionFromSSE } = useConnection()
|
|
@@ -1055,7 +1055,26 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
1055
1055
|
// empty drawer over a not-yet-loaded view. Gating both on the SAME readiness so
|
|
1056
1056
|
// a drawer only ever sits over a real content surface.
|
|
1057
1057
|
const contentReady = !isSwitching && !authMePending &&
|
|
1058
|
-
!(authMe?.authEnabled && !authMe?.username) && connection.state === 'connected'
|
|
1058
|
+
!(authMe?.authEnabled && !authMe?.username) && connection.state === 'connected' && !failedSwitch
|
|
1059
|
+
|
|
1060
|
+
// The last context that was connected, so a screen about a cluster that
|
|
1061
|
+
// won't connect can offer a way back to it.
|
|
1062
|
+
const [lastConnectedContext, setLastConnectedContext] = useState<string | null>(null)
|
|
1063
|
+
useEffect(() => {
|
|
1064
|
+
if (connection.state === 'connected' && connection.context) setLastConnectedContext(connection.context)
|
|
1065
|
+
}, [connection.state, connection.context])
|
|
1066
|
+
// A refused switch is about the cluster that was still connected. Once that
|
|
1067
|
+
// connection changes in any way (dropped, reconnecting, or switched from
|
|
1068
|
+
// another tab), the screen is stale.
|
|
1069
|
+
const failedSwitchFrom = useRef<string | undefined>(undefined)
|
|
1070
|
+
useEffect(() => {
|
|
1071
|
+
if (!failedSwitch) {
|
|
1072
|
+
failedSwitchFrom.current = undefined
|
|
1073
|
+
return
|
|
1074
|
+
}
|
|
1075
|
+
failedSwitchFrom.current ??= connection.context
|
|
1076
|
+
if (connection.state !== 'connected' || connection.context !== failedSwitchFrom.current) setFailedSwitch(null)
|
|
1077
|
+
}, [failedSwitch, connection.state, connection.context, setFailedSwitch])
|
|
1059
1078
|
|
|
1060
1079
|
// Progressive shell during the initial informer sync: once the server
|
|
1061
1080
|
// publishes per-kind sync progress, render the app instead of the splash.
|
|
@@ -1623,7 +1642,9 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
1623
1642
|
if (slashIdx > 0) {
|
|
1624
1643
|
const ns = releaseParam.slice(0, slashIdx)
|
|
1625
1644
|
const name = releaseParam.slice(slashIdx + 1)
|
|
1626
|
-
|
|
1645
|
+
const storageNamespace = searchParams.get('releaseStorage') || undefined
|
|
1646
|
+
// Keep what a row click knows about the release; the URL doesn't carry it.
|
|
1647
|
+
setSelectedHelmRelease(prev => (prev?.namespace === ns && prev.name === name && prev.storageNamespace === storageNamespace ? prev : { namespace: ns, name, storageNamespace }))
|
|
1627
1648
|
}
|
|
1628
1649
|
}
|
|
1629
1650
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- run only when searchParams change; namespacesKey/namespaceScope are read for that transition
|
|
@@ -2009,13 +2030,20 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
2009
2030
|
|
|
2010
2031
|
{/* Connection error view - show when disconnected */}
|
|
2011
2032
|
{!isSwitching && !(authMe?.authEnabled && !authMe?.username) && connection.state === 'disconnected' && (
|
|
2012
|
-
<
|
|
2033
|
+
<DisconnectedView
|
|
2013
2034
|
connection={connection}
|
|
2014
2035
|
onRetry={retryConnection}
|
|
2015
2036
|
isRetrying={isRetrying}
|
|
2037
|
+
lastConnectedContext={lastConnectedContext}
|
|
2016
2038
|
/>
|
|
2017
2039
|
)}
|
|
2018
2040
|
|
|
2041
|
+
{/* A switch refused before leaving the current cluster: the error screen
|
|
2042
|
+
for the cluster that didn't answer, over the still-connected app. */}
|
|
2043
|
+
{!isSwitching && !(authMe?.authEnabled && !authMe?.username) && connection.state === 'connected' && failedSwitch && (
|
|
2044
|
+
<FailedSwitchView currentContext={connection.context} />
|
|
2045
|
+
)}
|
|
2046
|
+
|
|
2019
2047
|
{/* Connecting view — shown during initial connection or retry.
|
|
2020
2048
|
Icon is pane-anchored so its screen position matches the
|
|
2021
2049
|
host hub splash across cross-document transitions. */}
|
|
@@ -2323,7 +2351,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
2323
2351
|
<HelmView
|
|
2324
2352
|
namespaces={namespaces}
|
|
2325
2353
|
selectedRelease={selectedHelmRelease}
|
|
2326
|
-
onReleaseClick={navigateToHelmRelease}
|
|
2354
|
+
onReleaseClick={(namespace, name, storageNamespace, observed) => navigateToHelmRelease(namespace, name, storageNamespace, undefined, observed)}
|
|
2327
2355
|
/>
|
|
2328
2356
|
)}
|
|
2329
2357
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { fetchJSON } from './client'
|
|
2
|
+
|
|
3
|
+
export type EvidenceApplication = 'rabbitmq' | 'nats' | 'vault'
|
|
4
|
+
export interface EvidenceTarget { namespace: string; pod: string; uid?: string; container?: string }
|
|
5
|
+
export interface EvidenceCandidate {
|
|
6
|
+
application: EvidenceApplication
|
|
7
|
+
target: EvidenceTarget & { uid: string; container: string }
|
|
8
|
+
expectedEvidence: string[]
|
|
9
|
+
coverage: string
|
|
10
|
+
}
|
|
11
|
+
export interface EvidenceCandidates {
|
|
12
|
+
permissionCheckTimedOut?: boolean
|
|
13
|
+
permissionCheckFailed?: boolean
|
|
14
|
+
enabled: boolean
|
|
15
|
+
context?: string
|
|
16
|
+
subjectUID?: string
|
|
17
|
+
candidates: EvidenceCandidate[]
|
|
18
|
+
truncated?: boolean
|
|
19
|
+
coverageLimited?: boolean
|
|
20
|
+
}
|
|
21
|
+
export interface NATSSequence {
|
|
22
|
+
/** Decimal uint64 identifiers, preserved without JavaScript number rounding. */
|
|
23
|
+
consumerSequence?: string
|
|
24
|
+
streamSequence?: string
|
|
25
|
+
lastActive?: string
|
|
26
|
+
}
|
|
27
|
+
export interface ApplicationEvidenceResult {
|
|
28
|
+
adapter: EvidenceApplication
|
|
29
|
+
target: EvidenceTarget
|
|
30
|
+
observedAt: string
|
|
31
|
+
source: string
|
|
32
|
+
outcome: 'observed' | 'unavailable'
|
|
33
|
+
reason?: string
|
|
34
|
+
httpStatus?: number
|
|
35
|
+
facts?: {
|
|
36
|
+
rabbitmq?: {
|
|
37
|
+
diskAlarm: boolean
|
|
38
|
+
memoryAlarm: boolean
|
|
39
|
+
diskAvailableBytes?: number
|
|
40
|
+
diskWatermarkBytes?: number
|
|
41
|
+
memoryUsedBytes?: number
|
|
42
|
+
memoryWatermarkBytes?: number
|
|
43
|
+
}
|
|
44
|
+
vault?: { initialized: boolean; sealed: boolean; standby: boolean; performanceStandby?: boolean; haConnectionHealthy?: boolean; removedFromCluster?: boolean }
|
|
45
|
+
nats?: {
|
|
46
|
+
jetStreamEnabled: boolean
|
|
47
|
+
totals?: { accounts: number; streams: number; consumers: number; messages: number }
|
|
48
|
+
consumers: { account: string; stream: string; name: string; pending: number; ackPending: number; redelivered: number; delivered?: NATSSequence; ackFloor?: NATSSequence; waitingPullRequests?: number }[]
|
|
49
|
+
coverage: string
|
|
50
|
+
returnedAccounts: number
|
|
51
|
+
returnedStreams: number
|
|
52
|
+
returnedConsumers: number
|
|
53
|
+
truncated: boolean
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
limitations: string[]
|
|
57
|
+
}
|
|
58
|
+
export function collectApplicationEvidence(candidate: EvidenceCandidate, context: string, signal: AbortSignal) {
|
|
59
|
+
return fetchJSON<ApplicationEvidenceResult>('/application-evidence/collect', {
|
|
60
|
+
method: 'POST', signal, headers: { 'Content-Type': 'application/json' },
|
|
61
|
+
body: JSON.stringify({ application: candidate.application, namespace: candidate.target.namespace, pod: candidate.target.pod, uid: candidate.target.uid, context, confirmNetworkAccess: true }),
|
|
62
|
+
})
|
|
63
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { argoSyncRequestBody } from './client'
|
|
3
|
+
|
|
4
|
+
// A one-click sync (the drawer's Sync button, the create-namespace retry)
|
|
5
|
+
// names no prune and no options; neither may change meaning on an older Radar.
|
|
6
|
+
describe('argoSyncRequestBody for a sync that names no options', () => {
|
|
7
|
+
const vars = { namespace: 'argocd', name: 'guestbook', applicationSyncOptions: ['CreateNamespace=true'] }
|
|
8
|
+
|
|
9
|
+
it('sends prune false and lets a current Radar use the Application options', () => {
|
|
10
|
+
const body = argoSyncRequestBody(vars, true)
|
|
11
|
+
expect(body.prune).toBe(false)
|
|
12
|
+
expect(body.syncOptions).toBeUndefined()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it("sends prune false and the Application's options to an older Radar", () => {
|
|
16
|
+
expect(argoSyncRequestBody(vars, false)).toMatchObject({ prune: false, syncOptions: ['CreateNamespace=true'] })
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('keeps an explicit prune', () => {
|
|
20
|
+
expect(argoSyncRequestBody({ ...vars, prune: true }, false).prune).toBe(true)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import { ClusterConnectedContext } from '../context/clusterConnected'
|
|
7
|
+
import { useAudit } from './client'
|
|
8
|
+
|
|
9
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
10
|
+
|
|
11
|
+
function AuditProbe() {
|
|
12
|
+
useAudit([])
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
vi.unstubAllGlobals()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
async function renderWith(connected: boolean) {
|
|
21
|
+
const fetchMock = vi.fn<(input: RequestInfo | URL) => Promise<Response>>(async () => new Response('{}', { status: 200, headers: { 'Content-Type': 'application/json' } }))
|
|
22
|
+
vi.stubGlobal('fetch', fetchMock)
|
|
23
|
+
const container = document.createElement('div')
|
|
24
|
+
const root = createRoot(container)
|
|
25
|
+
await act(async () => {
|
|
26
|
+
root.render(
|
|
27
|
+
<QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>
|
|
28
|
+
<ClusterConnectedContext.Provider value={connected}>
|
|
29
|
+
<AuditProbe />
|
|
30
|
+
</ClusterConnectedContext.Provider>
|
|
31
|
+
</QueryClientProvider>,
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
await act(async () => { await Promise.resolve() })
|
|
35
|
+
const auditCalls = fetchMock.mock.calls.filter(([input]) => String(input).includes('/audit')).length
|
|
36
|
+
act(() => root.unmount())
|
|
37
|
+
return auditCalls
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('useAudit', () => {
|
|
41
|
+
it('does not ask a disconnected cluster for checks', async () => {
|
|
42
|
+
expect(await renderWith(false)).toBe(0)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('fetches checks while connected', async () => {
|
|
46
|
+
expect(await renderWith(true)).toBe(1)
|
|
47
|
+
})
|
|
48
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { ApiError, kueuePositionRefetchInterval } from './client'
|
|
3
|
+
import { RadarFeatureUnsupportedError } from './radarFeatures'
|
|
4
|
+
|
|
5
|
+
const answer = (position?: Record<string, unknown>, eligible = true) => ({ data: { uid: 'u', eligible, position: position as never } })
|
|
6
|
+
|
|
7
|
+
describe('kueuePositionRefetchInterval', () => {
|
|
8
|
+
it('polls answers that change by themselves', () => {
|
|
9
|
+
for (const status of ['listed', 'not_listed', 'limit_reached', 'queue_unknown']) {
|
|
10
|
+
expect(kueuePositionRefetchInterval(answer({ status }))).toBe(30000)
|
|
11
|
+
}
|
|
12
|
+
expect(kueuePositionRefetchInterval(answer({ status: 'unavailable', code: 'read_error' }))).toBe(30000)
|
|
13
|
+
expect(kueuePositionRefetchInterval(answer({ status: 'unavailable', code: 'user_permission_check_failed' }))).toBe(30000)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('stops on answers only a change of access or cluster resolves', () => {
|
|
17
|
+
for (const status of ['not_served', 'unsupported', 'no_local_queue']) {
|
|
18
|
+
expect(kueuePositionRefetchInterval(answer({ status }))).toBe(false)
|
|
19
|
+
}
|
|
20
|
+
for (const code of ['user_forbidden', 'radar_forbidden', 'radar_credentials_rejected']) {
|
|
21
|
+
expect(kueuePositionRefetchInterval(answer({ status: 'unavailable', code }))).toBe(false)
|
|
22
|
+
}
|
|
23
|
+
expect(kueuePositionRefetchInterval(answer(undefined, false))).toBe(30000)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('stops on client errors and an older Radar, keeps polling through transient failures', () => {
|
|
27
|
+
expect(kueuePositionRefetchInterval({ error: new ApiError('forbidden', 403) })).toBe(false)
|
|
28
|
+
expect(kueuePositionRefetchInterval({ error: new RadarFeatureUnsupportedError('kueuePendingPosition', {}) })).toBe(false)
|
|
29
|
+
expect(kueuePositionRefetchInterval({ error: new ApiError('unavailable', 503) })).toBe(30000)
|
|
30
|
+
expect(kueuePositionRefetchInterval({ ...answer({ status: 'listed' }), error: new ApiError('unavailable', 503) })).toBe(30000)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
6
|
+
import { useKueueQueueWorkloads } from './client'
|
|
7
|
+
import { setApiBase } from './config'
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
setApiBase('/api')
|
|
11
|
+
vi.unstubAllGlobals()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const json = (body: unknown) => new Response(JSON.stringify(body), { status: 200, headers: { 'Content-Type': 'application/json' } })
|
|
15
|
+
const page = (names: string[], next?: string) => ({
|
|
16
|
+
queue: { kind: 'ClusterQueue', name: 'cq', uid: 'cq-uid' },
|
|
17
|
+
workloads: {
|
|
18
|
+
items: names.map(name => ({ namespace: 'team-a', name, uid: name, apiVersion: 'kueue.x-k8s.io/v1beta2', createdAt: null, deleting: false, membership: ['reservation'] })),
|
|
19
|
+
matching: 3, counts: { members: 3, submission: 0, reservation: 3, states: {} }, next,
|
|
20
|
+
coverage: { status: 'complete', scope: { type: 'all_namespaces' }, read: { type: 'all_namespaces' }, gaps: [] },
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it.each(['supported', 'older'] as const)('reads queue Workloads page by page only from a Radar that serves them: %s', async (radar) => {
|
|
25
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
26
|
+
setApiBase('/c/review/api')
|
|
27
|
+
const requests: string[] = []
|
|
28
|
+
vi.stubGlobal('fetch', vi.fn(async (input: string) => {
|
|
29
|
+
const url = new URL(input, 'http://localhost')
|
|
30
|
+
requests.push(url.pathname + url.search)
|
|
31
|
+
if (url.pathname.endsWith('/capabilities')) return json({ features: radar === 'supported' ? { kueueQueueWorkloads: true } : {} })
|
|
32
|
+
if (url.pathname.endsWith('/version')) return json({ currentVersion: 'v1.20.0' })
|
|
33
|
+
if (radar === 'older') return new Response('404 page not found\n', { status: 404, headers: { 'Content-Type': 'text/plain' } })
|
|
34
|
+
return json(url.searchParams.get('cursor') ? page(['c']) : page(['a', 'b'], 'next-1'))
|
|
35
|
+
}))
|
|
36
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
37
|
+
let result!: ReturnType<typeof useKueueQueueWorkloads>
|
|
38
|
+
function Probe() {
|
|
39
|
+
result = useKueueQueueWorkloads({ kind: 'ClusterQueue', name: 'cq', uid: 'cq-uid' }, { membership: 'reservation' })
|
|
40
|
+
return null
|
|
41
|
+
}
|
|
42
|
+
const host = document.createElement('div')
|
|
43
|
+
const root = createRoot(host)
|
|
44
|
+
const endpoint = (path: string) => path.startsWith('/c/review/api/kueue/')
|
|
45
|
+
try {
|
|
46
|
+
await act(async () => { root.render(<QueryClientProvider client={client}><Probe /></QueryClientProvider>) })
|
|
47
|
+
if (radar === 'older') {
|
|
48
|
+
// Before capabilities answer, one probe may reach the older Radar; once
|
|
49
|
+
// they do, it is never asked again and the upgrade note replaces the list.
|
|
50
|
+
await vi.waitFor(() => expect(result.upgrade).not.toBeNull())
|
|
51
|
+
const asked = requests.filter(endpoint).length
|
|
52
|
+
expect(asked).toBeLessThanOrEqual(1)
|
|
53
|
+
await act(async () => { await result.refetch() })
|
|
54
|
+
expect(requests.filter(endpoint).length).toBe(asked)
|
|
55
|
+
expect(result.data).toBeUndefined()
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
await vi.waitFor(() => expect(result.data?.pages).toHaveLength(1))
|
|
59
|
+
expect(result.hasNextPage).toBe(true)
|
|
60
|
+
await act(async () => { await result.fetchNextPage() })
|
|
61
|
+
await vi.waitFor(() => expect(result.data?.pages).toHaveLength(2))
|
|
62
|
+
expect(result.hasNextPage).toBe(false)
|
|
63
|
+
expect(requests.filter(endpoint)).toEqual([
|
|
64
|
+
'/c/review/api/kueue/clusterqueues/cq/workloads?membership=reservation',
|
|
65
|
+
'/c/review/api/kueue/clusterqueues/cq/workloads?membership=reservation&cursor=next-1',
|
|
66
|
+
])
|
|
67
|
+
} finally {
|
|
68
|
+
act(() => root.unmount())
|
|
69
|
+
client.clear()
|
|
70
|
+
}
|
|
71
|
+
})
|
|
@@ -2,6 +2,9 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
2
2
|
import { useQuery } from '@tanstack/react-query'
|
|
3
3
|
import { useResourceAudit, useResourceEvents } from './client'
|
|
4
4
|
|
|
5
|
+
// These tests call the hooks outside React; the connected signal is a context read.
|
|
6
|
+
vi.mock('../context/clusterConnected', () => ({ useClusterConnected: () => true }))
|
|
7
|
+
|
|
5
8
|
vi.mock('@tanstack/react-query', async (original) => ({
|
|
6
9
|
...await original<typeof import('@tanstack/react-query')>(),
|
|
7
10
|
useQuery: vi.fn(() => ({})),
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { focusManager, QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
6
|
+
import { useResourceIssues } from './client'
|
|
7
|
+
import { setApiBase } from './config'
|
|
8
|
+
|
|
9
|
+
interface Props { instance?: number; namespace?: string; observation?: string; enabled?: boolean; name?: string }
|
|
10
|
+
function Probe({ observation, enabled = true, name = 'collector', namespace = 'test' }: Props) {
|
|
11
|
+
const query = useResourceIssues('opentelemetrycollectors', 'opentelemetry.io', namespace, name, enabled, observation)
|
|
12
|
+
return <span>{query.data?.length ?? 'pending'}</span>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const clients: QueryClient[] = []
|
|
16
|
+
const roots: ReturnType<typeof createRoot>[] = []
|
|
17
|
+
const hosts: HTMLElement[] = []
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.useFakeTimers()
|
|
21
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
22
|
+
focusManager.setFocused(true)
|
|
23
|
+
setApiBase('/api')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
roots.splice(0).forEach(root => act(() => root.unmount()))
|
|
28
|
+
clients.splice(0).forEach(client => client.clear())
|
|
29
|
+
hosts.splice(0).forEach(host => host.remove())
|
|
30
|
+
focusManager.setFocused(undefined)
|
|
31
|
+
setApiBase('/api')
|
|
32
|
+
vi.unstubAllGlobals()
|
|
33
|
+
vi.useRealTimers()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
async function setup(props: Props = {}, supported: boolean | 'unknown' = true) {
|
|
37
|
+
let endpointSupported = supported === true
|
|
38
|
+
let count = 1
|
|
39
|
+
let heldReply: Promise<Response> | undefined
|
|
40
|
+
const requests: string[] = []
|
|
41
|
+
vi.stubGlobal('fetch', vi.fn(async (input: string) => {
|
|
42
|
+
const path = new URL(input, 'http://localhost').pathname
|
|
43
|
+
requests.push(path)
|
|
44
|
+
if (path.includes('/issues/resource/') && !endpointSupported) return new Response('404 page not found\n', { status: 404, headers: { 'Content-Type': 'text/plain; charset=utf-8' } })
|
|
45
|
+
if (path.includes('/issues/resource/') && heldReply) {
|
|
46
|
+
const reply = heldReply
|
|
47
|
+
heldReply = undefined
|
|
48
|
+
return reply
|
|
49
|
+
}
|
|
50
|
+
const body = path.endsWith('/capabilities')
|
|
51
|
+
? supported === 'unknown' ? { version: 'dev', features: {} } : { version: supported ? 'v1.18.2' : 'v1.7.0', features: { resourceIssues: supported } }
|
|
52
|
+
: Array.from({ length: count }, (_, index) => ({ id: String(index), message: 'Recorded failure' }))
|
|
53
|
+
return new Response(JSON.stringify(body), { status: 200, headers: { 'Content-Type': 'application/json' } })
|
|
54
|
+
}))
|
|
55
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, refetchOnWindowFocus: false } } })
|
|
56
|
+
if (supported === false) client.setQueryData(['version-check', '/api'], { currentVersion: 'v1.7.0' })
|
|
57
|
+
clients.push(client)
|
|
58
|
+
const host = document.createElement('div')
|
|
59
|
+
document.body.append(host)
|
|
60
|
+
hosts.push(host)
|
|
61
|
+
const root = createRoot(host)
|
|
62
|
+
roots.push(root)
|
|
63
|
+
async function render(next: Props) {
|
|
64
|
+
await act(async () => { root.render(<QueryClientProvider client={client}><Probe key={next.instance} {...next} /></QueryClientProvider>) })
|
|
65
|
+
}
|
|
66
|
+
await render(props)
|
|
67
|
+
if (supported === true && props.enabled !== false) await vi.waitFor(() => expect(host.textContent).toBe('1'))
|
|
68
|
+
const issueRequests = () => requests.filter(path => path.includes('/issues/resource/'))
|
|
69
|
+
const advance = async (ms: number) => { await act(async () => { await vi.advanceTimersByTimeAsync(ms) }) }
|
|
70
|
+
const holdNextReply = () => {
|
|
71
|
+
let release!: () => void
|
|
72
|
+
const body = JSON.stringify(Array.from({ length: count }, (_, index) => ({ id: String(index) })))
|
|
73
|
+
heldReply = new Promise(resolve => { release = () => resolve(new Response(body, { status: 200, headers: { 'Content-Type': 'application/json' } })) })
|
|
74
|
+
return release
|
|
75
|
+
}
|
|
76
|
+
return { client, host, root, render, advance, setEndpointSupported: (value: boolean) => { endpointSupported = value }, issueRequests, requests, holdNextReply, setCount: (value: number) => { count = value } }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
it('clears an old Issue after a watched root changes without reopening', async () => {
|
|
80
|
+
const h = await setup({ observation: 'managed-rv' })
|
|
81
|
+
h.setCount(0)
|
|
82
|
+
await h.render({ observation: 'unmanaged-rv' })
|
|
83
|
+
await h.advance(10001)
|
|
84
|
+
expect(h.host.textContent).toBe('0')
|
|
85
|
+
expect(h.issueRequests()).toHaveLength(2)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('coalesces watch churn and keeps one cache entry for the resource', async () => {
|
|
89
|
+
const h = await setup({ observation: '0' })
|
|
90
|
+
for (let index = 1; index <= 20; index++) {
|
|
91
|
+
await h.render({ observation: String(index) })
|
|
92
|
+
await h.advance(200)
|
|
93
|
+
}
|
|
94
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
95
|
+
await h.advance(6001)
|
|
96
|
+
expect(h.issueRequests()).toHaveLength(2)
|
|
97
|
+
expect(h.client.getQueryCache().findAll({ queryKey: ['issues', 'resource'] })).toHaveLength(1)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('does not refresh when the observation is unchanged', async () => {
|
|
101
|
+
const observation = 'root-rv'
|
|
102
|
+
const h = await setup({ observation })
|
|
103
|
+
await h.render({ observation })
|
|
104
|
+
await h.advance(10001)
|
|
105
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('updates Pod-only and timer-driven findings even when the root does not change', async () => {
|
|
109
|
+
const h = await setup({ observation: 'same-rv' })
|
|
110
|
+
h.setCount(0)
|
|
111
|
+
await h.advance(60001)
|
|
112
|
+
expect(h.host.textContent).toBe('0')
|
|
113
|
+
expect(h.issueRequests()).toHaveLength(2)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('does not poll a hidden tab', async () => {
|
|
117
|
+
const h = await setup({ observation: 'same-rv' })
|
|
118
|
+
focusManager.setFocused(false)
|
|
119
|
+
await h.advance(120001)
|
|
120
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('refreshes a hidden observation when focus returns with the production focus default off', async () => {
|
|
124
|
+
const h = await setup({ observation: 'first' })
|
|
125
|
+
focusManager.setFocused(false)
|
|
126
|
+
h.setCount(0)
|
|
127
|
+
await h.render({ observation: 'changed' })
|
|
128
|
+
await h.advance(10001)
|
|
129
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
130
|
+
await act(async () => { focusManager.setFocused(true) })
|
|
131
|
+
await h.advance(1)
|
|
132
|
+
expect(h.host.textContent).toBe('0')
|
|
133
|
+
expect(h.issueRequests()).toHaveLength(2)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('does not duplicate the initial request when the root first arrives', async () => {
|
|
137
|
+
const h = await setup()
|
|
138
|
+
await h.render({ observation: 'first' })
|
|
139
|
+
await h.advance(10001)
|
|
140
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('does not refresh for a drawer transition with an unchanged root', async () => {
|
|
144
|
+
const h = await setup({ observation: 'first' })
|
|
145
|
+
await h.render({ observation: 'first', enabled: false })
|
|
146
|
+
await h.advance(300)
|
|
147
|
+
await h.render({ observation: 'first' })
|
|
148
|
+
await h.advance(10001)
|
|
149
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('does not let an older in-flight poll swallow a newer watched state', async () => {
|
|
153
|
+
const h = await setup({ observation: 'first' })
|
|
154
|
+
const release = h.holdNextReply()
|
|
155
|
+
await h.advance(60001)
|
|
156
|
+
expect(h.issueRequests()).toHaveLength(2)
|
|
157
|
+
h.setCount(0)
|
|
158
|
+
await h.render({ observation: 'changed' })
|
|
159
|
+
await h.advance(1)
|
|
160
|
+
expect(h.host.textContent).toBe('0')
|
|
161
|
+
await act(async () => { release() })
|
|
162
|
+
await h.advance(1)
|
|
163
|
+
expect(h.host.textContent).toBe('0')
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('stops pending refreshes for an inactive drawer and refreshes on reactivation', async () => {
|
|
167
|
+
const h = await setup({ observation: 'first' })
|
|
168
|
+
await h.render({ observation: 'changed' })
|
|
169
|
+
await h.render({ observation: 'changed', enabled: false })
|
|
170
|
+
await h.advance(60001)
|
|
171
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
172
|
+
h.setCount(0)
|
|
173
|
+
await h.render({ observation: 'changed', enabled: true })
|
|
174
|
+
await h.advance(10001)
|
|
175
|
+
expect(h.host.textContent).toBe('0')
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('cancels a pending refresh when the inspected resource changes', async () => {
|
|
179
|
+
const h = await setup({ observation: 'first' })
|
|
180
|
+
await h.render({ observation: 'changed' })
|
|
181
|
+
await h.render({ observation: 'other', name: 'other-collector' })
|
|
182
|
+
await h.advance(10001)
|
|
183
|
+
expect(h.issueRequests().filter(path => path.endsWith('/collector'))).toHaveLength(1)
|
|
184
|
+
expect(h.issueRequests().filter(path => path.endsWith('/other-collector'))).toHaveLength(1)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('does not poll or call an unsupported resource-Issues endpoint', async () => {
|
|
188
|
+
const h = await setup({ observation: 'first' }, false)
|
|
189
|
+
await h.advance(120001)
|
|
190
|
+
await h.render({ observation: 'changed' })
|
|
191
|
+
await h.advance(10001)
|
|
192
|
+
expect(h.issueRequests()).toHaveLength(0)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
// Cluster-scoped subjects require a cluster-wide Issues scan, so resource
|
|
196
|
+
// version churn must not turn them into automatic repeated scans.
|
|
197
|
+
it('does not automatically rescan cluster-scoped drawers', async () => {
|
|
198
|
+
const h = await setup({ namespace: '', observation: 'first' })
|
|
199
|
+
await h.render({ namespace: '', observation: 'changed' })
|
|
200
|
+
await h.advance(180001)
|
|
201
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('does not duplicate an in-flight reopen when a newer root arrives', async () => {
|
|
205
|
+
const h = await setup({ observation: 'first' })
|
|
206
|
+
await h.advance(31000)
|
|
207
|
+
const release = h.holdNextReply()
|
|
208
|
+
await h.render({ observation: 'first', instance: 1 })
|
|
209
|
+
const reopening = h.issueRequests().length
|
|
210
|
+
await h.render({ observation: 'changed', instance: 1 })
|
|
211
|
+
await h.advance(1000)
|
|
212
|
+
expect(h.issueRequests()).toHaveLength(reopening)
|
|
213
|
+
release()
|
|
214
|
+
await h.advance(10001)
|
|
215
|
+
expect(h.issueRequests()).toHaveLength(reopening + 1)
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
// An unknown-version host can initially probe an endpoint before capabilities settle.
|
|
219
|
+
it('does not retry an unknown-route error on focus or watch updates', async () => {
|
|
220
|
+
const h = await setup({ observation: 'first' }, 'unknown')
|
|
221
|
+
await h.advance(100)
|
|
222
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
223
|
+
focusManager.setFocused(false)
|
|
224
|
+
await act(async () => { focusManager.setFocused(true) })
|
|
225
|
+
await h.render({ observation: 'changed' })
|
|
226
|
+
await h.advance(120001)
|
|
227
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
it('recovers an open unsupported query when capabilities confirm support', async () => {
|
|
231
|
+
const h = await setup({ observation: 'first' }, 'unknown')
|
|
232
|
+
await h.advance(100)
|
|
233
|
+
expect(h.issueRequests()).toHaveLength(1)
|
|
234
|
+
h.setEndpointSupported(true)
|
|
235
|
+
await act(async () => { h.client.setQueryData(['capabilities'], { features: { resourceIssues: true } }) })
|
|
236
|
+
await h.advance(1)
|
|
237
|
+
expect(h.host.textContent).toBe('1')
|
|
238
|
+
expect(h.issueRequests()).toHaveLength(2)
|
|
239
|
+
})
|
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
useUpdateResource,
|
|
17
17
|
} from './client'
|
|
18
18
|
|
|
19
|
+
// These tests call the hooks outside React; the connected signal is a context read.
|
|
20
|
+
vi.mock('../context/clusterConnected', () => ({ useClusterConnected: () => true }))
|
|
21
|
+
|
|
19
22
|
vi.mock('@tanstack/react-query', async (original) => ({
|
|
20
23
|
...await original<typeof import('@tanstack/react-query')>(),
|
|
21
24
|
useQuery: vi.fn(() => ({})),
|