Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SecuritySolution] Replace risk scores donut charts with Lens #148755

Merged
merged 13 commits into from
Jan 17, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface DonutChartProps {
export interface DonutChartWrapperProps {
children?: React.ReactElement;
dataExists: boolean;
label: React.ReactElement | string;
label?: React.ReactElement | string;
title: React.ReactElement | string | number | null;
isChartEmbeddablesEnabled?: boolean;
}
Expand Down Expand Up @@ -111,17 +111,19 @@ const DonutChartWrapperComponent: React.FC<DonutChartWrapperProps> = ({
justifyContent="center"
>
<EuiFlexItem>{title}</EuiFlexItem>
<EuiFlexItem className={className}>
<EuiToolTip content={label}>
<EuiText
className={className}
size="s"
style={dataExists ? undefined : emptyLabelStyle}
>
{label}
</EuiText>
</EuiToolTip>
</EuiFlexItem>
{label && (
<EuiFlexItem className={className}>
<EuiToolTip content={label}>
<EuiText
className={className}
size="s"
style={dataExists ? undefined : emptyLabelStyle}
>
{label}
</EuiText>
</EuiToolTip>
</EuiFlexItem>
)}
</DonutTextWrapper>
{children}
</StyledEuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

import React from 'react';

export const AlertDonutEmbeddable = () => <div data-test-subj="alert-donut-embeddable" />;
export const VisualizationEmbeddable = () => <div data-test-subj="visualization-embeddable" />;

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
@@ -0,0 +1,56 @@
/*
* 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 { getRiskScoreDonutAttributes } from './risk_score_donut';

jest.mock('../../../../../containers/sourcerer', () => ({
useSourcererDataView: jest.fn().mockReturnValue({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
}),
}));

jest.mock('../../../../../utils/route/use_route_spy', () => ({
useRouteSpy: jest.fn().mockReturnValue([
{
detailName: 'undefined',
pageName: 'overview',
tabName: undefined,
},
]),
}));

jest.mock('uuid', () => ({
v4: jest
.fn()
.mockReturnValueOnce('d594baeb-5eca-480c-8885-ba79eaf41372')
.mockReturnValue('1dd5663b-f062-43f8-8688-fc8166c2ca8e'),
}));

describe('getRiskScoreDonutAttributes', () => {
it('should render', () => {
const { result } = renderHook(
() =>
useLensAttributes({
getLensAttributes: getRiskScoreDonutAttributes,
stackByField: 'host',
extraOptions: {
spaceId: 'mockSpaceId',
},
}),
{ wrapper }
);

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