From 4f0da280ad241a2a4971e74b1abc8cb6a8caa33e Mon Sep 17 00:00:00 2001 From: animehart Date: Fri, 15 Dec 2023 02:23:00 -0800 Subject: [PATCH] clean up --- .../common/utils/helpers.ts | 27 +++---------------- .../public/pages/rules/index.tsx | 6 ++--- .../public/pages/rules/rules.test.tsx | 3 ++- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts b/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts index 10d18dfde658b..9f1b7ee7ffa89 100644 --- a/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts +++ b/x-pack/plugins/cloud_security_posture/common/utils/helpers.ts @@ -186,8 +186,9 @@ export const getBenchmarkCisName = (benchmarkId: BenchmarksCisId) => { return 'CIS EKS'; case 'cis_gcp': return 'CIS GCP'; + default: + return null; } - return null; }; export const getBenchmarkApplicableTo = (benchmarkId: BenchmarksCisId) => { @@ -202,30 +203,10 @@ export const getBenchmarkApplicableTo = (benchmarkId: BenchmarksCisId) => { return 'Amazon Elastic Kubernetes Service'; case 'cis_gcp': return 'Google Cloud Provider'; + default: + return null; } - return null; }; -// export const getBenchmarkFilterQuery = ( -// id: BenchmarkId, -// version: string, -// section?: string -// ): string => -// `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${id} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${version}"${ -// section -// ? ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.section: "${section}"` -// : '' -// }`; - -// export const getBenchmarkFilterQuery = ( -// id: BenchmarkId, -// version: string, -// selectParams?: BenchmarkRuleSelectParams -// ): string => -// `${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.id:${id} AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.benchmark.version:"v${version}"${ -// selectParams?.section || selectParams?.ruleNumber -// ? ` AND ${CSP_BENCHMARK_RULE_SAVED_OBJECT_TYPE}.attributes.metadata.section: "${selectParams?.section}"` -// : '' -// }`; export const getBenchmarkFilterQuery = ( id: BenchmarkId, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/rules/index.tsx b/x-pack/plugins/cloud_security_posture/public/pages/rules/index.tsx index 22e432f32fa71..500219eef39d8 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/rules/index.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/rules/index.tsx @@ -29,13 +29,13 @@ import { BenchmarksCisId, PageUrlParams } from '../../../common/types/latest'; export const Rules = ({ match: { params } }: RouteComponentProps) => { const { euiTheme } = useEuiTheme(); - const integrationInfo = useCspBenchmarkIntegrationsV2(); + const benchmarksInfo = useCspBenchmarkIntegrationsV2(); const SpyRoute = useSecuritySolutionContext()?.getSpyRouteComponent(); - const [packageInfo] = integrationInfo.data?.items || []; + const [packageInfo] = benchmarksInfo.data?.items || []; return ( - + ', () => { expect(useCspBenchmarkIntegrationsV2).toHaveBeenCalled(); }); - it('Display Success State', async () => { + it('Display success state when result request is resolved', async () => { const params = { benchmarkId: 'cis_eks', benchmarkVersion: '1.9.1' }; const Component = getTestComponent(params); const result = createReactQueryResponse({ @@ -143,5 +143,6 @@ describe('', () => { render(); expect(await screen.findByTestId(TEST_SUBJECTS.CSP_RULES_CONTAINER)).toBeInTheDocument(); + expect(useCspBenchmarkIntegrationsV2).toHaveBeenCalled(); }); });