@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
|
@@ -30,6 +30,7 @@ import { useIsAuthEnabled } from '../../contexts/CapabilitiesContext'
|
|
|
30
30
|
import { executionDefinitionDiffers, executionDefinitionSummary, type ExecutionDefinitionSummary, type ExecutionUnitSummary } from './execution-definition'
|
|
31
31
|
import { batchRunHasContainerOutcome, batchRunNextStep, isFailedRunPhase, type BatchRunNextStep } from './batch-run-actions'
|
|
32
32
|
import { JobSetAdmission } from './JobSetAdmission'
|
|
33
|
+
import { runStateLabel } from './runState'
|
|
33
34
|
|
|
34
35
|
const EMPTY_RUNS: WorkloadRun[] = []
|
|
35
36
|
const SCHEDULED_KINDS = new Set(['CronJob', 'CronWorkflow', 'WorkflowTemplate', 'ClusterWorkflowTemplate', 'ScaledJob', 'JobSet'])
|
|
@@ -122,7 +123,15 @@ interface BatchExecutionProps {
|
|
|
122
123
|
viewNamespaces?: string[]
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
export function BatchExecutionFullscreen(
|
|
126
|
+
export function BatchExecutionFullscreen(props: BatchExecutionProps) {
|
|
127
|
+
const { resource, namespace, name, onNavigateToResource } = props
|
|
128
|
+
if (resource.apiVersion !== 'batch/v1' || resource.kind !== 'Job') return <BatchExecutionContent {...props} />
|
|
129
|
+
return <JobSetAdmission resource={resource} namespace={namespace} name={name} onNavigate={onNavigateToResource}>
|
|
130
|
+
{(admissionContent, kueueManaged) => <BatchExecutionContent {...props} admissionContent={admissionContent} kueueManaged={kueueManaged} />}
|
|
131
|
+
</JobSetAdmission>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function BatchExecutionContent({ leadContent, kind, apiKind, namespace, name, resource, selectedRunKey = '', canViewLogs = false, onSelectRun, onSwitchToLogs, onSwitchToTimeline, onNavigateToResource, viewNamespaces, admissionContent, kueueManaged = false }: BatchExecutionProps & { admissionContent?: ReactNode; kueueManaged?: boolean }) {
|
|
126
135
|
const scheduled = SCHEDULED_KINDS.has(kind)
|
|
127
136
|
const clusterScoped = kind === 'ClusterWorkflowTemplate'
|
|
128
137
|
const jobSetRoot = isJobSetV1Alpha2(resource)
|
|
@@ -179,6 +188,7 @@ export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace
|
|
|
179
188
|
}, [runsQuery.data, runsQuery.isPlaceholderData, runs, resolvedRuns, selectedRunKey, defaultRun, onSelectRun, selectionMissing])
|
|
180
189
|
|
|
181
190
|
const selectedRun = selectionMissing ? undefined : resolvedRuns.find((run) => workloadRunKey(run) === selectedRunKey) ?? defaultRun
|
|
191
|
+
const selectedRunHeldByKueue = kueueManaged && selectedRun?.kind === 'jobs' && selectedRun.namespace === namespace && selectedRun.name === name && selectedRun.phase === 'Suspended'
|
|
182
192
|
useEffect(() => {
|
|
183
193
|
if (!selectedRun) return
|
|
184
194
|
const selectionChanged = previousSelection.current !== selectedRunKey
|
|
@@ -355,7 +365,8 @@ export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace
|
|
|
355
365
|
<JobSetRenderer data={resource} mode="overview" shownMemberCounts={shownMemberCounts} onSelectRole={memberCollection ? selectRole : undefined} />
|
|
356
366
|
</section>
|
|
357
367
|
)}
|
|
358
|
-
{
|
|
368
|
+
{admissionContent}
|
|
369
|
+
{jobSetRoot && <JobSetAdmission resource={resource} namespace={namespace} name={name} onNavigate={onNavigateToResource} />}
|
|
359
370
|
{memberShell && <JobSetMemberComparison
|
|
360
371
|
runs={runs} total={runsQuery.data?.total ?? 0} filteredTotal={runsQuery.data?.filteredTotal ?? runs.length}
|
|
361
372
|
truncated={runsQuery.data?.truncated ?? false} loading={runsQuery.isLoading} error={runsQuery.error}
|
|
@@ -407,7 +418,7 @@ export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace
|
|
|
407
418
|
{selectedResourceQuery.isFetching && <span>refreshing</span>}
|
|
408
419
|
</div>
|
|
409
420
|
</div>
|
|
410
|
-
<span className={clsx('badge', phaseBadgeClass(selectedRun.phase))}>{
|
|
421
|
+
<span className={clsx('badge', selectedRunHeldByKueue ? 'status-neutral' : phaseBadgeClass(selectedRun.phase))}>{selectedRunHeldByKueue ? `Held by Kueue until admitted${selectedRun.deleting ? ' · deleting' : ''}` : runStateLabel(selectedRun)}</span>
|
|
411
422
|
</div>
|
|
412
423
|
{memberCollection && <div className="flex flex-wrap items-center gap-3 border-b border-theme-border px-4 py-2 text-xs">
|
|
413
424
|
{!runs.some(run => workloadRunKey(run) === selectedRunKey) && <span className="text-theme-text-secondary">Selected Job is outside the current filter or shown window.</span>}
|
|
@@ -470,7 +481,7 @@ export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace
|
|
|
470
481
|
<JobSetRenderer data={resource} mode="configuration" />
|
|
471
482
|
) : (
|
|
472
483
|
<SourceFacts
|
|
473
|
-
source={sourceFacts(kind, definitionResource, runs)}
|
|
484
|
+
source={sourceFacts(kind, definitionResource, runs, kueueManaged)}
|
|
474
485
|
namespace={selectedRun?.namespace || namespace}
|
|
475
486
|
definitionLoading={Boolean(referencedDefinitionTarget) && referencedDefinitionQuery.isLoading}
|
|
476
487
|
definitionError={referencedDefinitionTarget ? referencedDefinitionQuery.error : undefined}
|
|
@@ -564,7 +575,7 @@ function scaledJobTone(resource: any): 'info' | 'warning' | 'success' | 'error'
|
|
|
564
575
|
}
|
|
565
576
|
}
|
|
566
577
|
|
|
567
|
-
function sourceFacts(kind: string, resource: any, runs: WorkloadRun[]) {
|
|
578
|
+
function sourceFacts(kind: string, resource: any, runs: WorkloadRun[], kueueManaged = false) {
|
|
568
579
|
const spec = resource?.spec ?? {}
|
|
569
580
|
const status = resource?.status ?? {}
|
|
570
581
|
const latest = pickLatestRun(runs)
|
|
@@ -649,9 +660,11 @@ function sourceFacts(kind: string, resource: any, runs: WorkloadRun[]) {
|
|
|
649
660
|
}
|
|
650
661
|
}
|
|
651
662
|
if (kind === 'Job') {
|
|
663
|
+
const phase = jobPhase(resource)
|
|
664
|
+
const heldByKueue = kueueManaged && phase === 'Suspended'
|
|
652
665
|
return {
|
|
653
|
-
state:
|
|
654
|
-
stateTone: phaseTone(
|
|
666
|
+
state: heldByKueue ? 'Held by Kueue until admitted' : phase,
|
|
667
|
+
stateTone: heldByKueue ? 'info' : phaseTone(phase),
|
|
655
668
|
progress: latest?.progress,
|
|
656
669
|
duration: latest ? formatRunDuration(latest) : '',
|
|
657
670
|
work: latest ? workCount(latest) : '',
|
|
@@ -678,7 +691,7 @@ function SourceFacts({ source, namespace, definitionLoading = false, definitionE
|
|
|
678
691
|
return (
|
|
679
692
|
<>
|
|
680
693
|
<div className="grid grid-cols-2 gap-2">
|
|
681
|
-
{source.state !== 'Definition' && <FactTile label="State" value={source.state} tone={source.stateTone} />}
|
|
694
|
+
{source.state !== 'Definition' && <FactTile label="State" value={source.state} tone={source.stateTone} wrap />}
|
|
682
695
|
{source.schedule && <FactTile label="Schedule" value={source.schedule} mono />}
|
|
683
696
|
{source.concurrency && <FactTile label="Concurrency" value={source.concurrency} />}
|
|
684
697
|
</div>
|
|
@@ -1273,16 +1286,16 @@ function RunRailButton({ run, selected, showNamespace, onClick }: { run: Workloa
|
|
|
1273
1286
|
{formatRunTime(run) || 'time unknown'}{formatRunDuration(run) ? ` · ${formatRunDuration(run)}` : ''} · {workCount(run)}
|
|
1274
1287
|
</span>
|
|
1275
1288
|
</span>
|
|
1276
|
-
<span className={clsx('badge-sm shrink-0', phaseBadgeClass(run.phase))}>{
|
|
1289
|
+
<span className={clsx('badge-sm shrink-0', phaseBadgeClass(run.phase))}>{runStateLabel(run, shortPhase)}</span>
|
|
1277
1290
|
</button>
|
|
1278
1291
|
)
|
|
1279
1292
|
}
|
|
1280
1293
|
|
|
1281
|
-
function FactTile({ label, value, tone, mono }: { label: string; value: string | number; tone?: string; mono?: boolean }) {
|
|
1294
|
+
function FactTile({ label, value, tone, mono, wrap = false }: { label: string; value: string | number; tone?: string; mono?: boolean; wrap?: boolean }) {
|
|
1282
1295
|
return (
|
|
1283
1296
|
<div className="rounded-md border border-theme-border bg-theme-surface px-3 py-2">
|
|
1284
1297
|
<div className="text-[10px] font-medium uppercase tracking-wide text-theme-text-tertiary">{label}</div>
|
|
1285
|
-
<div className={clsx('mt-1
|
|
1298
|
+
<div className={clsx('mt-1 text-sm font-semibold text-theme-text-primary', wrap ? 'break-words' : 'truncate', mono && 'font-mono', tone && phaseTextClass(tone))}>{value}</div>
|
|
1286
1299
|
</div>
|
|
1287
1300
|
)
|
|
1288
1301
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
2
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
3
|
import { KueueAdmission } from "./JobSetAdmission";
|
|
4
|
+
import { JobRenderer } from '../resources/renderers/JobAdmissionRenderers'
|
|
5
|
+
import { BatchExecutionFullscreen } from './BatchExecutionView'
|
|
4
6
|
const mock = vi.hoisted(() => ({ result: {} as any, calls: [] as any[] }));
|
|
5
7
|
vi.mock("../../api/client", () => ({
|
|
6
8
|
ApiError: class extends Error {
|
|
@@ -10,6 +12,10 @@ vi.mock("../../api/client", () => ({
|
|
|
10
12
|
mock.calls.push(args);
|
|
11
13
|
return mock.result;
|
|
12
14
|
},
|
|
15
|
+
useResource: () => ({}),
|
|
16
|
+
useWorkloadPods: () => ({}),
|
|
17
|
+
useJobSetResources: () => ({}),
|
|
18
|
+
useWorkloadRuns: () => ({ data: { runs: [{ kind: 'jobs', namespace: 'ml', name: 'train', phase: 'Suspended', active: false }], total: 1 } }),
|
|
13
19
|
}));
|
|
14
20
|
const job = {
|
|
15
21
|
apiVersion: "batch/v1",
|
|
@@ -115,6 +121,42 @@ describe("Job admission host", () => {
|
|
|
115
121
|
});
|
|
116
122
|
});
|
|
117
123
|
|
|
124
|
+
describe.each(['drawer', 'fullscreen'])('suspended Job wording in %s', (surface) => {
|
|
125
|
+
const renderJob = (resource: any) => renderToStaticMarkup(surface === 'drawer'
|
|
126
|
+
? <JobRenderer data={resource} />
|
|
127
|
+
: <BatchExecutionFullscreen kind="Job" apiKind="jobs" namespace="ml" name="train" resource={resource} />)
|
|
128
|
+
const expectHeld = (html: string) => {
|
|
129
|
+
expect(html.match(/Held by Kueue until admitted/g)).toHaveLength(surface === 'drawer' ? 1 : 2)
|
|
130
|
+
expect(html).not.toContain('>Suspended<')
|
|
131
|
+
expect(html).not.toContain('Pods will not be created until this Job is resumed.')
|
|
132
|
+
if (surface === 'drawer') expect(html).toContain('See Kueue admission')
|
|
133
|
+
}
|
|
134
|
+
const expectPlain = (html: string) => {
|
|
135
|
+
expect(html).not.toContain('Held by Kueue')
|
|
136
|
+
if (surface === 'drawer') {
|
|
137
|
+
expect(html).toContain('Job Suspended')
|
|
138
|
+
expect(html).toContain('Pods will not be created until this Job is resumed.')
|
|
139
|
+
} else expect(html.match(/>Suspended</g)).toHaveLength(2)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
it.each([{ isLoading: true }, { data: empty }, { error: new Error('denied') }])('uses the queue label even without a successful admission lookup: %j', (result) => {
|
|
143
|
+
mock.result = result
|
|
144
|
+
expectHeld(renderJob(hinted))
|
|
145
|
+
})
|
|
146
|
+
it('uses controller-owned Workload evidence for an unlabeled Job', () => {
|
|
147
|
+
mock.result = { data: evidence }
|
|
148
|
+
expectHeld(renderJob(job))
|
|
149
|
+
})
|
|
150
|
+
it.each([{ isLoading: true }, { data: empty }, { error: new Error('denied') }, { data: { ...evidence, uid: 'old' } }, { data: evidence, error: new Error('cache unavailable') }])('keeps ordinary wording without current readable evidence: %j', (result) => {
|
|
151
|
+
mock.result = result
|
|
152
|
+
expectPlain(renderJob(job))
|
|
153
|
+
})
|
|
154
|
+
it('does not infer Kueue from an arbitrary controller', () => {
|
|
155
|
+
mock.result = { data: empty }
|
|
156
|
+
expectPlain(renderJob({ ...job, spec: { ...job.spec, managedBy: 'other.io/controller' } }))
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
|
|
118
160
|
describe("JobSet admission identity", () => {
|
|
119
161
|
it("rejects evidence and absence for a different root instance", () => {
|
|
120
162
|
const resource = {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { KueueAdmissionSection } from '@skyhook-io/k8s-ui/components/resources/KueueAdmissionSection'
|
|
2
|
+
import type { KueueAdmissionWorkload } from '@skyhook-io/k8s-ui/types/scheduling'
|
|
2
3
|
import { ApiError, useKueueAdmission } from '../../api/client'
|
|
4
|
+
import { KueuePendingPosition } from '../kueue/KueuePendingPosition'
|
|
5
|
+
import type { ReactNode } from 'react'
|
|
3
6
|
|
|
4
|
-
export function KueueAdmission({ resource, namespace, name, onNavigate, presentation }: {
|
|
7
|
+
export function KueueAdmission({ resource, namespace, name, onNavigate, presentation, children }: {
|
|
5
8
|
presentation?: 'card' | 'drawer'
|
|
6
9
|
resource: any
|
|
7
10
|
namespace: string
|
|
8
11
|
name: string
|
|
12
|
+
children?: (admissionContent: ReactNode, hasKueueEvidence: boolean) => ReactNode
|
|
9
13
|
onNavigate?: (ref: { kind: string; namespace: string; name: string; group?: string }) => void
|
|
10
14
|
}) {
|
|
11
15
|
const isJob = resource.apiVersion === 'batch/v1' && resource.kind === 'Job'
|
|
@@ -18,9 +22,20 @@ export function KueueAdmission({ resource, namespace, name, onNavigate, presenta
|
|
|
18
22
|
const query = useKueueAdmission(namespace, name, resource.metadata?.uid, { isJob, isRayJob, hinted, terminal })
|
|
19
23
|
const data = query.data?.uid === resource.metadata?.uid ? query.data : undefined
|
|
20
24
|
const error = query.error?.message ?? (query.data && !data ? 'Admission evidence belongs to a different workload instance; waiting for a fresh observation.' : undefined)
|
|
21
|
-
|
|
25
|
+
const hasKueueEvidence = Boolean(labels?.['kueue.x-k8s.io/queue-name'] || (!query.error && data?.workloads.length))
|
|
26
|
+
const visible = !((isJob || isRayJob) && !hinted && !data?.workloads.length)
|
|
22
27
|
const hasOwner = (resource.metadata?.ownerReferences ?? []).some((owner: any) => owner.controller === true && !(owner.apiVersion === 'batch/v1' && owner.kind === 'CronJob'))
|
|
23
|
-
|
|
28
|
+
const content = visible ? <KueueAdmissionSection presentation={presentation} data={data} loading={query.isLoading} error={error} forbidden={query.error instanceof ApiError && query.error.status === 403} hinted={hinted} externalExecution={externalExecution} hasOwner={isJob && hasOwner} onRetry={() => { void query.refetch() }} onNavigate={onNavigate} renderWorkloadExtra={renderPendingPosition} /> : null
|
|
29
|
+
return children ? children(content, hasKueueEvidence) : content
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Kueue's reported position, for a Workload the admission projection reads as
|
|
33
|
+
// pending and active: the same rule the Workload drawer and the server apply.
|
|
34
|
+
function renderPendingPosition(workload: KueueAdmissionWorkload) {
|
|
35
|
+
const kueue = workload.scheduling?.observations?.find(observation => observation.kueue)?.kueue
|
|
36
|
+
const queue = workload.scheduling?.observations?.flatMap(observation => observation.queues ?? []).find(entry => entry.roles.includes('submission'))?.name
|
|
37
|
+
if (!kueue || kueue.phase !== 'pending' || kueue.active === false) return null
|
|
38
|
+
return <p className="text-sm"><span className="text-theme-text-secondary">Queue position: </span><KueuePendingPosition namespace={workload.namespace} name={workload.name} uid={workload.uid} queueName={queue} requeueAt={kueue.requeueState?.requeueAt} /></p>
|
|
24
39
|
}
|
|
25
40
|
|
|
26
41
|
export { KueueAdmission as JobSetAdmission }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Badge, EmptyState, FetchResult } from '@skyhook-io/k8s-ui'
|
|
2
2
|
import { formatCPUNanocores, formatMemoryBytes } from '@skyhook-io/k8s-ui/utils/format'
|
|
3
3
|
import type { JobSetResources, JobSetUsage, WorkloadRun } from '../../api/client'
|
|
4
|
+
import { runStateLabel } from './runState'
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
runs: WorkloadRun[]
|
|
@@ -74,7 +75,7 @@ export function JobSetMemberComparison(props: Props) {
|
|
|
74
75
|
return <tr key={key} className={`border-b border-theme-border-subtle last:border-0 ${props.selected === key ? 'selection' : 'hover:bg-theme-hover'}`}>
|
|
75
76
|
<td className="px-3 py-2 text-theme-text-secondary">{run.jobset?.replicatedJob ?? 'Not reported'}{run.jobset?.jobIndex !== undefined && ` #${run.jobset.jobIndex}`}</td>
|
|
76
77
|
<th scope="row" className="max-w-xs px-3 py-2 font-medium"><button type="button" aria-pressed={props.selected === key} className="block max-w-full truncate text-accent-text hover:underline" onClick={() => props.onSelect?.(key)}>{run.name}</button></th>
|
|
77
|
-
<td className="px-3 py-2"><Badge severity={run.phase === 'Failed' || run.phase === 'Error' ? 'error' : run.phase === 'Succeeded' ? 'success' : run.active ? 'info' : 'neutral'}>{run
|
|
78
|
+
<td className="px-3 py-2"><Badge severity={run.phase === 'Failed' || run.phase === 'Error' ? 'error' : run.phase === 'Succeeded' ? 'success' : run.active ? 'info' : 'neutral'}>{runStateLabel(run)}</Badge></td>
|
|
78
79
|
<td className="whitespace-nowrap px-3 py-2 text-theme-text-secondary">{props.durationFor(run) || '—'}</td>
|
|
79
80
|
<td className="whitespace-nowrap px-3 py-2"><UsageValue usage={usage} resource="cpu" /></td>
|
|
80
81
|
<td className="whitespace-nowrap px-3 py-2"><UsageValue usage={usage} resource="memory" /></td>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { runStateLabel } from './runState'
|
|
3
|
+
|
|
4
|
+
describe('runStateLabel', () => {
|
|
5
|
+
it('reads a deleting Job with no active Pods as Deleting, not Pending', () => {
|
|
6
|
+
expect(runStateLabel({ phase: 'Pending', deleting: true })).toBe('Deleting')
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it('keeps the phase for other runs, marking deletion', () => {
|
|
10
|
+
expect(runStateLabel({ phase: 'Running', deleting: true })).toBe('Running · deleting')
|
|
11
|
+
expect(runStateLabel({ phase: 'Pending' })).toBe('Pending')
|
|
12
|
+
expect(runStateLabel({ phase: 'Succeeded', deleting: true }, () => 'OK')).toBe('OK · deleting')
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkloadRun } from '../../api/client'
|
|
2
|
+
|
|
3
|
+
// A Job being deleted whose Pods are still terminating has no active Pods, so
|
|
4
|
+
// its derived phase falls back to Pending, which reads as "not started yet".
|
|
5
|
+
export function runStateLabel(run: Pick<WorkloadRun, 'phase' | 'deleting'>, formatPhase: (phase: string) => string = phase => phase): string {
|
|
6
|
+
if (run.deleting && run.phase === 'Pending') return 'Deleting'
|
|
7
|
+
return `${formatPhase(run.phase)}${run.deleting ? ' · deleting' : ''}`
|
|
8
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
7
|
+
import type { GitOpsHistoryItem, GitOpsInsight } from '@skyhook-io/k8s-ui'
|
|
8
|
+
import { GitOpsView } from './GitOpsView'
|
|
9
|
+
|
|
10
|
+
const harness = vi.hoisted(() => ({
|
|
11
|
+
rollback: vi.fn(),
|
|
12
|
+
resume: vi.fn(),
|
|
13
|
+
onResume: undefined as undefined | (() => void),
|
|
14
|
+
showError: vi.fn(),
|
|
15
|
+
multiSourceWarning: undefined as boolean | undefined,
|
|
16
|
+
source: undefined as string | undefined,
|
|
17
|
+
confirm: undefined as undefined | ((opts: { prune: boolean; dryRun: boolean }) => void),
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
const app = {
|
|
21
|
+
apiVersion: 'argoproj.io/v1alpha1',
|
|
22
|
+
kind: 'Application',
|
|
23
|
+
metadata: { name: 'guestbook', namespace: 'argocd' },
|
|
24
|
+
spec: { project: 'default', source: {}, destination: {}, syncPolicy: {} },
|
|
25
|
+
status: { sync: { status: 'Synced' }, health: { status: 'Healthy' } },
|
|
26
|
+
}
|
|
27
|
+
const insight = {
|
|
28
|
+
summary: { tool: 'argocd', kind: 'Application', namespace: 'argocd', name: 'guestbook', autoSyncMode: 'Manual' },
|
|
29
|
+
capabilities: { rollback: true },
|
|
30
|
+
history: [{ id: '0', revision: 'aaa111' }],
|
|
31
|
+
} as unknown as GitOpsInsight
|
|
32
|
+
|
|
33
|
+
// The layout and the history view are replaced by stubs that expose just what
|
|
34
|
+
// the rollback path needs: the Activity body, the dialog, and the gate.
|
|
35
|
+
vi.mock('@skyhook-io/k8s-ui', async (importOriginal) => {
|
|
36
|
+
const actual = await importOriginal<typeof import('@skyhook-io/k8s-ui')>()
|
|
37
|
+
return {
|
|
38
|
+
...actual,
|
|
39
|
+
useToast: () => ({ showError: harness.showError, showSuccess: vi.fn(), showToast: vi.fn() }),
|
|
40
|
+
GitOpsDetailLayout: (props: { argo?: { onResume: () => void; resumeUpgrade?: unknown; resumeBlockedReason?: string }; renderTabBody: (ctx: { tab: 'activity'; fullscreen: boolean }) => React.ReactNode; children?: React.ReactNode }) => {
|
|
41
|
+
harness.onResume = props.argo?.onResume
|
|
42
|
+
return <div>
|
|
43
|
+
<button disabled={!!props.argo?.resumeUpgrade || !!props.argo?.resumeBlockedReason} onClick={props.argo?.onResume}>Enable auto-sync</button>
|
|
44
|
+
{props.argo?.resumeBlockedReason}
|
|
45
|
+
{props.renderTabBody({ tab: 'activity', fullscreen: false })}{props.children}
|
|
46
|
+
</div>
|
|
47
|
+
},
|
|
48
|
+
GitOpsActivityInsightView: (props: { onRollback?: (item: GitOpsHistoryItem) => void; rollbackUpgrade?: unknown; rollbackBlockedReason?: string }) => (
|
|
49
|
+
<div>{props.rollbackBlockedReason}<button type="button" disabled={!!props.rollbackUpgrade || !!props.rollbackBlockedReason} onClick={() => props.onRollback?.({ id: '0', revision: 'aaa111', source: 'guestbook (+1 more)', rollbackMultiSourceWarning: true })}>Rollback</button></div>
|
|
50
|
+
),
|
|
51
|
+
RollbackDialog: (props: { open: boolean; source?: string; multiSourceWarning?: boolean; onConfirm: (opts: { prune: boolean; dryRun: boolean }) => void }) => {
|
|
52
|
+
if (props.open) {
|
|
53
|
+
harness.confirm = props.onConfirm
|
|
54
|
+
harness.multiSourceWarning = props.multiSourceWarning
|
|
55
|
+
harness.source = props.source
|
|
56
|
+
}
|
|
57
|
+
return props.open ? <div role="dialog">Roll back?</div> : null
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
vi.mock('../../api/client', async (importOriginal) => {
|
|
62
|
+
const actual = await importOriginal<typeof import('../../api/client')>()
|
|
63
|
+
const idle = () => ({ mutate: vi.fn(), reset: vi.fn(), isPending: false })
|
|
64
|
+
return {
|
|
65
|
+
...actual,
|
|
66
|
+
useResource: () => ({ data: app, isLoading: false, error: null }),
|
|
67
|
+
useGitOpsTree: () => ({ data: undefined, isLoading: false, error: null }),
|
|
68
|
+
useGitOpsInsights: () => ({ data: insight, isLoading: false, error: null }),
|
|
69
|
+
useArgoRollback: () => ({ mutate: harness.rollback, isPending: false }),
|
|
70
|
+
useArgoSync: idle, useArgoResourceValidation: idle, useArgoRefresh: idle, useArgoTerminate: idle,
|
|
71
|
+
useArgoSuspend: idle, useArgoResume: () => ({ mutate: harness.resume, isPending: false }), useApplyResource: idle,
|
|
72
|
+
useFluxReconcile: idle, useFluxSyncWithSource: idle, useFluxSuspend: idle, useFluxResume: idle,
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
vi.mock('../../api/apiResources', async (importOriginal) => ({
|
|
76
|
+
...(await importOriginal<typeof import('../../api/apiResources')>()),
|
|
77
|
+
useAPIResources: () => ({ data: [], isLoading: false }),
|
|
78
|
+
}))
|
|
79
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
|
|
80
|
+
vi.mock('../../context/RadarUpgradeHost', () => ({ useRadarUpgradeHost: () => ({}) }))
|
|
81
|
+
vi.mock('../useContextSwitchFlow', () => ({ useContextSwitchFlow: () => ({ confirmDialog: null, requestSwitch: vi.fn() }) }))
|
|
82
|
+
vi.mock('./useDestinationCluster', () => ({ useDestinationCluster: () => ({}) }))
|
|
83
|
+
vi.mock('../../hooks/useKeyboardShortcuts', () => ({ useRegisterShortcut: () => {} }))
|
|
84
|
+
vi.mock('../../hooks/usePreviousIntegrationSettings', () => ({ usePreviousIntegrationSettings: () => ({}), previousSettingsNote: () => undefined }))
|
|
85
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
86
|
+
|
|
87
|
+
let client: QueryClient
|
|
88
|
+
let host: HTMLDivElement
|
|
89
|
+
let root: ReturnType<typeof createRoot>
|
|
90
|
+
|
|
91
|
+
beforeEach(async () => {
|
|
92
|
+
app.spec.syncPolicy = {}
|
|
93
|
+
harness.resume.mockClear()
|
|
94
|
+
harness.onResume = undefined
|
|
95
|
+
harness.rollback.mockClear()
|
|
96
|
+
harness.showError.mockClear()
|
|
97
|
+
harness.confirm = undefined
|
|
98
|
+
harness.multiSourceWarning = undefined
|
|
99
|
+
harness.source = undefined
|
|
100
|
+
// /api/capabilities and /version-check stay pending until a test answers.
|
|
101
|
+
vi.stubGlobal('fetch', vi.fn(() => new Promise<Response>(() => {})))
|
|
102
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
103
|
+
host = document.createElement('div')
|
|
104
|
+
document.body.append(host)
|
|
105
|
+
root = createRoot(host)
|
|
106
|
+
await act(async () => root.render(
|
|
107
|
+
<MemoryRouter initialEntries={['/gitops/detail/applications/argocd/guestbook?apiGroup=argoproj.io']}>
|
|
108
|
+
<QueryClientProvider client={client}><GitOpsView namespaces={[]} onOpenResource={() => {}} /></QueryClientProvider>
|
|
109
|
+
</MemoryRouter>,
|
|
110
|
+
))
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
afterEach(async () => {
|
|
114
|
+
await act(async () => root.unmount())
|
|
115
|
+
client.clear()
|
|
116
|
+
host.remove()
|
|
117
|
+
vi.unstubAllGlobals()
|
|
118
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const settle = async () => { await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) }) }
|
|
122
|
+
const rollbackButton = () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Rollback')!
|
|
123
|
+
|
|
124
|
+
it('does not send a rollback confirmed after capabilities show an older Radar', async () => {
|
|
125
|
+
await act(async () => { client.setQueryData(['capabilities'], { features: { argoRollbackSync: true } }) })
|
|
126
|
+
await settle()
|
|
127
|
+
expect(rollbackButton().disabled).toBe(false)
|
|
128
|
+
await act(async () => rollbackButton().click())
|
|
129
|
+
expect(host.querySelector('[role="dialog"]')).not.toBeNull()
|
|
130
|
+
|
|
131
|
+
await act(async () => { client.setQueryData(['capabilities'], { features: { workloadHistory: true } }) })
|
|
132
|
+
await settle()
|
|
133
|
+
expect(rollbackButton().disabled).toBe(true)
|
|
134
|
+
await act(async () => harness.confirm!({ prune: false, dryRun: false }))
|
|
135
|
+
|
|
136
|
+
expect(harness.rollback).not.toHaveBeenCalled()
|
|
137
|
+
expect(harness.showError).toHaveBeenCalledWith('Rollback unavailable', expect.stringContaining('Argo CD rollbacks need'))
|
|
138
|
+
expect(host.querySelector('[role="dialog"]')).toBeNull()
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
it('sends history id 0 once capabilities advertise argoRollbackSync', async () => {
|
|
142
|
+
await act(async () => { client.setQueryData(['capabilities'], { features: { argoRollbackSync: true } }) })
|
|
143
|
+
await settle()
|
|
144
|
+
expect(rollbackButton().disabled).toBe(false)
|
|
145
|
+
await act(async () => rollbackButton().click())
|
|
146
|
+
await act(async () => harness.confirm!({ prune: false, dryRun: false }))
|
|
147
|
+
expect(harness.rollback).toHaveBeenCalledWith(expect.objectContaining({ namespace: 'argocd', name: 'guestbook', id: 0 }), expect.any(Object))
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('passes the selected multi-source history entry to the rollback confirmation', async () => {
|
|
151
|
+
await act(async () => { client.setQueryData(['capabilities'], { features: { argoRollbackSync: true } }) })
|
|
152
|
+
await settle()
|
|
153
|
+
await act(async () => rollbackButton().click())
|
|
154
|
+
expect(harness.multiSourceWarning).toBe(true)
|
|
155
|
+
expect(harness.source).toBe('guestbook (+1 more)')
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('disables rollback while capabilities are pending with checking copy', () => {
|
|
159
|
+
expect(rollbackButton().disabled).toBe(true)
|
|
160
|
+
expect(host.textContent).toContain("Checking this cluster's Radar…")
|
|
161
|
+
expect(host.textContent).not.toContain('need the latest Radar')
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('does not execute confirmation while capabilities are pending', async () => {
|
|
165
|
+
await act(async () => { client.setQueryData(['capabilities'], { features: { argoRollbackSync: true } }) })
|
|
166
|
+
await settle()
|
|
167
|
+
await act(async () => rollbackButton().click())
|
|
168
|
+
expect(host.querySelector('[role="dialog"]')).not.toBeNull()
|
|
169
|
+
await act(async () => { void client.resetQueries({ queryKey: ['capabilities'] }) })
|
|
170
|
+
await settle()
|
|
171
|
+
expect(rollbackButton().disabled).toBe(true)
|
|
172
|
+
await act(async () => harness.confirm!({ prune: false, dryRun: false }))
|
|
173
|
+
expect(harness.rollback).not.toHaveBeenCalled()
|
|
174
|
+
expect(harness.showError).toHaveBeenCalledWith('Rollback unavailable', "Checking this cluster's Radar…")
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('keeps rollback disabled with check-unavailable copy when capabilities fail', async () => {
|
|
178
|
+
await act(async () => {
|
|
179
|
+
client.getQueryCache().find({ queryKey: ['capabilities'] })!.setState({ status: 'error', error: new Error('offline'), fetchStatus: 'idle' })
|
|
180
|
+
})
|
|
181
|
+
await settle()
|
|
182
|
+
expect(rollbackButton().disabled).toBe(true)
|
|
183
|
+
expect(host.textContent).toContain("Couldn't check this cluster's Radar support. Refresh to try again.")
|
|
184
|
+
expect(host.textContent).not.toContain('need the latest Radar')
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('requires affirmative support before enabling an automated block switched off in place', async () => {
|
|
188
|
+
app.spec.syncPolicy = { automated: { enabled: false } }
|
|
189
|
+
await act(async () => { client.setQueryData(['capabilities'], { features: { argoRollbackSync: true } }) })
|
|
190
|
+
await settle()
|
|
191
|
+
await act(async () => { void client.resetQueries({ queryKey: ['capabilities'] }) })
|
|
192
|
+
await settle()
|
|
193
|
+
const enable = () => [...host.querySelectorAll('button')].find(b => b.textContent === 'Enable auto-sync')!
|
|
194
|
+
expect(enable().disabled).toBe(true)
|
|
195
|
+
await act(async () => harness.onResume!())
|
|
196
|
+
expect(harness.resume).not.toHaveBeenCalled()
|
|
197
|
+
await act(async () => { client.setQueryData(['capabilities'], { features: { argoRollbackSync: true } }) })
|
|
198
|
+
await settle()
|
|
199
|
+
expect(enable().disabled).toBe(false)
|
|
200
|
+
await act(async () => harness.onResume!())
|
|
201
|
+
expect(harness.resume).toHaveBeenCalledOnce()
|
|
202
|
+
})
|