@skyhook-io/radar-app 1.18.2 → 1.20.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/README.md +1 -1
- package/package.json +7 -7
- package/src/App.tsx +31 -6
- 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 +285 -55
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.test.ts +33 -2
- package/src/api/diagnose.ts +97 -3
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +41 -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/diagnose/AIMarkdown.tsx +4 -1
- package/src/components/diagnose/ActivityTurn.tsx +34 -14
- package/src/components/diagnose/AgentControls.tsx +53 -6
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +22 -4
- package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
- package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
- package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
- package/src/components/diagnose/AnalysisStory.tsx +17 -4
- package/src/components/diagnose/AssessmentCard.tsx +39 -8
- 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.capacity.test.tsx +113 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
- package/src/components/diagnose/DiagnoseContext.tsx +272 -10
- package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +151 -134
- package/src/components/diagnose/EvidenceCard.tsx +67 -14
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +208 -5
- package/src/components/diagnose/Home.tsx +187 -36
- package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
- package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +50 -23
- package/src/components/diagnose/InvestigationView.tsx +249 -54
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +365 -39
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
- package/src/components/diagnose/QuestionComposer.tsx +495 -0
- package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
- package/src/components/diagnose/QuestionFocus.tsx +123 -0
- package/src/components/diagnose/ResourcePicker.tsx +206 -0
- package/src/components/diagnose/StoryExcerpt.tsx +12 -3
- package/src/components/diagnose/assessmentCopy.ts +5 -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.runs.test.tsx +328 -0
- package/src/components/diagnose/investigationCase.test.tsx +9 -1
- package/src/components/diagnose/investigationCase.ts +33 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +58 -2
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
- package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
- package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
- package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
- package/src/components/diagnose/investigationEvidence/index.ts +1 -1
- package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -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 +7 -0
- package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
- package/src/components/diagnose/investigationFocus.test.ts +271 -0
- package/src/components/diagnose/investigationFocus.ts +132 -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/parts.test.tsx +20 -0
- package/src/components/diagnose/questionSuggestions.test.ts +111 -0
- package/src/components/diagnose/questionSuggestions.ts +150 -0
- package/src/components/diagnose/storyParts.test.tsx +13 -0
- package/src/components/diagnose/target.test.ts +143 -2
- package/src/components/diagnose/target.ts +109 -7
- package/src/components/diagnose/testdata/story-runs.json +474 -0
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/diagnose/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- 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/home/ClusterHealthCard.tsx +13 -39
- package/src/components/home/HomeAgentBlock.test.tsx +141 -0
- package/src/components/home/HomeAgentBlock.tsx +103 -0
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +86 -47
- package/src/components/home/MCPSetupDialog.test.tsx +95 -5
- package/src/components/home/MCPSetupDialog.tsx +30 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- 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 +23 -10
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +20 -1
- package/src/components/issues/uncheckedSources.ts +18 -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/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
- package/src/components/ui/Omnibar.tsx +47 -3
- package/src/components/ui/RadarOmnibar.test.tsx +1 -0
- package/src/components/ui/RadarOmnibar.tsx +11 -0
- 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 +18 -4
- package/src/components/whats-new/releaseNotes.ts +136 -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 +6 -4
- package/src/hooks/useAgentSignin.test.tsx +190 -0
- package/src/hooks/useAgentSignin.ts +160 -0
- package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
- package/src/hooks/useElementSize.ts +30 -0
- 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 +12 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import type { RunSummary } from "../../api/diagnose";
|
|
6
|
+
import {
|
|
7
|
+
capacityCluster,
|
|
8
|
+
InvestigationCapacityNotice,
|
|
9
|
+
runsHoldingSlots,
|
|
10
|
+
} from "./InvestigationCapacityNotice";
|
|
11
|
+
|
|
12
|
+
function run(
|
|
13
|
+
id: string,
|
|
14
|
+
name: string,
|
|
15
|
+
status: string,
|
|
16
|
+
createdAt: string,
|
|
17
|
+
): RunSummary {
|
|
18
|
+
return {
|
|
19
|
+
id,
|
|
20
|
+
kind: "Deployment",
|
|
21
|
+
group: "apps",
|
|
22
|
+
namespace: "prod",
|
|
23
|
+
name,
|
|
24
|
+
context: "test",
|
|
25
|
+
profile: "safeguarded",
|
|
26
|
+
status,
|
|
27
|
+
createdAt,
|
|
28
|
+
updatedAt: createdAt,
|
|
29
|
+
} as RunSummary;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const capacity = {
|
|
33
|
+
target: { kind: "Pod", group: "", namespace: "shop", name: "cart-0" },
|
|
34
|
+
limit: 3,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const threeRunning = [
|
|
38
|
+
run("c", "checkout", "running", "2026-10-28T10:04:00Z"),
|
|
39
|
+
run("a", "api", "running", "2026-10-28T10:00:00Z"),
|
|
40
|
+
run("done", "old", "completed", "2026-10-28T09:00:00Z"),
|
|
41
|
+
run("b", "billing", "running", "2026-10-28T10:02:00Z"),
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
describe("runsHoldingSlots", () => {
|
|
45
|
+
it("keeps only live runs, longest-running first", () => {
|
|
46
|
+
expect(runsHoldingSlots(threeRunning).map((r) => r.id)).toEqual([
|
|
47
|
+
"a",
|
|
48
|
+
"b",
|
|
49
|
+
"c",
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("capacityCluster", () => {
|
|
55
|
+
it("retries only in the cluster the start was refused in", () => {
|
|
56
|
+
expect(capacityCluster("dev", "dev")).toBe("same");
|
|
57
|
+
expect(capacityCluster("dev", "prod")).toBe("changed");
|
|
58
|
+
// Contexts reloading after a switch: not yet known to be the same.
|
|
59
|
+
expect(capacityCluster("dev", undefined)).toBe("unknown");
|
|
60
|
+
expect(capacityCluster(undefined, "prod")).toBe("same");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe("InvestigationCapacityNotice", () => {
|
|
65
|
+
let container: HTMLDivElement;
|
|
66
|
+
let root: Root;
|
|
67
|
+
const handlers = {
|
|
68
|
+
onOpenRun: vi.fn(),
|
|
69
|
+
onStop: vi.fn(async () => {}),
|
|
70
|
+
onStart: vi.fn(),
|
|
71
|
+
onDismiss: vi.fn(),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
beforeEach(() => {
|
|
75
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
76
|
+
vi.useFakeTimers();
|
|
77
|
+
vi.setSystemTime(new Date("2026-10-28T10:05:00Z"));
|
|
78
|
+
container = document.createElement("div");
|
|
79
|
+
document.body.appendChild(container);
|
|
80
|
+
root = createRoot(container);
|
|
81
|
+
Object.values(handlers).forEach((h) => h.mockClear());
|
|
82
|
+
});
|
|
83
|
+
afterEach(async () => {
|
|
84
|
+
await act(async () => root.unmount());
|
|
85
|
+
container.remove();
|
|
86
|
+
vi.useRealTimers();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const render = (
|
|
90
|
+
runs: RunSummary[],
|
|
91
|
+
{
|
|
92
|
+
runsKnown = true,
|
|
93
|
+
cluster = "same" as "same" | "changed" | "unknown",
|
|
94
|
+
} = {},
|
|
95
|
+
) =>
|
|
96
|
+
act(async () =>
|
|
97
|
+
root.render(
|
|
98
|
+
<InvestigationCapacityNotice
|
|
99
|
+
capacity={capacity}
|
|
100
|
+
runs={runs}
|
|
101
|
+
runsKnown={runsKnown}
|
|
102
|
+
cluster={cluster}
|
|
103
|
+
{...handlers}
|
|
104
|
+
/>,
|
|
105
|
+
),
|
|
106
|
+
);
|
|
107
|
+
const button = (text: string) =>
|
|
108
|
+
[...container.querySelectorAll("button")].find(
|
|
109
|
+
(b) => b.textContent === text || b.getAttribute("aria-label") === text,
|
|
110
|
+
)!;
|
|
111
|
+
|
|
112
|
+
it("says how many are running and lists each with its elapsed time", async () => {
|
|
113
|
+
await render(threeRunning);
|
|
114
|
+
expect(container.textContent).toContain(
|
|
115
|
+
"3 investigations are already running",
|
|
116
|
+
);
|
|
117
|
+
expect(container.textContent).toContain(
|
|
118
|
+
"Stop one to start Pod shop/cart-0",
|
|
119
|
+
);
|
|
120
|
+
const rows = [...container.querySelectorAll("li")].map(
|
|
121
|
+
(li) => li.textContent,
|
|
122
|
+
);
|
|
123
|
+
expect(rows).toHaveLength(3);
|
|
124
|
+
expect(rows[0]).toContain("Deployment prod/api");
|
|
125
|
+
expect(rows[0]).toContain("Started 5m ago");
|
|
126
|
+
expect(rows[2]).toContain("Started 1m ago");
|
|
127
|
+
expect(button("Start investigation").disabled).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("names question-only runs and starts by their question", async () => {
|
|
131
|
+
const asking = {
|
|
132
|
+
...run("q", "", "running", "2026-10-28T10:03:00Z"),
|
|
133
|
+
kind: "",
|
|
134
|
+
group: "",
|
|
135
|
+
namespace: "",
|
|
136
|
+
question: "checkout is slow",
|
|
137
|
+
} as RunSummary;
|
|
138
|
+
await act(async () =>
|
|
139
|
+
root.render(
|
|
140
|
+
<InvestigationCapacityNotice
|
|
141
|
+
capacity={{
|
|
142
|
+
target: {
|
|
143
|
+
kind: "",
|
|
144
|
+
group: "",
|
|
145
|
+
namespace: "",
|
|
146
|
+
name: "",
|
|
147
|
+
question: "why is web timing out",
|
|
148
|
+
},
|
|
149
|
+
limit: 3,
|
|
150
|
+
}}
|
|
151
|
+
runs={[...threeRunning.slice(0, 2), asking]}
|
|
152
|
+
runsKnown
|
|
153
|
+
cluster="same"
|
|
154
|
+
{...handlers}
|
|
155
|
+
/>,
|
|
156
|
+
),
|
|
157
|
+
);
|
|
158
|
+
expect(container.textContent).toContain(
|
|
159
|
+
"Stop one to start “why is web timing out”",
|
|
160
|
+
);
|
|
161
|
+
expect(container.textContent).toContain("checkout is slow");
|
|
162
|
+
expect(button("Stop checkout is slow")).toBeDefined();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("opens and stops the run the user picks", async () => {
|
|
166
|
+
handlers.onStop.mockImplementationOnce(() => new Promise<void>(() => {}));
|
|
167
|
+
await render(threeRunning);
|
|
168
|
+
await act(async () => button("Open").click());
|
|
169
|
+
expect(handlers.onOpenRun).toHaveBeenCalledWith("a");
|
|
170
|
+
await act(async () => button("Stop Deployment prod/billing").click());
|
|
171
|
+
expect(handlers.onStop).toHaveBeenCalledWith("b");
|
|
172
|
+
expect(button("Stop Deployment prod/billing").disabled).toBe(true);
|
|
173
|
+
expect(container.textContent).toContain("Stopping…");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("offers the same start once a slot frees, without starting it itself", async () => {
|
|
177
|
+
await render(threeRunning);
|
|
178
|
+
await render(threeRunning.filter((r) => r.id !== "b"));
|
|
179
|
+
expect(container.textContent).toContain("A slot is free");
|
|
180
|
+
expect(handlers.onStart).not.toHaveBeenCalled();
|
|
181
|
+
const start = button("Start investigation");
|
|
182
|
+
expect(start.disabled).toBe(false);
|
|
183
|
+
await act(async () => start.click());
|
|
184
|
+
expect(handlers.onStart).toHaveBeenCalledTimes(1);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("lets a stop that didn't take be tried again", async () => {
|
|
188
|
+
let fail!: () => void;
|
|
189
|
+
handlers.onStop.mockImplementationOnce(
|
|
190
|
+
() =>
|
|
191
|
+
new Promise<void>((_, reject) => (fail = () => reject(new Error("x")))),
|
|
192
|
+
);
|
|
193
|
+
await render(threeRunning);
|
|
194
|
+
const stop = () => button("Stop Deployment prod/api");
|
|
195
|
+
await act(async () => stop().click());
|
|
196
|
+
expect(stop().disabled).toBe(true);
|
|
197
|
+
await act(async () => fail());
|
|
198
|
+
expect(stop().disabled).toBe(false);
|
|
199
|
+
expect(container.textContent).not.toContain("Stopping…");
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("claims no free slot before the running list is known", async () => {
|
|
203
|
+
await render([], { runsKnown: false });
|
|
204
|
+
expect(container.textContent).toContain(
|
|
205
|
+
"3 investigations are already running",
|
|
206
|
+
);
|
|
207
|
+
expect(container.textContent).toContain(
|
|
208
|
+
"Loading the running investigations",
|
|
209
|
+
);
|
|
210
|
+
// The server decides; the button must not dead-end on missing data.
|
|
211
|
+
expect(button("Start investigation").disabled).toBe(false);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("won't retry a start after the cluster changed", async () => {
|
|
215
|
+
await render(threeRunning, { cluster: "changed" });
|
|
216
|
+
expect(container.textContent).toContain("The cluster changed");
|
|
217
|
+
expect(button("Start investigation")).toBeUndefined();
|
|
218
|
+
await act(async () => button("Dismiss").click());
|
|
219
|
+
expect(handlers.onDismiss).toHaveBeenCalledTimes(1);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("holds the retry until the current cluster is confirmed", async () => {
|
|
223
|
+
await render(
|
|
224
|
+
threeRunning.filter((r) => r.id !== "b"),
|
|
225
|
+
{
|
|
226
|
+
cluster: "unknown",
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
expect(button("Start investigation").disabled).toBe(true);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("says when a stop didn't take", async () => {
|
|
233
|
+
await render(threeRunning);
|
|
234
|
+
await act(async () => button("Stop Deployment prod/api").click());
|
|
235
|
+
// The refreshed list still shows it running.
|
|
236
|
+
await render([...threeRunning]);
|
|
237
|
+
expect(container.textContent).toContain("Radar couldn’t stop it");
|
|
238
|
+
expect(button("Stop Deployment prod/api").disabled).toBe(false);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("cancels the pending start", async () => {
|
|
242
|
+
await render(threeRunning);
|
|
243
|
+
await act(async () => button("Cancel").click());
|
|
244
|
+
expect(handlers.onDismiss).toHaveBeenCalledTimes(1);
|
|
245
|
+
});
|
|
246
|
+
});
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { formatRelativeAgeTime } from "@skyhook-io/k8s-ui/utils/format";
|
|
3
|
+
import { stopRun, type RunSummary } from "../../api/diagnose";
|
|
4
|
+
import { useContexts } from "../../api/client";
|
|
5
|
+
import {
|
|
6
|
+
useDiagnose,
|
|
7
|
+
type StartCapacity,
|
|
8
|
+
type Target,
|
|
9
|
+
} from "./DiagnoseContext";
|
|
10
|
+
import { formatInvestigationTarget, formatInvestigationTitle } from "./target";
|
|
11
|
+
|
|
12
|
+
// The runs holding a slot, oldest first: the order they were started in.
|
|
13
|
+
export function runsHoldingSlots(runs: RunSummary[]): RunSummary[] {
|
|
14
|
+
return runs
|
|
15
|
+
.filter((r) => r.status === "running" || r.status === "stopping")
|
|
16
|
+
.sort(
|
|
17
|
+
(a, b) =>
|
|
18
|
+
new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// A question-only run is named by its question, as in the history.
|
|
23
|
+
function runLabel(run: RunSummary): string {
|
|
24
|
+
return run.name || run.question
|
|
25
|
+
? formatInvestigationTitle(run)
|
|
26
|
+
: run.preview || "Investigation";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function targetLabel(target: Target): string {
|
|
30
|
+
if (target.name) return formatInvestigationTarget(target);
|
|
31
|
+
return target.question
|
|
32
|
+
? `“${formatInvestigationTitle(target)}”`
|
|
33
|
+
: "this investigation";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// A start refused without a cluster name (a host that sends none) has
|
|
37
|
+
// nothing to compare, so it is taken as this one.
|
|
38
|
+
export function capacityCluster(
|
|
39
|
+
refusedIn: string | undefined,
|
|
40
|
+
current: string | undefined,
|
|
41
|
+
): "same" | "changed" | "unknown" {
|
|
42
|
+
if (!refusedIn || current === refusedIn) return "same";
|
|
43
|
+
return current ? "changed" : "unknown";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function without(set: ReadonlySet<string>, id: string): ReadonlySet<string> {
|
|
47
|
+
const next = new Set(set);
|
|
48
|
+
next.delete(id);
|
|
49
|
+
return next;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const SECONDARY_BUTTON =
|
|
53
|
+
"rounded-lg border border-theme-border px-3 py-1.5 text-sm text-theme-text-secondary hover:bg-theme-hover disabled:cursor-not-allowed disabled:opacity-50";
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The start the user asked for was refused because every investigation slot
|
|
57
|
+
* is taken. Lists what holds them, with a way to open or stop each, and
|
|
58
|
+
* starts the same request again once a slot is free. Starting stays a click:
|
|
59
|
+
* it spends an agent run and takes over the panel, and by the time a slot
|
|
60
|
+
* frees the user may be reading one of the others.
|
|
61
|
+
*
|
|
62
|
+
* runsKnown is false until the runs list has loaded, or while it fails: an
|
|
63
|
+
* empty list then says nothing about free slots, so Start stays available
|
|
64
|
+
* and the server decides.
|
|
65
|
+
*
|
|
66
|
+
* cluster compares the cluster the start was refused in with the current
|
|
67
|
+
* one. A retry resolves the same namespace and name against whatever Radar
|
|
68
|
+
* is connected to, so it waits for a confirmed match.
|
|
69
|
+
*/
|
|
70
|
+
export function InvestigationCapacityNotice({
|
|
71
|
+
capacity,
|
|
72
|
+
runs,
|
|
73
|
+
runsKnown,
|
|
74
|
+
cluster,
|
|
75
|
+
onOpenRun,
|
|
76
|
+
onStop,
|
|
77
|
+
onStart,
|
|
78
|
+
onDismiss,
|
|
79
|
+
}: {
|
|
80
|
+
capacity: StartCapacity;
|
|
81
|
+
runs: RunSummary[];
|
|
82
|
+
runsKnown: boolean;
|
|
83
|
+
cluster: "same" | "changed" | "unknown";
|
|
84
|
+
onOpenRun: (id: string) => void;
|
|
85
|
+
onStop: (id: string) => Promise<void>;
|
|
86
|
+
onStart: () => void;
|
|
87
|
+
onDismiss: () => void;
|
|
88
|
+
}) {
|
|
89
|
+
// Runs whose stop request is in flight, then the ones it settled for. The
|
|
90
|
+
// server marks a run stopped before answering, so a settled run the
|
|
91
|
+
// refreshed list still shows running did not stop.
|
|
92
|
+
const [stopping, setStopping] = useState<ReadonlySet<string>>(new Set());
|
|
93
|
+
const [stopSettled, setStopSettled] = useState<ReadonlySet<string>>(
|
|
94
|
+
new Set(),
|
|
95
|
+
);
|
|
96
|
+
const holding = runsHoldingSlots(runs);
|
|
97
|
+
const slotFree = runsKnown && holding.length < capacity.limit;
|
|
98
|
+
const canStart = cluster === "same" && (!runsKnown || slotFree);
|
|
99
|
+
const target = targetLabel(capacity.target);
|
|
100
|
+
|
|
101
|
+
const stop = (id: string) => {
|
|
102
|
+
setStopping((prev) => new Set(prev).add(id));
|
|
103
|
+
setStopSettled((prev) => without(prev, id));
|
|
104
|
+
const settle = () => {
|
|
105
|
+
setStopping((prev) => without(prev, id));
|
|
106
|
+
setStopSettled((prev) => new Set(prev).add(id));
|
|
107
|
+
};
|
|
108
|
+
onStop(id).then(settle, settle);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
if (cluster === "changed") {
|
|
112
|
+
return (
|
|
113
|
+
<div className="flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center">
|
|
114
|
+
<p className="text-sm text-theme-text-secondary">
|
|
115
|
+
{`The cluster changed since you asked to investigate ${target}, so Radar won’t start it here. Open the resource in this cluster to investigate it.`}
|
|
116
|
+
</p>
|
|
117
|
+
<button type="button" onClick={onDismiss} className={SECONDARY_BUTTON}>
|
|
118
|
+
Dismiss
|
|
119
|
+
</button>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div className="flex flex-1 flex-col overflow-y-auto px-4 py-6">
|
|
126
|
+
<div className="mx-auto flex w-full max-w-xl flex-col gap-4">
|
|
127
|
+
<div>
|
|
128
|
+
<h2 className="text-sm font-medium text-theme-text-primary">
|
|
129
|
+
{slotFree
|
|
130
|
+
? "A slot is free"
|
|
131
|
+
: `${capacity.limit} investigations are already running`}
|
|
132
|
+
</h2>
|
|
133
|
+
<p className="mt-1 text-sm text-theme-text-secondary">
|
|
134
|
+
{slotFree
|
|
135
|
+
? `Start ${target} now.`
|
|
136
|
+
: `Radar runs up to ${capacity.limit} at a time. Stop one to start ${target}, or wait for one to finish.`}
|
|
137
|
+
</p>
|
|
138
|
+
</div>
|
|
139
|
+
{!runsKnown ? (
|
|
140
|
+
<p className="text-sm text-theme-text-tertiary">
|
|
141
|
+
Loading the running investigations…
|
|
142
|
+
</p>
|
|
143
|
+
) : holding.length > 0 ? (
|
|
144
|
+
<ul
|
|
145
|
+
aria-label="Running investigations"
|
|
146
|
+
className="divide-y divide-theme-border rounded-lg border border-theme-border"
|
|
147
|
+
>
|
|
148
|
+
{holding.map((run) => {
|
|
149
|
+
const isStopping =
|
|
150
|
+
stopping.has(run.id) || run.status === "stopping";
|
|
151
|
+
const didNotStop =
|
|
152
|
+
!isStopping &&
|
|
153
|
+
stopSettled.has(run.id) &&
|
|
154
|
+
run.status === "running";
|
|
155
|
+
return (
|
|
156
|
+
<li key={run.id} className="flex items-center gap-3 px-3 py-2">
|
|
157
|
+
<div className="min-w-0 flex-1">
|
|
158
|
+
<div className="truncate text-sm text-theme-text-primary">
|
|
159
|
+
{runLabel(run)}
|
|
160
|
+
</div>
|
|
161
|
+
<div className="text-xs text-theme-text-tertiary">
|
|
162
|
+
{isStopping
|
|
163
|
+
? "Stopping…"
|
|
164
|
+
: didNotStop
|
|
165
|
+
? "Still running. Radar couldn’t stop it; try again."
|
|
166
|
+
: `Started ${formatRelativeAgeTime(run.createdAt)}`}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
<button
|
|
170
|
+
type="button"
|
|
171
|
+
onClick={() => onOpenRun(run.id)}
|
|
172
|
+
className={SECONDARY_BUTTON}
|
|
173
|
+
>
|
|
174
|
+
Open
|
|
175
|
+
</button>
|
|
176
|
+
<button
|
|
177
|
+
type="button"
|
|
178
|
+
disabled={isStopping}
|
|
179
|
+
onClick={() => stop(run.id)}
|
|
180
|
+
className={SECONDARY_BUTTON}
|
|
181
|
+
aria-label={`Stop ${runLabel(run)}`}
|
|
182
|
+
>
|
|
183
|
+
Stop
|
|
184
|
+
</button>
|
|
185
|
+
</li>
|
|
186
|
+
);
|
|
187
|
+
})}
|
|
188
|
+
</ul>
|
|
189
|
+
) : null}
|
|
190
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
191
|
+
<button
|
|
192
|
+
type="button"
|
|
193
|
+
disabled={!canStart}
|
|
194
|
+
onClick={onStart}
|
|
195
|
+
className="btn-brand px-3 py-1.5 text-sm"
|
|
196
|
+
>
|
|
197
|
+
Start investigation
|
|
198
|
+
</button>
|
|
199
|
+
<button
|
|
200
|
+
type="button"
|
|
201
|
+
onClick={onDismiss}
|
|
202
|
+
className={SECONDARY_BUTTON}
|
|
203
|
+
>
|
|
204
|
+
Cancel
|
|
205
|
+
</button>
|
|
206
|
+
{cluster === "unknown" ? (
|
|
207
|
+
<span className="text-xs text-theme-text-tertiary">
|
|
208
|
+
Checking which cluster Radar is connected to…
|
|
209
|
+
</span>
|
|
210
|
+
) : null}
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** InvestigationCapacityNotice wired to the investigation state. */
|
|
218
|
+
export function InvestigationCapacityRecovery({
|
|
219
|
+
capacity,
|
|
220
|
+
}: {
|
|
221
|
+
capacity: StartCapacity;
|
|
222
|
+
}) {
|
|
223
|
+
const d = useDiagnose();
|
|
224
|
+
const { data: contexts } = useContexts();
|
|
225
|
+
const current = contexts?.find((c) => c.isCurrent)?.name;
|
|
226
|
+
return (
|
|
227
|
+
<InvestigationCapacityNotice
|
|
228
|
+
capacity={capacity}
|
|
229
|
+
runs={d.runs}
|
|
230
|
+
runsKnown={d.runsLoaded && !d.runsLoadFailed}
|
|
231
|
+
cluster={capacityCluster(capacity.context, current)}
|
|
232
|
+
onOpenRun={d.openRun}
|
|
233
|
+
onStop={async (id) => {
|
|
234
|
+
await stopRun(id);
|
|
235
|
+
await d.refreshRuns();
|
|
236
|
+
}}
|
|
237
|
+
onStart={() => d.openInvestigation(capacity.target)}
|
|
238
|
+
onDismiss={d.dismissError}
|
|
239
|
+
/>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
1
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { act } from "react";
|
|
4
|
+
import { createRoot } from "react-dom/client";
|
|
2
5
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
6
|
|
|
4
7
|
import { InvestigationEvidencePane } from "./InvestigationEvidencePane";
|
|
@@ -621,7 +624,12 @@ describe("story card defaults", () => {
|
|
|
621
624
|
matches: 1,
|
|
622
625
|
row: { kind: "ConfigMap", namespace: "b", name: "config" },
|
|
623
626
|
},
|
|
624
|
-
{
|
|
627
|
+
{
|
|
628
|
+
key: "ConfigMap//missing",
|
|
629
|
+
label: "missing",
|
|
630
|
+
matches: 0,
|
|
631
|
+
row: undefined,
|
|
632
|
+
},
|
|
625
633
|
]);
|
|
626
634
|
// Rows of a namespace-scoped listing omit their namespace: the scope is
|
|
627
635
|
// theirs, and only that namespace satisfies a namespaced citation.
|
|
@@ -749,21 +757,104 @@ describe("story card defaults", () => {
|
|
|
749
757
|
},
|
|
750
758
|
},
|
|
751
759
|
];
|
|
752
|
-
const
|
|
760
|
+
const render = (report: string, items = evidence) =>
|
|
761
|
+
renderToStaticMarkup(
|
|
762
|
+
<InvestigationEvidencePane
|
|
763
|
+
projection={projection}
|
|
764
|
+
investigationCase={resolveInvestigationCase(
|
|
765
|
+
projection,
|
|
766
|
+
{ evidence: items },
|
|
767
|
+
0,
|
|
768
|
+
)}
|
|
769
|
+
story={{ report, evidence: items }}
|
|
770
|
+
collecting={false}
|
|
771
|
+
animateGroupIds={new Set()}
|
|
772
|
+
onViewSource={() => {}}
|
|
773
|
+
onViewActivity={() => {}}
|
|
774
|
+
/>,
|
|
775
|
+
);
|
|
776
|
+
const symptom = render("Memory climbs.\n\n[[radar:evidence=0]]");
|
|
777
|
+
expect(symptom).toContain("data-story-metrics");
|
|
778
|
+
expect(symptom).not.toContain("height:140px");
|
|
779
|
+
const context = [{ ...evidence[0], role: "context" as const }];
|
|
780
|
+
const contextHtml = render(
|
|
781
|
+
"Memory climbs.\n\n[[radar:evidence=0]]",
|
|
782
|
+
context,
|
|
783
|
+
);
|
|
784
|
+
expect(contextHtml).toContain("data-story-metrics");
|
|
785
|
+
expect(contextHtml).toContain("height:140px");
|
|
786
|
+
expect(contextHtml).toContain('aria-expanded="true"');
|
|
787
|
+
expect(contextHtml).not.toContain("data-chart-reading");
|
|
788
|
+
const folded = render(
|
|
789
|
+
"Memory climbs.\n\n[[radar:evidence=0|compact]]",
|
|
790
|
+
context,
|
|
791
|
+
);
|
|
792
|
+
expect(folded).not.toContain("data-story-metrics");
|
|
793
|
+
expect(folded).toContain('aria-expanded="false"');
|
|
794
|
+
expect(folded).toMatch(/data-chart-reading[^>]*>161\.5 Mi?B?/);
|
|
795
|
+
// Agents mark cards compact for the prose's flow, not their weight, so a
|
|
796
|
+
// compact symptom stays open.
|
|
797
|
+
const compactSymptom = render(
|
|
798
|
+
"Memory climbs.\n\n[[radar:evidence=0|compact]]",
|
|
799
|
+
);
|
|
800
|
+
expect(compactSymptom).toContain("data-story-metrics");
|
|
801
|
+
expect(compactSymptom).not.toContain("height:140px");
|
|
802
|
+
// The collapsed preview bounds its height and leaves the chart out.
|
|
803
|
+
expect(
|
|
804
|
+
render("Memory climbs.\n\n[[radar:evidence=0]]\n\nMore after the fold."),
|
|
805
|
+
).not.toContain("data-story-metrics");
|
|
806
|
+
|
|
807
|
+
const container = document.createElement("div");
|
|
808
|
+
document.body.appendChild(container);
|
|
809
|
+
const root = createRoot(container);
|
|
810
|
+
const pane = (report: string, items: DiagnosisEvidenceItem[]) => (
|
|
753
811
|
<InvestigationEvidencePane
|
|
754
812
|
projection={projection}
|
|
755
813
|
investigationCase={resolveInvestigationCase(
|
|
756
814
|
projection,
|
|
757
|
-
{ evidence },
|
|
815
|
+
{ evidence: items },
|
|
758
816
|
0,
|
|
759
817
|
)}
|
|
760
|
-
story={{ report
|
|
818
|
+
story={{ report, evidence: items }}
|
|
761
819
|
collecting={false}
|
|
762
820
|
animateGroupIds={new Set()}
|
|
763
821
|
onViewSource={() => {}}
|
|
764
822
|
onViewActivity={() => {}}
|
|
765
|
-
|
|
823
|
+
/>
|
|
824
|
+
);
|
|
825
|
+
// The story's card comes first; Captured results follows it.
|
|
826
|
+
const header = () =>
|
|
827
|
+
container.querySelector<HTMLButtonElement>("button[aria-expanded]")!;
|
|
828
|
+
act(() =>
|
|
829
|
+
root.render(
|
|
830
|
+
pane("Memory climbs.\n\n[[radar:evidence=0|compact]]", context),
|
|
831
|
+
),
|
|
832
|
+
);
|
|
833
|
+
expect(container.querySelector("[data-story-metrics]")).toBeNull();
|
|
834
|
+
act(() => header().click());
|
|
835
|
+
expect(header().getAttribute("aria-expanded")).toBe("true");
|
|
836
|
+
expect(container.querySelector("[data-story-metrics]")).not.toBeNull();
|
|
837
|
+
expect(container.querySelector("[data-chart-reading]")).toBeNull();
|
|
838
|
+
act(() => header().click());
|
|
839
|
+
expect(header().getAttribute("aria-expanded")).toBe("false");
|
|
840
|
+
expect(container.querySelector("[data-chart-reading]")).not.toBeNull();
|
|
841
|
+
act(() =>
|
|
842
|
+
root.render(
|
|
843
|
+
pane(
|
|
844
|
+
"Memory climbs.\n\n[[radar:evidence=0|compact]]\n\nSee [[radar:evidence=0]] again.",
|
|
845
|
+
context,
|
|
846
|
+
),
|
|
847
|
+
),
|
|
766
848
|
);
|
|
767
|
-
|
|
849
|
+
act(() => header().click());
|
|
850
|
+
expect(container.querySelector("[data-chart-reading]")).not.toBeNull();
|
|
851
|
+
const reference = container.querySelector<HTMLButtonElement>(
|
|
852
|
+
"[data-story-ref-direction]",
|
|
853
|
+
)!;
|
|
854
|
+
Element.prototype.scrollIntoView ??= () => {};
|
|
855
|
+
act(() => reference.click());
|
|
856
|
+
expect(header().getAttribute("aria-expanded")).toBe("true");
|
|
857
|
+
act(() => root.unmount());
|
|
858
|
+
container.remove();
|
|
768
859
|
});
|
|
769
860
|
});
|
|
@@ -2802,6 +2802,63 @@ describe("cited broader cards and coverage rows", () => {
|
|
|
2802
2802
|
expect(render(projection)).toContain(
|
|
2803
2803
|
"4 results about other resources are not shown; they appear here when the assessment cites them.",
|
|
2804
2804
|
);
|
|
2805
|
+
// A question with no resource has no "other" resource to speak of.
|
|
2806
|
+
expect(
|
|
2807
|
+
renderToStaticMarkup(
|
|
2808
|
+
<InvestigationEvidencePane
|
|
2809
|
+
projection={projection}
|
|
2810
|
+
collecting={false}
|
|
2811
|
+
animateGroupIds={new Set()}
|
|
2812
|
+
onViewSource={onViewSource}
|
|
2813
|
+
onViewActivity={() => {}}
|
|
2814
|
+
withoutTarget
|
|
2815
|
+
/>,
|
|
2816
|
+
),
|
|
2817
|
+
).toContain(
|
|
2818
|
+
"4 results the assessment didn’t cite are not shown; they appear here when the assessment cites them.",
|
|
2819
|
+
);
|
|
2820
|
+
// Before there is an assessment nothing has been passed over yet.
|
|
2821
|
+
expect(
|
|
2822
|
+
renderToStaticMarkup(
|
|
2823
|
+
<InvestigationEvidencePane
|
|
2824
|
+
projection={projection}
|
|
2825
|
+
collecting
|
|
2826
|
+
animateGroupIds={new Set()}
|
|
2827
|
+
onViewSource={onViewSource}
|
|
2828
|
+
onViewActivity={() => {}}
|
|
2829
|
+
withoutTarget
|
|
2830
|
+
assessmentPending
|
|
2831
|
+
/>,
|
|
2832
|
+
),
|
|
2833
|
+
).toContain(
|
|
2834
|
+
"4 results are held for the assessment; the ones it cites appear here.",
|
|
2835
|
+
);
|
|
2836
|
+
// A run that stopped without one will never cite anything: show it all.
|
|
2837
|
+
const stopped = partitionInvestigationEvidence(
|
|
2838
|
+
projection.groups,
|
|
2839
|
+
undefined,
|
|
2840
|
+
undefined,
|
|
2841
|
+
false,
|
|
2842
|
+
true,
|
|
2843
|
+
);
|
|
2844
|
+
expect(stopped.hiddenBroader).toBe(0);
|
|
2845
|
+
expect(stopped.main.length + stopped.workload.length).toBe(4);
|
|
2846
|
+
const stoppedMarkup = renderToStaticMarkup(
|
|
2847
|
+
<InvestigationEvidencePane
|
|
2848
|
+
projection={projection}
|
|
2849
|
+
collecting={false}
|
|
2850
|
+
animateGroupIds={new Set()}
|
|
2851
|
+
onViewSource={onViewSource}
|
|
2852
|
+
onViewActivity={() => {}}
|
|
2853
|
+
withoutTarget
|
|
2854
|
+
assessmentPending
|
|
2855
|
+
showUncited
|
|
2856
|
+
/>,
|
|
2857
|
+
);
|
|
2858
|
+
expect(stoppedMarkup).not.toContain("not shown");
|
|
2859
|
+
expect(stoppedMarkup).toContain("Evidence collected");
|
|
2860
|
+
expect(stoppedMarkup).not.toContain("about this resource");
|
|
2861
|
+
expect(stoppedMarkup).not.toContain("No relevant evidence");
|
|
2805
2862
|
|
|
2806
2863
|
const resolution = resolveInvestigationRootCauseEvidence(
|
|
2807
2864
|
projection,
|