Skip to content

Commit

Permalink
[Security Solution] Risk score area chart displayed error (#155597)
Browse files Browse the repository at this point in the history
## Summary

Risk score area chart displayed error on host details page:
/app/security/hosts/name/{hostName}/hostRisk

Before:
![Screenshot 2023-04-24 at 11 02
19](https://user-images.githubusercontent.com/6295984/233961792-7f8c64f6-0bbb-467d-b762-0b9cbf86a979.png)

After:
<img width="834" alt="Screenshot 2023-04-24 at 10 21 55"
src="https://user-images.githubusercontent.com/6295984/233961617-b78e1c05-6b9f-406a-8264-e615cf8e4848.png">

Relevant changes:
https://github.com/elastic/kibana/pull/152506/files#diff-260dbbbd965ff10673ef7670e2cb819173662b51bb353b7ad702a60334e874ff


### Checklist

Delete any items that are not applicable to this PR.


- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
angorayc and kibanamachine authored Apr 24, 2023
1 parent f5034e6 commit d0642f7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { renderHook } from '@testing-library/react-hooks';
import type { XYState } from '@kbn/lens-plugin/public';
import { wrapper } from '../../../mocks';

import { useLensAttributes } from '../../../use_lens_attributes';
Expand Down Expand Up @@ -56,4 +57,42 @@ describe('getRiskScoreOverTimeAreaAttributes', () => {

expect(result?.current).toMatchSnapshot();
});

it('should render a Reference Line with an Alert icon', () => {
const { result } = renderHook(
() =>
useLensAttributes({
getLensAttributes: getRiskScoreOverTimeAreaAttributes,
stackByField: 'host',
extraOptions: {
spaceId: 'mockSpaceId',
},
}),
{ wrapper }
);

expect(
(result?.current?.state.visualization as XYState).layers.find(
(layer) => layer.layerType === 'referenceLine'
)
).toEqual(
expect.objectContaining({
layerId: '1dd5663b-f062-43f8-8688-fc8166c2ca8e',
layerType: 'referenceLine',
accessors: ['1dd5663b-f062-43f8-8688-fc8166c2ca8e'],
yConfig: [
{
forAccessor: '1dd5663b-f062-43f8-8688-fc8166c2ca8e',
axisMode: 'left',
lineWidth: 2,
color: '#aa6556',
icon: 'alert',
textVisibility: true,
fill: 'none',
iconPosition: 'left',
},
],
})
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const getRiskScoreOverTimeAreaAttributes: GetLensAttributes = (
axisMode: 'left',
lineWidth: 2,
color: '#aa6556',
icon: 'warning',
icon: 'alert',
textVisibility: true,
fill: 'none',
iconPosition: 'left',
Expand Down

0 comments on commit d0642f7

Please sign in to comment.