forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cloud Security] [Posture Dashboard] Update links to the findings pag…
…e with groupBy option (elastic#176463)
- Loading branch information
1 parent
201944f
commit c6ccda3
Showing
9 changed files
with
151 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
x-pack/plugins/cloud_security_posture/public/components/accounts_evaluated_widget.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import { AccountsEvaluatedWidget } from './accounts_evaluated_widget'; | ||
import { BenchmarkData } from '../../common/types_old'; | ||
import { TestProvider } from '../test/test_provider'; | ||
|
||
const mockNavToFindings = jest.fn(); | ||
jest.mock('../common/hooks/use_navigate_findings', () => ({ | ||
useNavigateFindings: () => mockNavToFindings, | ||
})); | ||
|
||
describe('AccountsEvaluatedWidget', () => { | ||
const benchmarkAssets = [ | ||
{ meta: { benchmarkId: 'cis_aws', assetCount: 10 } }, | ||
{ meta: { benchmarkId: 'cis_k8s', assetCount: 20 } }, | ||
] as BenchmarkData[]; | ||
|
||
it('renders the component with benchmark data correctly', () => { | ||
const { getByText } = render( | ||
<TestProvider> | ||
<AccountsEvaluatedWidget benchmarkAssets={benchmarkAssets} benchmarkAbbreviateAbove={999} /> | ||
</TestProvider> | ||
); | ||
|
||
expect(getByText('10')).toBeInTheDocument(); | ||
expect(getByText('20')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls navToFindingsByCloudProvider when a benchmark with provider is clicked', () => { | ||
const { getByText } = render( | ||
<TestProvider> | ||
<AccountsEvaluatedWidget benchmarkAssets={benchmarkAssets} benchmarkAbbreviateAbove={999} /> | ||
</TestProvider> | ||
); | ||
|
||
fireEvent.click(getByText('10')); | ||
|
||
expect(mockNavToFindings).toHaveBeenCalledWith( | ||
{ | ||
'cloud.provider': 'aws', | ||
}, | ||
['cloud.account.name'] | ||
); | ||
}); | ||
|
||
it('calls navToFindingsByCisBenchmark when a benchmark with benchmarkId is clicked', () => { | ||
const { getByText } = render( | ||
<TestProvider> | ||
<AccountsEvaluatedWidget benchmarkAssets={benchmarkAssets} benchmarkAbbreviateAbove={999} /> | ||
</TestProvider> | ||
); | ||
|
||
fireEvent.click(getByText('20')); | ||
|
||
expect(mockNavToFindings).toHaveBeenCalledWith( | ||
{ | ||
'rule.benchmark.id': 'cis_k8s', | ||
}, | ||
['orchestrator.cluster.name'] | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.