Skip to content

Commit

Permalink
[Cloud Security] Adding unprivileged state to benchmark page (#195172)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSh authored Oct 7, 2024
1 parent 3b70d99 commit 5d7de2f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -85,6 +86,27 @@ describe('<Benchmarks />', () => {
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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<CloudPosturePage>
Expand All @@ -182,7 +187,7 @@ export const Benchmarks = () => {
bottomBorder
/>
<EuiSpacer />
{showConfigurationInstallPrompt ? (
{showNoFindingsStates ? (
<NoFindingsStates postureType={'all'} />
) : (
<>
Expand Down

0 comments on commit 5d7de2f

Please sign in to comment.