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.
- Loading branch information
Showing
11 changed files
with
1,209 additions
and
20 deletions.
There are no files selected for viewing
890 changes: 890 additions & 0 deletions
890
...ization_actions/lens_attributes/common/alerts/__snapshots__/alerts_histogram.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
101 changes: 101 additions & 0 deletions
101
...n/components/visualization_actions/lens_attributes/common/alerts/alerts_histogram.test.ts
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,101 @@ | ||
/* | ||
* 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 { renderHook } from '@testing-library/react-hooks'; | ||
import { wrapper } from '../../../mocks'; | ||
|
||
import { useLensAttributes } from '../../../use_lens_attributes'; | ||
|
||
import { getAlertsHistogramLensAttributes } from './alerts_histogram'; | ||
|
||
jest.mock('../../../../../containers/sourcerer', () => ({ | ||
useSourcererDataView: jest.fn().mockReturnValue({ | ||
dataViewId: 'security-solution-my-test', | ||
indicesExist: true, | ||
selectedPatterns: ['signal-index'], | ||
}), | ||
})); | ||
|
||
jest.mock('../../../../../utils/route/use_route_spy', () => ({ | ||
useRouteSpy: jest.fn().mockReturnValue([ | ||
{ | ||
detailName: 'mockRule', | ||
pageName: 'rules', | ||
tabName: 'alerts', | ||
}, | ||
]), | ||
})); | ||
|
||
describe('getAlertsHistogramLensAttributes', () => { | ||
it('should render without extra options', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
getLensAttributes: getAlertsHistogramLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - showBuildingBlockAlerts', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { showBuildingBlockAlerts: true }, | ||
getLensAttributes: getAlertsHistogramLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - showOnlyThreatIndicatorAlerts', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { showOnlyThreatIndicatorAlerts: true }, | ||
getLensAttributes: getAlertsHistogramLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - status', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { status: 'open' }, | ||
getLensAttributes: getAlertsHistogramLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - breakdownField', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { breakdownField: 'agent.type' }, | ||
getLensAttributes: getAlertsHistogramLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
}); |
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
99 changes: 99 additions & 0 deletions
99
...ommon/components/visualization_actions/lens_attributes/common/alerts/alerts_table.test.ts
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,99 @@ | ||
/* | ||
* 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 { renderHook } from '@testing-library/react-hooks'; | ||
import { wrapper } from '../../../mocks'; | ||
|
||
import { useLensAttributes } from '../../../use_lens_attributes'; | ||
|
||
import { getAlertsTableLensAttributes } from './alerts_table'; | ||
|
||
jest.mock('../../../../../containers/sourcerer', () => ({ | ||
useSourcererDataView: jest.fn().mockReturnValue({ | ||
dataViewId: 'security-solution-my-test', | ||
indicesExist: true, | ||
selectedPatterns: ['signal-index'], | ||
}), | ||
})); | ||
|
||
jest.mock('../../../../../utils/route/use_route_spy', () => ({ | ||
useRouteSpy: jest.fn().mockReturnValue([ | ||
{ | ||
pageName: 'alerts', | ||
}, | ||
]), | ||
})); | ||
|
||
describe('getAlertsTableLensAttributes', () => { | ||
it('should render without extra options', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
getLensAttributes: getAlertsTableLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - showBuildingBlockAlerts', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { showBuildingBlockAlerts: true }, | ||
getLensAttributes: getAlertsTableLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - showOnlyThreatIndicatorAlerts', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { showOnlyThreatIndicatorAlerts: true }, | ||
getLensAttributes: getAlertsTableLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - status', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { status: 'open' }, | ||
getLensAttributes: getAlertsTableLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - breakdownField', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { breakdownField: 'agent.type' }, | ||
getLensAttributes: getAlertsTableLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
}); |
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
99 changes: 99 additions & 0 deletions
99
...mon/components/visualization_actions/lens_attributes/common/alerts/alerts_treemap.test.ts
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,99 @@ | ||
/* | ||
* 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 { renderHook } from '@testing-library/react-hooks'; | ||
import { wrapper } from '../../../mocks'; | ||
|
||
import { useLensAttributes } from '../../../use_lens_attributes'; | ||
|
||
import { getAlertsTreemapLensAttributes } from './alerts_treemap'; | ||
|
||
jest.mock('../../../../../containers/sourcerer', () => ({ | ||
useSourcererDataView: jest.fn().mockReturnValue({ | ||
dataViewId: 'security-solution-my-test', | ||
indicesExist: true, | ||
selectedPatterns: ['signal-index'], | ||
}), | ||
})); | ||
|
||
jest.mock('../../../../../utils/route/use_route_spy', () => ({ | ||
useRouteSpy: jest.fn().mockReturnValue([ | ||
{ | ||
pageName: 'alerts', | ||
}, | ||
]), | ||
})); | ||
|
||
describe('getAlertsTreemapLensAttributes', () => { | ||
it('should render without extra options', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
getLensAttributes: getAlertsTreemapLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - showBuildingBlockAlerts', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { showBuildingBlockAlerts: true }, | ||
getLensAttributes: getAlertsTreemapLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - showOnlyThreatIndicatorAlerts', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { showOnlyThreatIndicatorAlerts: true }, | ||
getLensAttributes: getAlertsTreemapLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - status', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { status: 'open' }, | ||
getLensAttributes: getAlertsTreemapLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render with extra options - breakdownField', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
extraOptions: { breakdownField: 'agent.type' }, | ||
getLensAttributes: getAlertsTreemapLensAttributes, | ||
stackByField: 'event.category', | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
}); |
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.