Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into create-categorization-job-from-pattern-analysis
- Loading branch information
Showing
86 changed files
with
2,540 additions
and
560 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
180 changes: 180 additions & 0 deletions
180
..._actions/lens_attributes/common/risk_scores/__snapshots__/risk_score_summary.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
...nents/visualization_actions/lens_attributes/common/risk_scores/risk_score_summary.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,82 @@ | ||
/* | ||
* 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 { RiskScoreEntity } from '../../../../../../../common/risk_engine'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { wrapper } from '../../../mocks'; | ||
import { useLensAttributes } from '../../../use_lens_attributes'; | ||
import { getRiskScoreSummaryAttributes } from './risk_score_summary'; | ||
import { RiskSeverity } from '../../../../../../../common/search_strategy'; | ||
import type { MetricVisualizationState } from '@kbn/lens-plugin/public'; | ||
|
||
jest.mock('../../../../../containers/sourcerer', () => ({ | ||
useSourcererDataView: jest.fn().mockReturnValue({ | ||
selectedPatterns: ['auditbeat-mytest-*'], | ||
dataViewId: 'security-solution-my-test', | ||
indicesExist: true, | ||
}), | ||
})); | ||
|
||
jest.mock('uuid', () => ({ | ||
v4: jest.fn().mockReturnValue('2cc5663b-f062-43f8-8688-fc8166c2ca8e'), | ||
})); | ||
|
||
describe('getRiskScoreSummaryAttributes', () => { | ||
it('should render', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
lensAttributes: getRiskScoreSummaryAttributes({ | ||
severity: RiskSeverity.low, | ||
query: `user.name: test.user`, | ||
spaceId: 'default', | ||
riskEntity: RiskScoreEntity.user, | ||
}), | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders the subtitle', () => { | ||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
lensAttributes: getRiskScoreSummaryAttributes({ | ||
severity: RiskSeverity.low, | ||
query: `user.name: test.user`, | ||
spaceId: 'default', | ||
riskEntity: RiskScoreEntity.user, | ||
}), | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect((result?.current?.state.visualization as MetricVisualizationState).subtitle).toBe('Low'); | ||
}); | ||
|
||
it('renders the query when applyGlobalQueriesAndFilters is false', () => { | ||
const query = `test.field: test.user`; | ||
|
||
const { result } = renderHook( | ||
() => | ||
useLensAttributes({ | ||
lensAttributes: getRiskScoreSummaryAttributes({ | ||
severity: RiskSeverity.low, | ||
query, | ||
spaceId: 'default', | ||
riskEntity: RiskScoreEntity.user, | ||
}), | ||
applyGlobalQueriesAndFilters: false, | ||
}), | ||
{ wrapper } | ||
); | ||
|
||
expect(result?.current?.state.query.query).toBe(query); | ||
}); | ||
}); |
Oops, something went wrong.