-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] [RAC] Add alerts count table to Security Solution…
…s alerts page (#106358) * Add alerts count table to Security Solutions alerts page * Refactor alerts_histogram_panel to reuse logic on alerts_count * Improve AlertsCount mobile layout
- Loading branch information
Showing
36 changed files
with
1,104 additions
and
400 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
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
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
123 changes: 0 additions & 123 deletions
123
...ins/security_solution/public/detections/components/alerts_histogram_panel/translations.ts
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
...olution/public/detections/components/alerts_kpis/alerts_count_panel/alerts_count.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,91 @@ | ||
/* | ||
* 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 { shallow, mount } from 'enzyme'; | ||
|
||
import { AlertsCount } from './alerts_count'; | ||
import { AlertSearchResponse } from '../../../containers/detection_engine/alerts/types'; | ||
import { TestProviders } from '../../../../common/mock'; | ||
import { DragDropContextWrapper } from '../../../../common/components/drag_and_drop/drag_drop_context_wrapper'; | ||
import { mockBrowserFields } from '../../../../common/containers/source/mock'; | ||
import { AlertsCountAggregation } from './types'; | ||
|
||
jest.mock('../../../../common/lib/kibana'); | ||
const mockDispatch = jest.fn(); | ||
|
||
jest.mock('react-redux', () => { | ||
const original = jest.requireActual('react-redux'); | ||
return { | ||
...original, | ||
useDispatch: () => mockDispatch, | ||
}; | ||
}); | ||
|
||
describe('AlertsCount', () => { | ||
it('renders correctly', () => { | ||
const wrapper = shallow( | ||
<AlertsCount | ||
data={{} as AlertSearchResponse<{}, AlertsCountAggregation>} | ||
loading={false} | ||
selectedStackByOption={'test_selected_field'} | ||
/> | ||
); | ||
|
||
expect(wrapper.find('[data-test-subj="alertsCountTable"]').exists()).toBeTruthy(); | ||
}); | ||
|
||
it('renders the given alert item', () => { | ||
const alertFiedlKey = 'test_stack_by_test_key'; | ||
const alertFiedlCount = 999; | ||
const alertData = { | ||
took: 0, | ||
timeout: false, | ||
hits: { | ||
hits: [], | ||
sequences: [], | ||
events: [], | ||
total: { | ||
relation: 'eq', | ||
value: 0, | ||
}, | ||
}, | ||
_shards: { | ||
failed: 0, | ||
skipped: 0, | ||
successful: 1, | ||
total: 1, | ||
}, | ||
aggregations: { | ||
alertsByGroupingCount: { | ||
buckets: [ | ||
{ | ||
key: alertFiedlKey, | ||
doc_count: alertFiedlCount, | ||
}, | ||
], | ||
}, | ||
alertsByGrouping: { buckets: [] }, | ||
}, | ||
} as AlertSearchResponse<unknown, AlertsCountAggregation>; | ||
|
||
const wrapper = mount( | ||
<TestProviders> | ||
<DragDropContextWrapper browserFields={mockBrowserFields}> | ||
<AlertsCount | ||
data={alertData} | ||
loading={false} | ||
selectedStackByOption={'test_selected_field'} | ||
/> | ||
</DragDropContextWrapper> | ||
</TestProviders> | ||
); | ||
|
||
expect(wrapper.text()).toContain(alertFiedlKey); | ||
expect(wrapper.text()).toContain(alertFiedlCount); | ||
}); | ||
}); |
Oops, something went wrong.