@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,553 @@
|
|
|
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
|
+
|
|
6
|
+
import type { QuestionDraft } from "./DiagnoseContext";
|
|
7
|
+
import { QuestionComposer } from "./QuestionComposer";
|
|
8
|
+
|
|
9
|
+
const state = vi.hoisted(() => ({
|
|
10
|
+
openInvestigation: vi.fn(),
|
|
11
|
+
saveQuestionDraft: vi.fn(),
|
|
12
|
+
questionDraft: null as null | QuestionDraft,
|
|
13
|
+
actives: ["shop"],
|
|
14
|
+
issues: [] as unknown[],
|
|
15
|
+
pinIssues: [] as unknown[],
|
|
16
|
+
searchHits: [] as unknown[],
|
|
17
|
+
searchError: false,
|
|
18
|
+
searchCoverage: undefined as unknown,
|
|
19
|
+
context: "cluster-a",
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
vi.mock("@skyhook-io/k8s-ui", async (importOriginal) => ({
|
|
23
|
+
...(await importOriginal<object>()),
|
|
24
|
+
useDebouncedValue: <T,>(value: T) => value,
|
|
25
|
+
}));
|
|
26
|
+
vi.mock("./DiagnoseContext", () => ({
|
|
27
|
+
useDiagnose: () => ({
|
|
28
|
+
openInvestigation: state.openInvestigation,
|
|
29
|
+
agentLabel: "Claude Code",
|
|
30
|
+
questionDraft: state.questionDraft,
|
|
31
|
+
saveQuestionDraft: state.saveQuestionDraft,
|
|
32
|
+
}),
|
|
33
|
+
}));
|
|
34
|
+
vi.mock("../../api/client", () => ({
|
|
35
|
+
useNamespaceScope: () => ({
|
|
36
|
+
data: { actives: state.actives, accessibleNamespaces: ["shop", "web"] },
|
|
37
|
+
}),
|
|
38
|
+
useIssues: () => ({ data: { issues: state.issues } }),
|
|
39
|
+
useResourceIssues: () => ({ data: state.pinIssues }),
|
|
40
|
+
useContexts: () => ({
|
|
41
|
+
data: [{ name: state.context, isCurrent: true }],
|
|
42
|
+
}),
|
|
43
|
+
useSearch: () => ({
|
|
44
|
+
data: state.searchError
|
|
45
|
+
? undefined
|
|
46
|
+
: { hits: state.searchHits, coverage: state.searchCoverage },
|
|
47
|
+
isFetching: false,
|
|
48
|
+
isPlaceholderData: false,
|
|
49
|
+
isError: state.searchError,
|
|
50
|
+
refetch: vi.fn(),
|
|
51
|
+
}),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
55
|
+
let root: Root;
|
|
56
|
+
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
state.openInvestigation.mockReset();
|
|
59
|
+
state.saveQuestionDraft.mockReset();
|
|
60
|
+
state.questionDraft = null;
|
|
61
|
+
state.issues = [];
|
|
62
|
+
state.pinIssues = [];
|
|
63
|
+
state.searchHits = [];
|
|
64
|
+
state.searchError = false;
|
|
65
|
+
state.searchCoverage = undefined;
|
|
66
|
+
state.context = "cluster-a";
|
|
67
|
+
state.actives = ["shop"];
|
|
68
|
+
const element = document.createElement("div");
|
|
69
|
+
document.body.appendChild(element);
|
|
70
|
+
root = createRoot(element);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
afterEach(async () => {
|
|
74
|
+
await act(async () => root.unmount());
|
|
75
|
+
document.body.replaceChildren();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
async function render() {
|
|
79
|
+
await act(async () => root.render(<QuestionComposer />));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function textarea() {
|
|
83
|
+
return document.querySelector("textarea")!;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function type(value: string) {
|
|
87
|
+
const setter = Object.getOwnPropertyDescriptor(
|
|
88
|
+
HTMLTextAreaElement.prototype,
|
|
89
|
+
"value",
|
|
90
|
+
)!.set!;
|
|
91
|
+
await act(async () => {
|
|
92
|
+
setter.call(textarea(), value);
|
|
93
|
+
textarea().dispatchEvent(new Event("input", { bubbles: true }));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function press(key: string) {
|
|
98
|
+
await act(async () => {
|
|
99
|
+
textarea().dispatchEvent(
|
|
100
|
+
new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true }),
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
describe("QuestionComposer", () => {
|
|
106
|
+
it("starts a question-only run where the namespace picker points", async () => {
|
|
107
|
+
await render();
|
|
108
|
+
await type(" checkout returns 502s ");
|
|
109
|
+
await press("Enter");
|
|
110
|
+
expect(state.openInvestigation).toHaveBeenCalledWith({
|
|
111
|
+
kind: "",
|
|
112
|
+
group: "",
|
|
113
|
+
namespace: "",
|
|
114
|
+
name: "",
|
|
115
|
+
question: "checkout returns 502s",
|
|
116
|
+
namespaces: ["shop"],
|
|
117
|
+
lookBack: "1h",
|
|
118
|
+
askedAt: undefined,
|
|
119
|
+
fromComposer: true,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("does nothing without words", async () => {
|
|
124
|
+
await render();
|
|
125
|
+
await type(" ");
|
|
126
|
+
await press("Enter");
|
|
127
|
+
expect(state.openInvestigation).not.toHaveBeenCalled();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("opens the resource picker on @ instead of typing it", async () => {
|
|
131
|
+
await render();
|
|
132
|
+
await press("@");
|
|
133
|
+
const pinButton = [...document.querySelectorAll("button")].find((b) =>
|
|
134
|
+
b.textContent?.includes("Pin a resource"),
|
|
135
|
+
);
|
|
136
|
+
expect(pinButton?.getAttribute("aria-expanded")).toBe("true");
|
|
137
|
+
expect(textarea().value).toBe("");
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("holds a question longer than Radar accepts", async () => {
|
|
141
|
+
state.questionDraft = { seq: 1, text: "x".repeat(2001) };
|
|
142
|
+
await render();
|
|
143
|
+
await press("Enter");
|
|
144
|
+
expect(state.openInvestigation).not.toHaveBeenCalled();
|
|
145
|
+
expect(document.body.textContent).toContain("this one has 2001");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("types an @ inside a word as text", async () => {
|
|
149
|
+
await render();
|
|
150
|
+
await type("page oncall");
|
|
151
|
+
await press("@");
|
|
152
|
+
const pinButton = [...document.querySelectorAll("button")].find((b) =>
|
|
153
|
+
b.textContent?.includes("Pin a resource"),
|
|
154
|
+
);
|
|
155
|
+
expect(pinButton?.getAttribute("aria-expanded")).toBe("false");
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("lands in the box when a hand-off mounts it", async () => {
|
|
159
|
+
state.questionDraft = { seq: 4, text: "catalog latency spiked" };
|
|
160
|
+
await render();
|
|
161
|
+
expect(document.activeElement).toBe(textarea());
|
|
162
|
+
expect(textarea().selectionStart).toBe("catalog latency spiked".length);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("keeps the words when a resource is handed over without any", async () => {
|
|
166
|
+
await render();
|
|
167
|
+
await type("memory keeps climbing");
|
|
168
|
+
state.questionDraft = {
|
|
169
|
+
seq: 2,
|
|
170
|
+
pin: {
|
|
171
|
+
kind: "Deployment",
|
|
172
|
+
group: "apps",
|
|
173
|
+
namespace: "shop",
|
|
174
|
+
name: "api",
|
|
175
|
+
},
|
|
176
|
+
keepWords: true,
|
|
177
|
+
};
|
|
178
|
+
await render();
|
|
179
|
+
expect(textarea().value).toBe("memory keeps climbing");
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("asks about a handed-off resource instead of the namespaces", async () => {
|
|
183
|
+
state.questionDraft = {
|
|
184
|
+
seq: 1,
|
|
185
|
+
pin: {
|
|
186
|
+
kind: "Deployment",
|
|
187
|
+
group: "apps",
|
|
188
|
+
namespace: "shop",
|
|
189
|
+
name: "api",
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
await render();
|
|
193
|
+
expect(document.body.textContent).toContain("Deployment shop/api");
|
|
194
|
+
await type("why did it restart?");
|
|
195
|
+
await press("Enter");
|
|
196
|
+
expect(state.openInvestigation).toHaveBeenCalledWith(
|
|
197
|
+
expect.objectContaining({
|
|
198
|
+
kind: "Deployment",
|
|
199
|
+
name: "api",
|
|
200
|
+
question: "why did it restart?",
|
|
201
|
+
namespaces: [],
|
|
202
|
+
}),
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("suggests only from live issues", async () => {
|
|
207
|
+
await render();
|
|
208
|
+
expect(document.body.textContent).not.toContain("From what Radar sees now");
|
|
209
|
+
state.issues = [
|
|
210
|
+
{
|
|
211
|
+
id: "i",
|
|
212
|
+
severity: "critical",
|
|
213
|
+
source: "problem",
|
|
214
|
+
category: "crashloop",
|
|
215
|
+
category_group: "runtime",
|
|
216
|
+
grouping_scope: "workload",
|
|
217
|
+
kind: "Deployment",
|
|
218
|
+
group: "apps",
|
|
219
|
+
namespace: "shop",
|
|
220
|
+
name: "api",
|
|
221
|
+
reason: "CrashLoopBackOff",
|
|
222
|
+
},
|
|
223
|
+
];
|
|
224
|
+
await render();
|
|
225
|
+
expect(document.body.textContent).toContain("From what Radar sees now");
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("suggests from the pinned resource's own issues", async () => {
|
|
229
|
+
state.questionDraft = {
|
|
230
|
+
seq: 1,
|
|
231
|
+
pin: {
|
|
232
|
+
kind: "Deployment",
|
|
233
|
+
group: "apps",
|
|
234
|
+
namespace: "shop",
|
|
235
|
+
name: "api",
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
state.issues = [
|
|
239
|
+
{
|
|
240
|
+
id: "elsewhere",
|
|
241
|
+
severity: "critical",
|
|
242
|
+
source: "problem",
|
|
243
|
+
category: "crashloop",
|
|
244
|
+
category_group: "runtime",
|
|
245
|
+
grouping_scope: "workload",
|
|
246
|
+
kind: "Deployment",
|
|
247
|
+
group: "apps",
|
|
248
|
+
namespace: "other",
|
|
249
|
+
name: "x",
|
|
250
|
+
reason: "CrashLoopBackOff",
|
|
251
|
+
},
|
|
252
|
+
];
|
|
253
|
+
state.pinIssues = [
|
|
254
|
+
{
|
|
255
|
+
id: "np",
|
|
256
|
+
severity: "warning",
|
|
257
|
+
source: "problem",
|
|
258
|
+
category: "network_policy_denies",
|
|
259
|
+
category_group: "networking",
|
|
260
|
+
grouping_scope: "workload",
|
|
261
|
+
kind: "NetworkPolicy",
|
|
262
|
+
group: "networking.k8s.io",
|
|
263
|
+
namespace: "shop",
|
|
264
|
+
name: "deny-all",
|
|
265
|
+
reason: "DenyAll",
|
|
266
|
+
},
|
|
267
|
+
];
|
|
268
|
+
await render();
|
|
269
|
+
const text = document.body.textContent ?? "";
|
|
270
|
+
expect(text).toContain("NetworkPolicy shop/deny-all");
|
|
271
|
+
expect(text).not.toContain("other/x");
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it("gives back unsent words when it unmounts", async () => {
|
|
275
|
+
await render();
|
|
276
|
+
await type("half a question");
|
|
277
|
+
await act(async () => root.render(<></>));
|
|
278
|
+
expect(state.saveQuestionDraft).toHaveBeenLastCalledWith(
|
|
279
|
+
expect.objectContaining({ text: "half a question" }),
|
|
280
|
+
);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("starts from a saved draft without treating it as a new hand-off", async () => {
|
|
284
|
+
state.questionDraft = { seq: 3, text: "where I left off", lookBack: "6h" };
|
|
285
|
+
await render();
|
|
286
|
+
expect(textarea().value).toBe("where I left off");
|
|
287
|
+
expect(document.querySelector('[aria-pressed="true"]')?.textContent).toBe(
|
|
288
|
+
"6h",
|
|
289
|
+
);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it("hands a submitted question to its start, not the draft", async () => {
|
|
293
|
+
await render();
|
|
294
|
+
await type("question A");
|
|
295
|
+
await press("Enter");
|
|
296
|
+
await act(async () => root.render(<></>));
|
|
297
|
+
expect(state.saveQuestionDraft).toHaveBeenLastCalledWith({});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it("does not let a returned question overwrite newer words", async () => {
|
|
301
|
+
await render();
|
|
302
|
+
await type("question B");
|
|
303
|
+
state.questionDraft = { seq: 2, text: "question A", restore: true };
|
|
304
|
+
await render();
|
|
305
|
+
expect(textarea().value).toBe("question B");
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("keeps when a handed-over question was first asked until it is edited", async () => {
|
|
309
|
+
state.questionDraft = {
|
|
310
|
+
seq: 1,
|
|
311
|
+
text: "checkout 502s",
|
|
312
|
+
askedAt: "2026-10-27T09:00:00Z",
|
|
313
|
+
};
|
|
314
|
+
await render();
|
|
315
|
+
await press("Enter");
|
|
316
|
+
expect(state.openInvestigation).toHaveBeenLastCalledWith(
|
|
317
|
+
expect.objectContaining({ askedAt: "2026-10-27T09:00:00Z" }),
|
|
318
|
+
);
|
|
319
|
+
await type("checkout 502s again");
|
|
320
|
+
await press("Enter");
|
|
321
|
+
expect(state.openInvestigation).toHaveBeenLastCalledWith(
|
|
322
|
+
expect.objectContaining({ askedAt: undefined }),
|
|
323
|
+
);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("opens the picker when asked to choose a resource", async () => {
|
|
327
|
+
state.questionDraft = { seq: 1, text: "why?", pickResource: true };
|
|
328
|
+
await render();
|
|
329
|
+
expect(
|
|
330
|
+
document.querySelector(
|
|
331
|
+
'input[aria-label="Search for a resource to pin"]',
|
|
332
|
+
),
|
|
333
|
+
).not.toBeNull();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it("tells a custom kind from the built-in one it shadows", async () => {
|
|
337
|
+
state.searchHits = [
|
|
338
|
+
{ score: 2, kind: "Service", group: "", namespace: "shop", name: "api" },
|
|
339
|
+
{
|
|
340
|
+
score: 1,
|
|
341
|
+
kind: "Service",
|
|
342
|
+
group: "serving.knative.dev",
|
|
343
|
+
namespace: "shop",
|
|
344
|
+
name: "api",
|
|
345
|
+
},
|
|
346
|
+
];
|
|
347
|
+
await render();
|
|
348
|
+
await press("@");
|
|
349
|
+
const input = document.querySelector<HTMLInputElement>(
|
|
350
|
+
'input[aria-label="Search for a resource to pin"]',
|
|
351
|
+
)!;
|
|
352
|
+
const setter = Object.getOwnPropertyDescriptor(
|
|
353
|
+
HTMLInputElement.prototype,
|
|
354
|
+
"value",
|
|
355
|
+
)!.set!;
|
|
356
|
+
await act(async () => {
|
|
357
|
+
setter.call(input, "api");
|
|
358
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
359
|
+
});
|
|
360
|
+
const labels = [...document.querySelectorAll('[role="option"]')].map(
|
|
361
|
+
(option) => option.textContent,
|
|
362
|
+
);
|
|
363
|
+
expect(labels).toEqual([
|
|
364
|
+
expect.stringContaining("Service · shop"),
|
|
365
|
+
expect.stringContaining("Service.serving.knative.dev · shop"),
|
|
366
|
+
]);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("pins the highlighted search result with the keyboard", async () => {
|
|
370
|
+
state.searchHits = [
|
|
371
|
+
{
|
|
372
|
+
score: 2,
|
|
373
|
+
kind: "Deployment",
|
|
374
|
+
group: "apps",
|
|
375
|
+
namespace: "shop",
|
|
376
|
+
name: "api",
|
|
377
|
+
},
|
|
378
|
+
{ score: 1, kind: "Service", group: "", namespace: "shop", name: "api" },
|
|
379
|
+
];
|
|
380
|
+
await render();
|
|
381
|
+
await press("@");
|
|
382
|
+
const input = document.querySelector<HTMLInputElement>(
|
|
383
|
+
'input[aria-label="Search for a resource to pin"]',
|
|
384
|
+
)!;
|
|
385
|
+
const setter = Object.getOwnPropertyDescriptor(
|
|
386
|
+
HTMLInputElement.prototype,
|
|
387
|
+
"value",
|
|
388
|
+
)!.set!;
|
|
389
|
+
await act(async () => {
|
|
390
|
+
setter.call(input, "api");
|
|
391
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
392
|
+
});
|
|
393
|
+
const key = (k: string) =>
|
|
394
|
+
act(async () => {
|
|
395
|
+
input.dispatchEvent(
|
|
396
|
+
new KeyboardEvent("keydown", {
|
|
397
|
+
key: k,
|
|
398
|
+
bubbles: true,
|
|
399
|
+
cancelable: true,
|
|
400
|
+
}),
|
|
401
|
+
);
|
|
402
|
+
});
|
|
403
|
+
await key("ArrowDown");
|
|
404
|
+
expect(
|
|
405
|
+
document.querySelector('[role="option"][aria-selected="true"]')
|
|
406
|
+
?.textContent,
|
|
407
|
+
).toContain("Service");
|
|
408
|
+
await key("Enter");
|
|
409
|
+
expect(document.body.textContent).toContain("Service shop/api");
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it("starts across the cluster when more namespaces are picked than a run takes", async () => {
|
|
413
|
+
state.actives = Array.from({ length: 21 }, (_, i) => `ns-${i}`);
|
|
414
|
+
await render();
|
|
415
|
+
expect(document.body.textContent).toContain("All namespaces (21 selected)");
|
|
416
|
+
await type("why?");
|
|
417
|
+
await press("Enter");
|
|
418
|
+
expect(state.openInvestigation).toHaveBeenLastCalledWith(
|
|
419
|
+
expect.objectContaining({ namespaces: [] }),
|
|
420
|
+
);
|
|
421
|
+
state.actives = ["shop"];
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it("does not suggest what is already asked", async () => {
|
|
425
|
+
state.issues = [
|
|
426
|
+
{
|
|
427
|
+
id: "i",
|
|
428
|
+
severity: "critical",
|
|
429
|
+
source: "problem",
|
|
430
|
+
category: "crashloop",
|
|
431
|
+
category_group: "runtime",
|
|
432
|
+
grouping_scope: "workload",
|
|
433
|
+
kind: "Deployment",
|
|
434
|
+
group: "apps",
|
|
435
|
+
namespace: "shop",
|
|
436
|
+
name: "api",
|
|
437
|
+
reason: "CrashLoopBackOff",
|
|
438
|
+
},
|
|
439
|
+
];
|
|
440
|
+
// The pinned resource reports the same problem it was suggested for.
|
|
441
|
+
state.pinIssues = state.issues;
|
|
442
|
+
await render();
|
|
443
|
+
const suggestions = () =>
|
|
444
|
+
[...document.querySelectorAll("button")].filter((b) =>
|
|
445
|
+
b.getAttribute("aria-label")?.startsWith("Critical: Crash loop"),
|
|
446
|
+
);
|
|
447
|
+
const [suggestion] = suggestions();
|
|
448
|
+
expect(suggestion.textContent).toContain("Deployment shop/api");
|
|
449
|
+
await act(async () => suggestion.click());
|
|
450
|
+
expect(textarea().value).toBe("What's causing “Crash loop”?");
|
|
451
|
+
expect(document.body.textContent).toContain("About");
|
|
452
|
+
expect(suggestions()).toHaveLength(0);
|
|
453
|
+
// Still hidden once the engineer adds what they saw.
|
|
454
|
+
await type("What's causing “Crash loop”? Since the 2pm deploy.");
|
|
455
|
+
expect(suggestions()).toHaveLength(0);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it("keeps the engineer's own words when a suggestion is chosen", async () => {
|
|
459
|
+
state.issues = [
|
|
460
|
+
{
|
|
461
|
+
id: "i",
|
|
462
|
+
severity: "critical",
|
|
463
|
+
source: "problem",
|
|
464
|
+
category: "crashloop",
|
|
465
|
+
category_group: "runtime",
|
|
466
|
+
grouping_scope: "workload",
|
|
467
|
+
kind: "Deployment",
|
|
468
|
+
group: "apps",
|
|
469
|
+
namespace: "shop",
|
|
470
|
+
name: "api",
|
|
471
|
+
reason: "CrashLoopBackOff",
|
|
472
|
+
},
|
|
473
|
+
];
|
|
474
|
+
await render();
|
|
475
|
+
await type("api restarts every few minutes since the deploy");
|
|
476
|
+
const [suggestion] = [...document.querySelectorAll("button")].filter((b) =>
|
|
477
|
+
b.getAttribute("aria-label")?.startsWith("Critical: Crash loop"),
|
|
478
|
+
);
|
|
479
|
+
expect(suggestion.getAttribute("aria-label")).toContain(
|
|
480
|
+
"Pins it to your question.",
|
|
481
|
+
);
|
|
482
|
+
await act(async () => suggestion.click());
|
|
483
|
+
expect(textarea().value).toBe(
|
|
484
|
+
"api restarts every few minutes since the deploy",
|
|
485
|
+
);
|
|
486
|
+
expect(document.body.textContent).toContain("Deployment shop/api");
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it("says a failed resource search failed instead of finding nothing", async () => {
|
|
490
|
+
state.searchError = true;
|
|
491
|
+
await render();
|
|
492
|
+
await press("@");
|
|
493
|
+
const input = document.querySelector<HTMLInputElement>(
|
|
494
|
+
'input[aria-label="Search for a resource to pin"]',
|
|
495
|
+
)!;
|
|
496
|
+
const setter = Object.getOwnPropertyDescriptor(
|
|
497
|
+
HTMLInputElement.prototype,
|
|
498
|
+
"value",
|
|
499
|
+
)!.set!;
|
|
500
|
+
await act(async () => {
|
|
501
|
+
setter.call(input, "api");
|
|
502
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
503
|
+
});
|
|
504
|
+
expect(document.body.textContent).toContain("Couldn’t search resources.");
|
|
505
|
+
expect(document.body.textContent).not.toContain("No matching resources.");
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
it("clears a pin chosen in another cluster but keeps the words", async () => {
|
|
509
|
+
state.questionDraft = {
|
|
510
|
+
seq: 1,
|
|
511
|
+
text: "why is it slow?",
|
|
512
|
+
pin: {
|
|
513
|
+
kind: "Deployment",
|
|
514
|
+
group: "apps",
|
|
515
|
+
namespace: "shop",
|
|
516
|
+
name: "api",
|
|
517
|
+
},
|
|
518
|
+
context: "cluster-a",
|
|
519
|
+
};
|
|
520
|
+
await render();
|
|
521
|
+
expect(document.body.textContent).toContain("Deployment shop/api");
|
|
522
|
+
state.context = "cluster-b";
|
|
523
|
+
await render();
|
|
524
|
+
expect(document.body.textContent).not.toContain("Deployment shop/api");
|
|
525
|
+
expect(document.body.textContent).toContain("The cluster changed");
|
|
526
|
+
expect(textarea().value).toBe("why is it slow?");
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
it("says a search is still loading while kinds sync", async () => {
|
|
530
|
+
state.searchCoverage = {
|
|
531
|
+
status: "partial",
|
|
532
|
+
scope: { namespaces: { count: 0 } },
|
|
533
|
+
read: { namespaces: { count: 0 } },
|
|
534
|
+
gaps: [
|
|
535
|
+
{ code: "kind_sync_pending", kind: "Widget", group: "example.com" },
|
|
536
|
+
],
|
|
537
|
+
};
|
|
538
|
+
await render();
|
|
539
|
+
await press("@");
|
|
540
|
+
const input = document.querySelector<HTMLInputElement>(
|
|
541
|
+
'input[aria-label="Search for a resource to pin"]',
|
|
542
|
+
)!;
|
|
543
|
+
const setter = Object.getOwnPropertyDescriptor(
|
|
544
|
+
HTMLInputElement.prototype,
|
|
545
|
+
"value",
|
|
546
|
+
)!.set!;
|
|
547
|
+
await act(async () => {
|
|
548
|
+
setter.call(input, "widget");
|
|
549
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
550
|
+
});
|
|
551
|
+
expect(document.body.textContent).toContain("Still loading");
|
|
552
|
+
});
|
|
553
|
+
});
|