@skyhook-io/radar-app 1.22.2 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +35 -10
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +122 -24
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +315 -0
- package/src/api/workloadSource.ts +128 -12
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +3 -3
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +4 -4
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +52 -13
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter, useLocation } from 'react-router-dom'
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
7
|
+
import { ApiError } from '../../api/client'
|
|
8
|
+
import { useVulnerabilities, vulnerabilitiesPath, type VulnerabilitiesResponse } from '../../api/vulnerabilities'
|
|
9
|
+
import { daysSince, isoDate } from '../vulnerabilities/columns'
|
|
10
|
+
import { VulnerabilitiesView } from './VulnerabilitiesView'
|
|
11
|
+
|
|
12
|
+
// Whether this Radar has the CSV export, which puts the Download items in the menu.
|
|
13
|
+
const feature = vi.hoisted(() => ({ exportSupport: 'unsupported' }))
|
|
14
|
+
vi.mock('../../api/client', async (importOriginal) => ({
|
|
15
|
+
...await importOriginal<typeof import('../../api/client')>(),
|
|
16
|
+
useCapabilities: () => ({ data: { features: {} } }),
|
|
17
|
+
useRadarFeature: () => ({ support: feature.exportSupport, guard: <T,>(fn: () => T) => fn() }),
|
|
18
|
+
}))
|
|
19
|
+
vi.mock('../../api/apiResources', () => ({ useAPIResources: () => ({ data: [{ group: 'aquasecurity.github.io', name: 'vulnerabilityreports' }] }) }))
|
|
20
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { context: 'test', clusterName: 'test', state: 'connected' } }) }))
|
|
21
|
+
vi.mock('../../hooks/useDesktopDownload', () => ({ useDesktopDownload: () => undefined }))
|
|
22
|
+
vi.mock('./ChecksViewTabs', () => ({ ChecksViewTabs: () => null }))
|
|
23
|
+
vi.mock('../../api/vulnerabilities', async (importOriginal) => ({
|
|
24
|
+
...await importOriginal<typeof import('../../api/vulnerabilities')>(),
|
|
25
|
+
useVulnerabilities: vi.fn(),
|
|
26
|
+
}))
|
|
27
|
+
|
|
28
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
29
|
+
|
|
30
|
+
const zero = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0 }
|
|
31
|
+
|
|
32
|
+
// eolCount null is an older Radar, which sends no end-of-life count.
|
|
33
|
+
function response(view: VulnerabilitiesResponse['view'], eolCount: number | null): VulnerabilitiesResponse {
|
|
34
|
+
return {
|
|
35
|
+
source: 'trivy-operator',
|
|
36
|
+
view,
|
|
37
|
+
summary: { imagesScanned: 1, imagesClean: 0, imagesUnscanned: 0, imagesWithCritical: 1, fixableCriticalHighCves: 1, workloadsWithCriticalOrHigh: 1, workloads: 1, counts: { ...zero, critical: 1 }, ...(eolCount === null ? {} : { imagesOsEndOfLife: eolCount }) },
|
|
38
|
+
coverage: { complete: true, gaps: [], inactiveReports: 0 },
|
|
39
|
+
images: [{
|
|
40
|
+
id: 'img', image: 'nginx:1.19.0', digest: 'sha256:4f8c3a1b2d', os: 'debian 10.4', osEndOfLife: true, scanner: { name: 'Trivy', version: '0.76.1' }, scannedAt: '2026-11-20T12:00:00Z',
|
|
41
|
+
counts: { ...zero, critical: 1 }, fixable: { ...zero, critical: 1 }, matching: 1, workloads: [], workloadsTotal: 0, findingsTotal: 1,
|
|
42
|
+
findings: [{ id: 'CVE-1', severity: 'critical', package: 'openssl', installedVersion: '1.1', packageUrl: 'pkg:deb/debian/openssl@1.1' }],
|
|
43
|
+
report: { kind: 'VulnerabilityReport', namespace: 'shop', name: 'r' },
|
|
44
|
+
}],
|
|
45
|
+
cves: [{ id: 'CVE-1', severity: 'critical', packages: ['openssl'], fixable: true, fixableImages: 1, images: 1, workloads: 1, publishedAt: '2020-12-10T04:15:11Z', affected: [] }],
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let container: HTMLDivElement
|
|
50
|
+
let root: Root
|
|
51
|
+
function Probe() {
|
|
52
|
+
return <output data-testid="location">{useLocation().search}</output>
|
|
53
|
+
}
|
|
54
|
+
const urlParams = () => new URLSearchParams(container.querySelector('[data-testid="location"]')!.textContent ?? '')
|
|
55
|
+
|
|
56
|
+
function render(path: string, eolCount: number | null = 3, shape: (r: VulnerabilitiesResponse) => VulnerabilitiesResponse | undefined = (r) => r, error: unknown = null) {
|
|
57
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => ({
|
|
58
|
+
data: shape(response(p.view, eolCount)), isLoading: false, isFetching: false, isPlaceholderData: false, error, dataUpdatedAt: 0, refetch: vi.fn(),
|
|
59
|
+
} as unknown as ReturnType<typeof useVulnerabilities>))
|
|
60
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
61
|
+
act(() => root.render(
|
|
62
|
+
<QueryClientProvider client={client}>
|
|
63
|
+
<MemoryRouter initialEntries={[path]}>
|
|
64
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
65
|
+
<Probe />
|
|
66
|
+
</MemoryRouter>
|
|
67
|
+
</QueryClientProvider>,
|
|
68
|
+
))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const button = (label: string) => Array.from(container.querySelectorAll('button')).find((b) => b.textContent?.trim() === label)
|
|
72
|
+
const menuButton = () => container.querySelector<HTMLButtonElement>('button[aria-label="More actions"]')
|
|
73
|
+
const menuItems = () => Array.from(container.querySelectorAll<HTMLButtonElement>('[role="menu"] [role^="menuitem"]'))
|
|
74
|
+
const menuItem = (label: string) => menuItems().find((b) => b.textContent === label)
|
|
75
|
+
const heads = () => Array.from(container.querySelectorAll('.uppercase')).map((h) => h.textContent ?? '')
|
|
76
|
+
const lastParams = () => vi.mocked(useVulnerabilities).mock.calls.at(-1)![0]
|
|
77
|
+
// A table row's summary: a click anywhere on it, off its controls, toggles the row.
|
|
78
|
+
const rowButtons = () => Array.from(container.querySelectorAll<HTMLElement>('[data-row-summary]'))
|
|
79
|
+
const moreChip = () => Array.from(container.querySelectorAll<HTMLButtonElement>('button[aria-haspopup="dialog"]')).find((b) => b.textContent?.startsWith('More filters'))
|
|
80
|
+
const panelCheck = (label: string) => Array.from(document.body.querySelectorAll('[role="dialog"] label')).find((l) => l.textContent?.startsWith(label))?.querySelector<HTMLInputElement>('input[type="checkbox"]')
|
|
81
|
+
const openMore = () => act(() => moreChip()!.click())
|
|
82
|
+
|
|
83
|
+
beforeEach(() => {
|
|
84
|
+
feature.exportSupport = 'unsupported'
|
|
85
|
+
localStorage.clear()
|
|
86
|
+
container = document.createElement('div')
|
|
87
|
+
document.body.appendChild(container)
|
|
88
|
+
root = createRoot(container)
|
|
89
|
+
vi.mocked(useVulnerabilities).mockReset()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
afterEach(() => {
|
|
93
|
+
act(() => root.unmount())
|
|
94
|
+
container.remove()
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
describe('Vulnerabilities optional columns', () => {
|
|
98
|
+
it('keeps them off until turned on from the page menu, and remembers the choice in this browser', () => {
|
|
99
|
+
render('/checks/vulnerabilities?by=cve')
|
|
100
|
+
expect(heads().some((h) => h.includes('Published'))).toBe(false)
|
|
101
|
+
expect(container.textContent).not.toContain('2020-12-10')
|
|
102
|
+
|
|
103
|
+
act(() => menuButton()!.click())
|
|
104
|
+
const show = menuItem('Show Published')!
|
|
105
|
+
expect(show.getAttribute('role')).toBe('menuitemcheckbox')
|
|
106
|
+
expect(show.getAttribute('aria-checked')).toBe('false')
|
|
107
|
+
act(() => show.click())
|
|
108
|
+
// A setting, not an action: the menu stays open and shows it checked.
|
|
109
|
+
expect(menuItem('Show Published')!.getAttribute('aria-checked')).toBe('true')
|
|
110
|
+
expect(heads().some((h) => h.includes('Published'))).toBe(true)
|
|
111
|
+
expect(container.textContent).toContain('2020-12-10')
|
|
112
|
+
expect(JSON.parse(localStorage.getItem('radar-vulnerability-columns')!)).toEqual(['cve.published'])
|
|
113
|
+
|
|
114
|
+
act(() => root.unmount())
|
|
115
|
+
root = createRoot(container)
|
|
116
|
+
render('/checks/vulnerabilities?by=cve')
|
|
117
|
+
expect(container.textContent).toContain('2020-12-10')
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('groups the menu: downloads, then the view\'s columns after a divider, with no filter items', () => {
|
|
121
|
+
feature.exportSupport = 'supported'
|
|
122
|
+
render('/checks/vulnerabilities?by=cve')
|
|
123
|
+
act(() => menuButton()!.click())
|
|
124
|
+
expect(menuItems().map((b) => b.textContent)).toEqual([
|
|
125
|
+
'Download By CVE as CSV', 'Download all findings as CSV', 'Show Published', 'Show Age',
|
|
126
|
+
])
|
|
127
|
+
expect(container.querySelectorAll('[role="menu"] .h-px')).toHaveLength(1)
|
|
128
|
+
|
|
129
|
+
act(() => { document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })) })
|
|
130
|
+
act(() => button('By fix')!.click())
|
|
131
|
+
act(() => menuButton()!.click())
|
|
132
|
+
expect(menuItems().map((b) => b.textContent)).toEqual(['Download By fix as CSV', 'Download all findings as CSV'])
|
|
133
|
+
expect(container.querySelectorAll('[role="menu"] .h-px')).toHaveLength(0)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('leaves out a group with nothing in it, and the menu when every group is empty', () => {
|
|
137
|
+
render('/checks/vulnerabilities?by=cve')
|
|
138
|
+
act(() => menuButton()!.click())
|
|
139
|
+
expect(menuItems().map((b) => b.textContent)).toEqual(['Show Published', 'Show Age'])
|
|
140
|
+
expect(container.querySelectorAll('[role="menu"] .h-px')).toHaveLength(0)
|
|
141
|
+
|
|
142
|
+
// By fix has no columns, and without the CSV export no downloads.
|
|
143
|
+
act(() => root.unmount())
|
|
144
|
+
root = createRoot(container)
|
|
145
|
+
render('/checks/vulnerabilities?by=fix')
|
|
146
|
+
expect(menuButton()).toBeNull()
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('shows OS and Scanner on By image, the OS moving into its column in the same quiet text', () => {
|
|
150
|
+
render('/checks/vulnerabilities?by=image')
|
|
151
|
+
act(() => menuButton()!.click())
|
|
152
|
+
expect(menuItems().map((b) => b.textContent)).toEqual(['Show OS', 'Show Scanner', 'Show Package URL'])
|
|
153
|
+
act(() => menuItem('Show OS')!.click())
|
|
154
|
+
act(() => menuItem('Show Scanner')!.click())
|
|
155
|
+
expect(heads().some((h) => h.includes('OS') && h.includes('Scanner'))).toBe(true)
|
|
156
|
+
expect(container.textContent).toContain('Trivy 0.76.1')
|
|
157
|
+
const grid = rowButtons()[0].querySelector('div.grid')!
|
|
158
|
+
expect(grid.children[0].textContent).toBe('nginx:1.19.0')
|
|
159
|
+
expect(grid.children[1].textContent).toBe('debian 10.4·end of life')
|
|
160
|
+
expect(container.querySelector('.badge-sm')).toBeNull()
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('shows each finding\'s package URL in an expanded image', () => {
|
|
164
|
+
localStorage.setItem('radar-vulnerability-columns', JSON.stringify(['image.packageUrl']))
|
|
165
|
+
render('/checks/vulnerabilities?by=image')
|
|
166
|
+
act(() => rowButtons()[0].click())
|
|
167
|
+
expect(container.textContent).toContain('pkg:deb/debian/openssl@1.1')
|
|
168
|
+
// The finding's severity is coloured text, not a pill.
|
|
169
|
+
expect(container.querySelector('.badge-sm')).toBeNull()
|
|
170
|
+
expect(Array.from(container.querySelectorAll('span')).some((e) => e.textContent === 'Critical' && e.className.includes('text-red'))).toBe(true)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('shows Age in days next to Published', () => {
|
|
174
|
+
localStorage.setItem('radar-vulnerability-columns', JSON.stringify(['cve.published', 'cve.age']))
|
|
175
|
+
render('/checks/vulnerabilities?by=cve')
|
|
176
|
+
const days = daysSince('2020-12-10T04:15:11Z')!
|
|
177
|
+
expect(container.textContent).toContain(`2020-12-10${days.toLocaleString('en-US')} d`)
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
it('shows a dash for Age, not 0 d, when the date does not parse', () => {
|
|
181
|
+
localStorage.setItem('radar-vulnerability-columns', JSON.stringify(['cve.published', 'cve.age']))
|
|
182
|
+
render('/checks/vulnerabilities?by=cve', 3, (r) => ({ ...r, cves: r.cves!.map((c) => ({ ...c, publishedAt: 'not a date' })) }))
|
|
183
|
+
expect(container.textContent).not.toContain('0 d')
|
|
184
|
+
expect(container.textContent).toContain('—')
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('explains Published on its column head', () => {
|
|
188
|
+
localStorage.setItem('radar-vulnerability-columns', JSON.stringify(['cve.published']))
|
|
189
|
+
render('/checks/vulnerabilities?by=cve')
|
|
190
|
+
const head = Array.from(container.querySelectorAll('span.underline')).find((h) => h.textContent === 'Published')
|
|
191
|
+
expect(head).toBeTruthy()
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('puts the OS and end of life on the image name\'s line as quiet text, and the digest only on hover', () => {
|
|
195
|
+
vi.useFakeTimers()
|
|
196
|
+
try {
|
|
197
|
+
render('/checks/vulnerabilities?by=image')
|
|
198
|
+
const cell = rowButtons()[0].querySelector('div.grid')!.children[0]
|
|
199
|
+
expect(cell.children[0].textContent).toBe('nginx:1.19.0· debian 10.4·end of life')
|
|
200
|
+
expect(container.querySelector('.badge-sm')).toBeNull()
|
|
201
|
+
expect(rowButtons()[0].textContent).not.toContain('sha256')
|
|
202
|
+
const name = Array.from(cell.querySelectorAll('span')).filter((e) => e.textContent === 'nginx:1.19.0').at(-1)!
|
|
203
|
+
act(() => { name.dispatchEvent(new MouseEvent('mouseover', { bubbles: true })) })
|
|
204
|
+
act(() => { vi.advanceTimersByTime(1_000) })
|
|
205
|
+
expect(document.body.textContent).toContain('sha256:4f8c3a1b2d')
|
|
206
|
+
} finally {
|
|
207
|
+
vi.useRealTimers()
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it('keeps the CVE severity as coloured text in its cell', () => {
|
|
212
|
+
render('/checks/vulnerabilities?by=cve')
|
|
213
|
+
const grid = rowButtons()[0].querySelector('div.grid')!
|
|
214
|
+
expect(grid.children[1].textContent).toBe('Critical')
|
|
215
|
+
expect(grid.children[1].classList.contains('badge-sm')).toBe(false)
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
it('counts the days since publication, not since detection', () => {
|
|
219
|
+
expect(daysSince('2020-01-10T00:00:00Z', Date.parse('2026-01-10T12:00:00Z'))).toBe(2192)
|
|
220
|
+
expect(daysSince('2030-01-01T00:00:00Z', Date.parse('2026-01-10T12:00:00Z'))).toBe(0)
|
|
221
|
+
expect(daysSince('not a date')).toBeUndefined()
|
|
222
|
+
expect(isoDate('2020-12-10T04:15:11Z')).toBe('2020-12-10')
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
describe('More filters', () => {
|
|
227
|
+
it('holds the OS end of life filter, through the URL and the request, and counts it', () => {
|
|
228
|
+
render('/checks/vulnerabilities?by=image')
|
|
229
|
+
expect(moreChip()!.textContent).toBe('More filters')
|
|
230
|
+
expect(lastParams().osEndOfLife).toBe(false)
|
|
231
|
+
openMore()
|
|
232
|
+
expect(Array.from(document.body.querySelectorAll('[role="dialog"] label')).map((l) => l.textContent)).toEqual([
|
|
233
|
+
'Fix availableOnly findings the scanner lists a fixed release for.',
|
|
234
|
+
"OS end of life(3)Only images whose OS release Trivy reports as end of life. Images not scanned yet stay listed: their OS is unknown.",
|
|
235
|
+
])
|
|
236
|
+
act(() => panelCheck('OS end of life')!.click())
|
|
237
|
+
expect(urlParams().get('eol')).toBe('1')
|
|
238
|
+
expect(lastParams().osEndOfLife).toBe(true)
|
|
239
|
+
expect(vulnerabilitiesPath(lastParams())).toContain('eol=1')
|
|
240
|
+
expect(moreChip()!.textContent).toBe('More filters · 1')
|
|
241
|
+
act(() => panelCheck('Fix available')!.click())
|
|
242
|
+
expect(urlParams().get('fixable')).toBe('1')
|
|
243
|
+
expect(moreChip()!.textContent).toBe('More filters · 2')
|
|
244
|
+
|
|
245
|
+
// They count as filters: the match line offers to clear them.
|
|
246
|
+
act(() => button('Clear filters')!.click())
|
|
247
|
+
expect(urlParams().has('eol')).toBe(false)
|
|
248
|
+
expect(urlParams().has('fixable')).toBe(false)
|
|
249
|
+
expect(urlParams().get('by')).toBe('image')
|
|
250
|
+
expect(lastParams().osEndOfLife).toBe(false)
|
|
251
|
+
expect(moreChip()!.textContent).toBe('More filters')
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
it('clears only its own filters with Clear all', () => {
|
|
255
|
+
render('/checks/vulnerabilities?by=image&eol=1&fixable=1&severity=critical&q=nginx')
|
|
256
|
+
openMore()
|
|
257
|
+
const clear = Array.from(document.body.querySelectorAll<HTMLButtonElement>('button')).find((b) => b.getAttribute('aria-label') === 'Clear more filters')!
|
|
258
|
+
act(() => clear.focus())
|
|
259
|
+
act(() => clear.click())
|
|
260
|
+
expect(urlParams().has('eol')).toBe(false)
|
|
261
|
+
expect(urlParams().has('fixable')).toBe(false)
|
|
262
|
+
expect(urlParams().get('severity')).toBe('critical')
|
|
263
|
+
expect(urlParams().get('q')).toBe('nginx')
|
|
264
|
+
// The button disables itself, so focus goes to the panel's first checkbox.
|
|
265
|
+
expect(document.activeElement).toBe(panelCheck('Fix available'))
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
it('hands focus to the chip before it when Clear all takes away the last filter More filters offers', () => {
|
|
269
|
+
// By fix offers only the end-of-life filter, and only while a link sets it.
|
|
270
|
+
render('/checks/vulnerabilities?by=fix&eol=1', 0)
|
|
271
|
+
openMore()
|
|
272
|
+
const clear = Array.from(document.body.querySelectorAll<HTMLButtonElement>('button')).find((b) => b.getAttribute('aria-label') === 'Clear more filters')!
|
|
273
|
+
act(() => clear.focus())
|
|
274
|
+
act(() => clear.click())
|
|
275
|
+
expect(urlParams().has('eol')).toBe(false)
|
|
276
|
+
expect(moreChip()).toBeUndefined()
|
|
277
|
+
const severity = Array.from(container.querySelectorAll('button[aria-haspopup="dialog"]')).find((b) => b.textContent === 'Severity')
|
|
278
|
+
expect(severity).toBeDefined()
|
|
279
|
+
expect(document.activeElement).toBe(severity)
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
it('shows a link\'s end-of-life filter as on, with no menu item to hide it', () => {
|
|
283
|
+
render('/checks/vulnerabilities?by=image&eol=1')
|
|
284
|
+
expect(moreChip()!.textContent).toBe('More filters · 1')
|
|
285
|
+
openMore()
|
|
286
|
+
expect(panelCheck('OS end of life')!.checked).toBe(true)
|
|
287
|
+
act(() => menuButton()!.click())
|
|
288
|
+
expect(menuItems().some((b) => b.textContent?.includes('filter'))).toBe(false)
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('offers no OS end of life filter for a Radar that sends no end-of-life count, or when there is none', () => {
|
|
292
|
+
for (const count of [null, 0]) {
|
|
293
|
+
render('/checks/vulnerabilities?by=image', count)
|
|
294
|
+
openMore()
|
|
295
|
+
expect(panelCheck('OS end of life')).toBeUndefined()
|
|
296
|
+
expect(panelCheck('Fix available')).toBeDefined()
|
|
297
|
+
act(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })) })
|
|
298
|
+
}
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
it('is left out of By fix when it has nothing else to offer', () => {
|
|
302
|
+
render('/checks/vulnerabilities?by=fix', null)
|
|
303
|
+
expect(moreChip()).toBeUndefined()
|
|
304
|
+
render('/checks/vulnerabilities?by=fix')
|
|
305
|
+
openMore()
|
|
306
|
+
expect(panelCheck('Fix available')).toBeUndefined()
|
|
307
|
+
expect(panelCheck('OS end of life')).toBeDefined()
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
describe('No data', () => {
|
|
312
|
+
it('explains the page and offers one install step when the cluster has no Trivy Operator', () => {
|
|
313
|
+
render('/checks/vulnerabilities', 3, () => undefined, new ApiError('kind unknown', 404, { error_code: 'kind_unknown' }))
|
|
314
|
+
const panel = container.querySelector('section[aria-label="Trivy Operator not installed"]')!
|
|
315
|
+
expect(panel.textContent).toContain("Trivy Operator isn't installed in this cluster")
|
|
316
|
+
expect(panel.querySelectorAll('li')).toHaveLength(4)
|
|
317
|
+
expect(Array.from(panel.querySelectorAll('a')).map((a) => a.textContent?.trim())).toEqual(['Install Trivy Operator'])
|
|
318
|
+
expect(container.textContent).toContain("Known CVEs in the images that run now, from Trivy Operator's reports.")
|
|
319
|
+
expect(menuButton()).toBeNull()
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
it('offers a Clear filters action when nothing matches', () => {
|
|
323
|
+
render('/checks/vulnerabilities?by=cve&q=nothing', 3, (r) => ({ ...r, cves: [] }))
|
|
324
|
+
expect(container.textContent).toContain('Nothing matches these filters')
|
|
325
|
+
const clear = Array.from(container.querySelectorAll('button')).filter((b) => b.textContent === 'Clear filters')
|
|
326
|
+
expect(clear.length).toBeGreaterThan(0)
|
|
327
|
+
act(() => clear.at(-1)!.click())
|
|
328
|
+
expect(urlParams().has('q')).toBe(false)
|
|
329
|
+
expect(urlParams().get('by')).toBe('cve')
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
it('says nothing matches, with Clear filters, for a workload whose images the end-of-life filter leaves out', () => {
|
|
333
|
+
render('/checks/vulnerabilities?by=image&eol=1&workload=Deployment/shop/web', 3, (r) => ({
|
|
334
|
+
...r, images: [], unscanned: [{ image: 'acme/pending:1', workloads: [{ kind: 'Deployment', group: 'apps', namespace: 'shop', name: 'web' }], workloadsTotal: 1 }],
|
|
335
|
+
}))
|
|
336
|
+
expect(container.textContent).toContain('Nothing matches these filters')
|
|
337
|
+
expect(container.textContent).not.toContain('No report yet for the images web runs')
|
|
338
|
+
expect(button('Clear filters')).toBeDefined()
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
it('counts the clean images the end-of-life filter keeps, rather than saying nothing matches', () => {
|
|
342
|
+
render('/checks/vulnerabilities?by=image&eol=1', 3, (r) => ({
|
|
343
|
+
...r, images: [], clean: [{ id: 'sha256:eol', image: 'acme/old:1', scannedAt: '2026-11-01T00:00:00Z', workloads: [{ kind: 'Deployment', group: 'apps', namespace: 'shop', name: 'web' }], workloadsTotal: 1, osEndOfLife: true, report: { kind: 'VulnerabilityReport', group: 'aquasecurity.github.io', namespace: 'shop', name: 'r' } }],
|
|
344
|
+
}))
|
|
345
|
+
expect(container.textContent).not.toContain('Nothing matches these filters')
|
|
346
|
+
expect(container.textContent).toContain('None of the 1 matching image has a reported CVE')
|
|
347
|
+
expect(container.textContent).toContain('1 image match')
|
|
348
|
+
expect(container.textContent).toContain('1 scanned image has no reported CVEs')
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
it('leaves clean images out of the count under a filter on findings', () => {
|
|
352
|
+
render('/checks/vulnerabilities?by=image&severity=critical', 3, (r) => ({
|
|
353
|
+
...r, images: [], clean: [{ id: 'sha256:clean', image: 'acme/new:1', scannedAt: '2026-11-01T00:00:00Z', workloads: [{ kind: 'Deployment', group: 'apps', namespace: 'shop', name: 'web' }], workloadsTotal: 1, report: { kind: 'VulnerabilityReport', group: 'aquasecurity.github.io', namespace: 'shop', name: 'r' } }],
|
|
354
|
+
}))
|
|
355
|
+
expect(container.textContent).toContain('Nothing matches these filters')
|
|
356
|
+
expect(container.textContent).toContain('0 images match')
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
it('offers no column the answer has no data for, and draws none a browser had on', () => {
|
|
360
|
+
localStorage.setItem('radar-vulnerability-columns', JSON.stringify(['image.scanner', 'image.os']))
|
|
361
|
+
// An older Radar: no scanner, no purls, no end-of-life count.
|
|
362
|
+
render('/checks/vulnerabilities?by=image', null, (r) => ({ ...r, images: r.images!.map((i) => ({ ...i, scanner: undefined, findings: i.findings.map((f) => ({ ...f, packageUrl: undefined })) })) }))
|
|
363
|
+
expect(heads().some((h) => h.includes('Scanner'))).toBe(false)
|
|
364
|
+
expect(heads().some((h) => h.includes('OS'))).toBe(true)
|
|
365
|
+
act(() => menuButton()!.click())
|
|
366
|
+
expect(menuItems().map((b) => b.textContent)).toEqual(['Show OS'])
|
|
367
|
+
|
|
368
|
+
act(() => root.unmount())
|
|
369
|
+
root = createRoot(container)
|
|
370
|
+
render('/checks/vulnerabilities?by=cve', null, (r) => ({ ...r, cves: r.cves!.map((c) => ({ ...c, publishedAt: undefined })) }))
|
|
371
|
+
expect(menuButton()).toBeNull()
|
|
372
|
+
})
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
describe('Owner column', () => {
|
|
376
|
+
const workload = (name: string) => ({ kind: 'Deployment', group: 'apps', namespace: 'shop', name, counts: { ...zero, high: 1 }, fixable: zero, containers: [] })
|
|
377
|
+
function renderWorkloads(ownership: boolean, owners: boolean | 'fold' = true) {
|
|
378
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => ({
|
|
379
|
+
data: {
|
|
380
|
+
...response(p.view, 0),
|
|
381
|
+
workloads: [workload('web'), workload('plain')],
|
|
382
|
+
...(ownership ? {
|
|
383
|
+
ownership: { teamLabel: 'team' },
|
|
384
|
+
owners: !owners ? [] : [{ kind: 'Deployment', group: 'apps', namespace: 'shop', name: owners === 'fold' ? 'folded' : 'web', manager: { tool: 'helm', kind: 'HelmRelease', namespace: 'shop', name: 'web-release', chart: 'web-1.2.0' }, team: 'payments', teamFrom: 'workload' }],
|
|
385
|
+
} : {}),
|
|
386
|
+
},
|
|
387
|
+
isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn(),
|
|
388
|
+
} as unknown as ReturnType<typeof useVulnerabilities>))
|
|
389
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
390
|
+
act(() => root.render(
|
|
391
|
+
<QueryClientProvider client={client}>
|
|
392
|
+
<MemoryRouter initialEntries={['/checks/vulnerabilities?by=workload']}>
|
|
393
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
394
|
+
</MemoryRouter>
|
|
395
|
+
</QueryClientProvider>,
|
|
396
|
+
))
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
it('is off by default and shows only what Radar knows when on', () => {
|
|
400
|
+
renderWorkloads(true)
|
|
401
|
+
expect(heads().some((h) => h.includes('Owner'))).toBe(false)
|
|
402
|
+
expect(container.textContent).not.toContain('web-release')
|
|
403
|
+
act(() => menuButton()!.click())
|
|
404
|
+
act(() => menuItem('Show Owner')!.click())
|
|
405
|
+
expect(heads().some((h) => h.includes('Owner'))).toBe(true)
|
|
406
|
+
expect(container.textContent).toContain('web-release')
|
|
407
|
+
expect(container.textContent).toContain('Helm · web-1.2.0')
|
|
408
|
+
expect(container.textContent).toContain('team: payments')
|
|
409
|
+
// The unmanaged workload's owner cell is empty, not a guess.
|
|
410
|
+
expect(container.textContent).not.toContain('Unknown')
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
it('adds no column or line when none was found, and says so in the menu', () => {
|
|
414
|
+
renderWorkloads(true, false)
|
|
415
|
+
act(() => menuButton()!.click())
|
|
416
|
+
const item = menuItems().find((b) => b.textContent?.startsWith('Show Owner'))!
|
|
417
|
+
expect(item.textContent).toBe('Show Ownernone found')
|
|
418
|
+
const description = document.getElementById(item.getAttribute('aria-describedby')!)
|
|
419
|
+
expect(description?.textContent).toContain('Helm release, an Argo CD or Flux app, or a team label')
|
|
420
|
+
act(() => item.click())
|
|
421
|
+
expect(item.getAttribute('aria-checked')).toBe('true')
|
|
422
|
+
expect(heads().some((h) => h.includes('Owner'))).toBe(false)
|
|
423
|
+
expect(container.querySelector('[role="table"], table')?.textContent ?? '').not.toContain('none found')
|
|
424
|
+
expect(container.textContent).not.toContain('No owner found')
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
it('says none found when only a workload outside the table has an owner', () => {
|
|
428
|
+
renderWorkloads(true, 'fold')
|
|
429
|
+
act(() => menuButton()!.click())
|
|
430
|
+
expect(menuItems().find((b) => b.textContent?.startsWith('Show Owner'))!.textContent).toBe('Show Ownernone found')
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
it('has no menu note when some workload has an owner', () => {
|
|
434
|
+
renderWorkloads(true)
|
|
435
|
+
act(() => menuButton()!.click())
|
|
436
|
+
expect(menuItem('Show Owner')!.getAttribute('aria-describedby')).toBeNull()
|
|
437
|
+
})
|
|
438
|
+
|
|
439
|
+
function renderUnchecked() {
|
|
440
|
+
vi.mocked(useVulnerabilities).mockImplementation((p) => ({
|
|
441
|
+
data: {
|
|
442
|
+
...response(p.view, 0),
|
|
443
|
+
workloads: [workload('web'), workload('plain')],
|
|
444
|
+
ownership: { teamLabel: 'team', unchecked: [{ kind: 'Application', group: 'argoproj.io', partial: true }, { kind: 'Namespace' }] },
|
|
445
|
+
owners: ['web', 'plain'].map((name) => ({ kind: 'Deployment', group: 'apps', namespace: 'shop', name, managerUnknown: true, managerUnchecked: true })),
|
|
446
|
+
},
|
|
447
|
+
isLoading: false, isFetching: false, isPlaceholderData: false, error: null, dataUpdatedAt: 0, refetch: vi.fn(),
|
|
448
|
+
} as unknown as ReturnType<typeof useVulnerabilities>))
|
|
449
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, enabled: false } } })
|
|
450
|
+
act(() => root.render(
|
|
451
|
+
<QueryClientProvider client={client}>
|
|
452
|
+
<MemoryRouter initialEntries={['/checks/vulnerabilities?by=workload']}>
|
|
453
|
+
<VulnerabilitiesView namespaces={[]} onNavigateToResource={vi.fn()} />
|
|
454
|
+
</MemoryRouter>
|
|
455
|
+
</QueryClientProvider>,
|
|
456
|
+
))
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
it('says the owner was not checked when the viewer\'s access stopped the lookup, never none found', () => {
|
|
460
|
+
renderUnchecked()
|
|
461
|
+
act(() => menuButton()!.click())
|
|
462
|
+
const item = menuItems().find((b) => b.textContent?.startsWith('Show Owner'))!
|
|
463
|
+
expect(item.textContent).toBe('Show Ownernot checked with your access')
|
|
464
|
+
const description = document.getElementById(item.getAttribute('aria-describedby')!)?.textContent ?? ''
|
|
465
|
+
expect(description).toContain("With your access, Radar couldn't read Argo CD Applications outside your namespaces.")
|
|
466
|
+
expect(description).toContain("It also couldn't read namespaces")
|
|
467
|
+
expect(description).not.toContain('found no owner')
|
|
468
|
+
// The column stays available, and each cell says it wasn't checked.
|
|
469
|
+
act(() => item.click())
|
|
470
|
+
expect(heads().some((h) => h.includes('Owner'))).toBe(true)
|
|
471
|
+
expect(container.textContent).toContain('Not checked')
|
|
472
|
+
expect(container.textContent).not.toContain('Unknown')
|
|
473
|
+
// The namespaces weren't readable either, so a team isn't claimed absent.
|
|
474
|
+
expect(container.textContent).toContain('team not checked')
|
|
475
|
+
})
|
|
476
|
+
|
|
477
|
+
it('is not offered by a Radar that reads no owners', () => {
|
|
478
|
+
renderWorkloads(true)
|
|
479
|
+
act(() => menuButton()!.click())
|
|
480
|
+
expect(menuItem('Show Owner')).toBeTruthy()
|
|
481
|
+
act(() => root.unmount())
|
|
482
|
+
root = createRoot(container)
|
|
483
|
+
renderWorkloads(false)
|
|
484
|
+
act(() => menuButton()?.click())
|
|
485
|
+
expect(menuItem('Show Owner')).toBeUndefined()
|
|
486
|
+
})
|
|
487
|
+
})
|