@skyhook-io/radar-app 1.22.1 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +131 -38
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/RadarApp.tsx +5 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +128 -25
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +1172 -0
- package/src/api/workloadSource.ts +408 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +9 -29
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +7 -7
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +119 -14
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -9,6 +9,11 @@ export function metricsSourceUnavailable(status: PrometheusStatus | null | undef
|
|
|
9
9
|
return status?.source?.kind === 'openobserve' && status.source.unavailable === true
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/** Radar is still checking whether OpenObserve has this cluster's metrics. */
|
|
13
|
+
export function metricsSourceChecking(status: PrometheusStatus | null | undefined): boolean {
|
|
14
|
+
return status?.source?.kind === 'openobserve' && status.source.pending === true && !status.connected
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export function hasPrometheusCharts(status: PrometheusStatus | null | undefined): boolean {
|
|
13
18
|
if (metricsSourceUnavailable(status)) return false
|
|
14
19
|
return status?.connected === true || status?.gkeSystemMetrics === true
|
|
@@ -79,6 +79,15 @@ describe('workload history, whose flag shipped with its endpoint', () => {
|
|
|
79
79
|
})
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
+
describe('runningCodeHistory capability flag', () => {
|
|
83
|
+
it('reports supported only when advertised, unsupported when omitted or false, and unknown before capabilities load', () => {
|
|
84
|
+
expect(radarFeatureSupport('runningCodeHistory', { features: { runningCodeHistory: true } }, undefined)).toBe('supported')
|
|
85
|
+
expect(radarFeatureSupport('runningCodeHistory', { features: { runningCodeHistory: false } }, 'v99.0.0')).toBe('unsupported')
|
|
86
|
+
expect(radarFeatureSupport('runningCodeHistory', { features: { workloadHistory: true } }, 'v99.0.0')).toBe('unsupported')
|
|
87
|
+
expect(radarFeatureSupport('runningCodeHistory', undefined, 'v99.0.0')).toBe('unknown')
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
82
91
|
// A behavior change on endpoints every Radar serves: only the flag tells.
|
|
83
92
|
describe('Argo CD rollback and auto-sync, gated on argoRollbackSync', () => {
|
|
84
93
|
it.each(['argoRollback', 'argoAutoSyncEnable'] as const)('%s trusts the flag and reads its absence as too old', (feature) => {
|
package/src/api/radarFeatures.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface RadarFeatureSpec {
|
|
|
32
32
|
export const RADAR_FEATURES = {
|
|
33
33
|
datadogRightsizing: { label: 'Datadog-backed rightsizing', flag: 'datadogRightsizing', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
|
|
34
34
|
datadogAgentPresence: { label: 'Datadog Agent setup hints', flag: 'datadogAgentPresence', flagShippedWithEndpoint: true },
|
|
35
|
+
cloudClusterAccess: { label: 'Cloud cluster access settings', flag: 'cloudClusterAccess', flagShippedWithEndpoint: true },
|
|
35
36
|
ownerAccessGrantReview: { label: 'Cloud Owner permission checks', flag: 'ownerAccessGrantReview', flagShippedWithEndpoint: true },
|
|
36
37
|
gitopsActionCapabilities: { label: 'GitOps action permission checks', flag: 'gitopsActionCapabilities', flagShippedWithEndpoint: true },
|
|
37
38
|
openobserveCollectorPresence: { label: 'OpenObserve collector setup hints', flag: 'openobserveCollectorPresence', flagShippedWithEndpoint: true },
|
|
@@ -56,8 +57,15 @@ export const RADAR_FEATURES = {
|
|
|
56
57
|
applications: { label: 'Applications', minimumVersion: 'v1.7.7' },
|
|
57
58
|
workloadHistory: { label: 'Workload history', flag: 'workloadHistory', flagShippedWithEndpoint: true },
|
|
58
59
|
workloadSource: { label: 'Workload source', flag: 'workloadSource', flagShippedWithEndpoint: true },
|
|
60
|
+
// Never blocks a control: tells Deploys whether this Radar records
|
|
61
|
+
// RunningCodeChanged rows so an older Radar does not draw a code-change
|
|
62
|
+
// recording divider or "code not recorded" / "shipped code" delivery labels.
|
|
63
|
+
runningCodeHistory: { label: 'Recorded running-code changes', flag: 'runningCodeHistory', flagShippedWithEndpoint: true },
|
|
59
64
|
deploymentPause: { label: 'Deployment rollout pause and resume', flag: 'deploymentPause', flagShippedWithEndpoint: true },
|
|
60
65
|
substrateHealthMetrics: { label: 'Agent Substrate charts', flag: 'substrateHealthMetrics', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
|
|
66
|
+
substrateWorkspace: { label: 'Agent Substrate actors, templates and workers', flag: 'substrateWorkspace', flagShippedWithEndpoint: true },
|
|
67
|
+
kagentWorkspace: { label: 'kagent workspace', flag: 'kagentWorkspace', flagShippedWithEndpoint: true },
|
|
68
|
+
kagentAttribution: { label: 'kagent Agent sessions in Agent Substrate', flag: 'kagentAttribution', flagShippedWithEndpoint: true },
|
|
61
69
|
cnpgWorkspace: { label: 'CloudNativePG views', flag: 'cnpgWorkspace', flagShippedWithEndpoint: true },
|
|
62
70
|
sealedSecretsController: { label: 'Sealed Secrets controller status', flag: 'sealedSecretsController', flagShippedWithEndpoint: true },
|
|
63
71
|
traefikRoutes: { label: 'Traefik routes', flag: 'traefikRoutes', flagShippedWithEndpoint: true },
|
|
@@ -67,6 +75,7 @@ export const RADAR_FEATURES = {
|
|
|
67
75
|
cnpgProtectionSetup: { label: 'CloudNativePG backup setup', flag: 'cnpgProtectionSetup', flagShippedWithEndpoint: true },
|
|
68
76
|
// Radars from v1.21.0 report these Checks in the workspace without advertising the flag.
|
|
69
77
|
cnpgPostureChecks: { label: 'CloudNativePG backup and availability counts', minimumVersion: 'v1.21.0', flag: 'cnpgPostureChecks' },
|
|
78
|
+
agentSandboxWorkspace: { label: 'Agent Sandbox overview', flag: 'agentSandboxWorkspace', flagShippedWithEndpoint: true },
|
|
70
79
|
veleroWorkspace: { label: 'Velero views', flag: 'veleroWorkspace', flagShippedWithEndpoint: true },
|
|
71
80
|
veleroBackupNow: { label: 'Back up now', flag: 'veleroBackupNow', flagShippedWithEndpoint: true },
|
|
72
81
|
veleroSchedulePause: { label: 'Pause and resume Velero schedules', flag: 'veleroSchedulePause', flagShippedWithEndpoint: true },
|
|
@@ -108,6 +117,10 @@ export const RADAR_FEATURES = {
|
|
|
108
117
|
// Never blocks a control: an older Radar ignores the request body and names
|
|
109
118
|
// the Job itself, so Trigger stays one click without the Job name dialog.
|
|
110
119
|
cronJobTriggerJobName: { label: 'Job names for manual CronJob runs', flag: 'cronJobTriggerJobName', flagShippedWithEndpoint: true },
|
|
120
|
+
// A Radar with the flag answers kev=1 and carries KEV and EPSS in `intel`
|
|
121
|
+
// when Radar Cloud provides them; without Radar Cloud the answers have no
|
|
122
|
+
// `intel`.
|
|
123
|
+
vulnerabilityIntel: { label: 'Known exploited CVEs and EPSS scores', flag: 'vulnerabilityIntel', flagShippedWithEndpoint: true },
|
|
111
124
|
} as const satisfies Record<string, RadarFeatureSpec>
|
|
112
125
|
|
|
113
126
|
export type RadarFeature = keyof typeof RADAR_FEATURES
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { beforeEach, expect, it, vi } from 'vitest'
|
|
2
|
+
import { useMutation, useQuery } from '@tanstack/react-query'
|
|
3
|
+
import { useSubstrateActor, useSubstrateActorLogs, useSubstrateActors, useSubstrateStatus, useUpdateSubstrateConnection } from './substrateWorkspace'
|
|
4
|
+
|
|
5
|
+
vi.mock('@tanstack/react-query', () => ({ useQuery: vi.fn(() => ({})), useMutation: vi.fn(), useQueryClient: vi.fn() }))
|
|
6
|
+
const feature = vi.hoisted(() => ({ support: 'unsupported', gatedKey: ['radar-feature-unsupported'] }))
|
|
7
|
+
vi.mock('./config', () => ({ getApiBase: () => '/api' }))
|
|
8
|
+
vi.mock('./client', () => ({
|
|
9
|
+
ApiError: class extends Error {},
|
|
10
|
+
apiFetch: vi.fn(),
|
|
11
|
+
fetchJSON: vi.fn(),
|
|
12
|
+
useClusterInfo: () => ({ data: { context: 'cluster-a' } }),
|
|
13
|
+
useRadarFeature: () => ({
|
|
14
|
+
support: feature.support,
|
|
15
|
+
gatedKey: feature.gatedKey,
|
|
16
|
+
upgrade: undefined,
|
|
17
|
+
blockedReason: undefined,
|
|
18
|
+
guard: (request: () => Promise<unknown>) => request(),
|
|
19
|
+
}),
|
|
20
|
+
}))
|
|
21
|
+
beforeEach(() => vi.clearAllMocks())
|
|
22
|
+
|
|
23
|
+
type Placeholder = (previous: unknown, query?: { queryKey: readonly unknown[] }) => unknown
|
|
24
|
+
function lastQuery() { return vi.mocked(useQuery).mock.calls.at(-1)![0] }
|
|
25
|
+
|
|
26
|
+
it('lets the feature guard decide, so an unsupported Radar reaches the upgrade path', () => {
|
|
27
|
+
useSubstrateStatus()
|
|
28
|
+
const options = lastQuery()
|
|
29
|
+
expect(options.enabled).toBe(true)
|
|
30
|
+
expect(options.queryKey).toEqual(['substrate', '/api', 'cluster-a', 'status', 'radar-feature-unsupported'])
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('keeps no previous answer for a detail, only for another page of the same actor list', () => {
|
|
34
|
+
feature.gatedKey = []
|
|
35
|
+
useSubstrateActor({ atespace: 'research', name: 'a' })
|
|
36
|
+
const a = lastQuery()
|
|
37
|
+
expect(a.placeholderData).toBeUndefined()
|
|
38
|
+
|
|
39
|
+
useSubstrateActors({ state: 'crashed', offset: 0, limit: 50 })
|
|
40
|
+
const page1 = lastQuery()
|
|
41
|
+
useSubstrateActors({ state: 'crashed', offset: 50, limit: 50 })
|
|
42
|
+
const page2 = lastQuery()
|
|
43
|
+
useSubstrateActors({ state: 'running', offset: 50, limit: 50 })
|
|
44
|
+
const otherFilter = lastQuery()
|
|
45
|
+
const previous = { rows: [] }
|
|
46
|
+
const keep = page2.placeholderData as Placeholder
|
|
47
|
+
expect(keep(previous, { queryKey: page1.queryKey })).toBe(previous)
|
|
48
|
+
expect((otherFilter.placeholderData as Placeholder)(previous, { queryKey: page2.queryKey })).toBeUndefined()
|
|
49
|
+
expect(keep(previous, { queryKey: ['substrate', '/api', 'cluster-b', ...page1.queryKey.slice(3)] })).toBeUndefined()
|
|
50
|
+
expect(keep(previous, { queryKey: ['substrate', '/other', 'cluster-a', ...page1.queryKey.slice(3)] })).toBeUndefined()
|
|
51
|
+
expect(keep(previous, { queryKey: a.queryKey })).toBeUndefined()
|
|
52
|
+
expect(keep(previous, undefined)).toBeUndefined()
|
|
53
|
+
feature.gatedKey = ['radar-feature-unsupported']
|
|
54
|
+
useSubstrateActors({ state: 'crashed', offset: 50, limit: 50 })
|
|
55
|
+
expect((lastQuery().placeholderData as Placeholder)(previous, { queryKey: page2.queryKey })).toBeUndefined()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('reads a new log window after a crash and leaves last-node polling off', () => {
|
|
59
|
+
const actor = { atespace: 'research', name: 'a' }
|
|
60
|
+
useSubstrateActorLogs({ ...actor, state: 'running', assignment: { worker: 'w', namespace: 'agents', pool: 'pool', pod: 'pod', node: 'node' } }, { tailLines: 8 })
|
|
61
|
+
const running = lastQuery()
|
|
62
|
+
useSubstrateActorLogs({ ...actor, state: 'crashed', crash: { time: '2026-11-26T00:00:00Z' } }, { tailLines: 8, pollMs: false })
|
|
63
|
+
const crashed = lastQuery()
|
|
64
|
+
expect(running.refetchInterval).toBe(15_000)
|
|
65
|
+
expect(crashed.queryKey).not.toEqual(running.queryKey)
|
|
66
|
+
expect(crashed.refetchInterval).toBe(false)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('leaves save and disconnect feedback to the connection form', () => {
|
|
70
|
+
useUpdateSubstrateConnection()
|
|
71
|
+
expect(vi.mocked(useMutation).mock.calls.at(-1)?.[0].meta).toBeUndefined()
|
|
72
|
+
})
|