diff --git a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.test.tsx index e11095bb622f0..4e52484dffbea 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.test.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.test.tsx @@ -18,6 +18,7 @@ import { useCspSetupStatusApi } from '@kbn/cloud-security-posture/src/hooks/use_ import { useCspIntegrationLink } from '../../common/navigation/use_csp_integration_link'; import { ERROR_STATE_TEST_SUBJECT } from './benchmarks_table'; import { useLicenseManagementLocatorApi } from '../../common/api/use_license_management_locator_api'; +import { NO_FINDINGS_STATUS_TEST_SUBJ } from '../../components/test_subjects'; jest.mock('./use_csp_benchmark_integrations'); jest.mock('@kbn/cloud-security-posture/src/hooks/use_csp_setup_status_api'); @@ -85,6 +86,27 @@ describe('', () => { expect(screen.getByTestId(ERROR_STATE_TEST_SUBJECT)).toBeInTheDocument(); }); + it('renders unprivileged state ', () => { + (useCspSetupStatusApi as jest.Mock).mockImplementation(() => + createReactQueryResponse({ + status: 'success', + data: { + cspm: { status: 'unprivileged' }, + kspm: { status: 'unprivileged' }, + }, + }) + ); + + renderBenchmarks( + createReactQueryResponse({ + status: 'success', + data: { total: 1, items: [createCspBenchmarkIntegrationFixture()] }, + }) + ); + + expect(screen.getByTestId(NO_FINDINGS_STATUS_TEST_SUBJ.UNPRIVILEGED)).toBeInTheDocument(); + }); + it('renders the benchmarks table', () => { renderBenchmarks( createReactQueryResponse({ diff --git a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.tsx b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.tsx index dd6b8ce45318b..e3e4efc0db371 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.tsx @@ -163,9 +163,14 @@ export const Benchmarks = () => { const getSetupStatus = useCspSetupStatusApi({ refetchInterval: NO_FINDINGS_STATUS_REFRESH_INTERVAL_MS, }); - const showConfigurationInstallPrompt = - getSetupStatus.data?.kspm?.status === 'not-installed' && - getSetupStatus.data?.cspm?.status === 'not-installed'; + + const kspmStatus = getSetupStatus.data?.kspm?.status; + const cspmStatus = getSetupStatus.data?.cspm?.status; + + const showNoFindingsStates = + (kspmStatus === 'not-installed' && cspmStatus === 'not-installed') || + cspmStatus === 'unprivileged' || + kspmStatus === 'unprivileged'; return ( @@ -182,7 +187,7 @@ export const Benchmarks = () => { bottomBorder /> - {showConfigurationInstallPrompt ? ( + {showNoFindingsStates ? ( ) : ( <>