Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeOberti committed Sep 13, 2023
1 parent c0efb41 commit 99efc61
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ describe('<InvestigationGuide />', () => {
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toBeInTheDocument();
});

it('should render null useInvestigationGuide errors out', () => {
it('should render no data message when useInvestigationGuide errors out', () => {
(useInvestigationGuide as jest.Mock).mockReturnValue({
loading: false,
error: true,
});
const { container } = render(renderInvestigationGuide());
expect(container).toBeEmptyDOMElement();
const { getByTestId } = render(renderInvestigationGuide());
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export const InvestigationGuide: React.FC = () => {
dataFormattedForFieldBrowser,
});

if (error) {
return null;
}

if (loading) {
return (
<EuiFlexGroup
Expand All @@ -45,7 +41,7 @@ export const InvestigationGuide: React.FC = () => {

return (
<>
{basicAlertData.ruleId && ruleNote ? (
{!error && basicAlertData.ruleId && ruleNote ? (
<InvestigationGuideView
basicData={basicAlertData}
ruleNote={ruleNote}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
PREVALENCE_DETAILS_LOADING_TEST_ID,
PREVALENCE_DETAILS_TABLE_ALERT_COUNT_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_DOC_COUNT_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_ERROR_TEST_ID,
PREVALENCE_DETAILS_TABLE_FIELD_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_HOST_PREVALENCE_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID,
PREVALENCE_DETAILS_TABLE_TEST_ID,
PREVALENCE_DETAILS_TABLE_USER_PREVALENCE_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_VALUE_CELL_TEST_ID,
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('PrevalenceDetails', () => {
expect(getByTestId(PREVALENCE_DETAILS_LOADING_TEST_ID)).toBeInTheDocument();
});

it('should render error if call errors out', () => {
it('should render no data message if call errors out', () => {
(usePrevalence as jest.Mock).mockReturnValue({
loading: false,
error: true,
Expand All @@ -231,6 +231,6 @@ describe('PrevalenceDetails', () => {
</LeftPanelContext.Provider>
);

expect(getByTestId(PREVALENCE_DETAILS_TABLE_ERROR_TEST_ID)).toBeInTheDocument();
expect(getByTestId(`${PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID}Error`)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import React, { useMemo, useState } from 'react';
import type { EuiBasicTableColumn, OnTimeChangeProps } from '@elastic/eui';
import {
EuiCallOut,
EuiEmptyPrompt,
EuiFlexGroup,
EuiFlexItem,
EuiInMemoryTable,
Expand All @@ -28,10 +27,8 @@ import { useLicense } from '../../../common/hooks/use_license';
import { InvestigateInTimelineButton } from '../../../common/components/event_details/table/investigate_in_timeline_button';
import type { PrevalenceData } from '../../shared/hooks/use_prevalence';
import { usePrevalence } from '../../shared/hooks/use_prevalence';
import { ERROR_MESSAGE, ERROR_TITLE } from '../../shared/translations';
import {
HOST_TITLE,
PREVALENCE_ERROR_MESSAGE,
PREVALENCE_TABLE_ALERT_COUNT_COLUMN_TITLE,
PREVALENCE_TABLE_COUNT_COLUMN_TITLE,
PREVALENCE_TABLE_DOC_COUNT_COLUMN_TITLE,
Expand All @@ -49,7 +46,6 @@ import {
PREVALENCE_DETAILS_LOADING_TEST_ID,
PREVALENCE_DETAILS_TABLE_ALERT_COUNT_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_DOC_COUNT_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_ERROR_TEST_ID,
PREVALENCE_DETAILS_TABLE_HOST_PREVALENCE_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_VALUE_CELL_TEST_ID,
PREVALENCE_DETAILS_TABLE_FIELD_CELL_TEST_ID,
Expand Down Expand Up @@ -272,18 +268,6 @@ export const PrevalenceDetails: React.FC = () => {
);
}

if (error) {
return (
<EuiEmptyPrompt
iconType="error"
color="danger"
title={<h2>{ERROR_TITLE(PREVALENCE_ERROR_MESSAGE)}</h2>}
body={<p>{ERROR_MESSAGE(PREVALENCE_ERROR_MESSAGE)}</p>}
data-test-subj={PREVALENCE_DETAILS_TABLE_ERROR_TEST_ID}
/>
);
}

const upsell = (
<>
<EuiCallOut data-test-subj={`${PREVALENCE_DETAILS_TABLE_TEST_ID}UpSell`}>
Expand All @@ -308,7 +292,7 @@ export const PrevalenceDetails: React.FC = () => {

return (
<>
{!isPlatinumPlus && upsell}
{!error && !isPlatinumPlus && upsell}
<EuiPanel>
<EuiSuperDatePicker
start={start}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ export const RELATED_USERS_TOOL_TIP = (hostName: string) =>
values: { hostName },
});

export const PREVALENCE_ERROR_MESSAGE = i18n.translate(
'xpack.securitySolution.flyout.prevalenceErrorMessage',
{
defaultMessage: 'prevalence',
}
);

export const PREVALENCE_NO_DATA_MESSAGE = i18n.translate(
'xpack.securitySolution.flyout.prevalenceNoDataMessage',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { renderHook } from '@testing-library/react-hooks';
import { useTimelineEventsDetails } from '../../../timelines/containers/details';
import { useSourcererDataView } from '../../../common/containers/sourcerer';
import { useRouteSpy } from '../../../common/utils/route/use_route_spy';
import type { LeftPanelContext } from '../context';
import { useLeftPanelContext } from '../context';
import { useInvestigationTimeEnrichment } from '../../../common/containers/cti/event_enrichment';
import { SecurityPageName } from '../../../../common/constants';
Expand All @@ -20,6 +19,7 @@ import {
type GetBasicDataFromDetailsData,
useBasicDataFromDetailsData,
} from '../../../timelines/components/side_panel/event_details/helpers';
import { mockContextValue } from '../mocks/mock_context';

jest.mock('../../../timelines/containers/details');
jest.mock('../../../common/containers/sourcerer');
Expand Down Expand Up @@ -64,20 +64,7 @@ describe('useThreatIntelligenceDetails', () => {
() => {},
]);

jest.mocked(useLeftPanelContext).mockReturnValue({
indexName: 'test-index',
eventId: 'test-event-id',
getFieldsData: () => null,
dataFormattedForFieldBrowser: null,
scopeId: 'test-scope-id',
browserFields: null,
searchHit: {
_id: 'testId',
_index: 'testIndex',
},
dataAsNestedObject: null,
investigationFields: [],
} as unknown as LeftPanelContext);
jest.mocked(useLeftPanelContext).mockReturnValue(mockContextValue);
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ describe('<InvestigationGuide />', () => {
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toBeInTheDocument();
});

it('should render null when useInvestigationGuide errors out', () => {
it('should render no data message when useInvestigationGuide errors out', () => {
(useInvestigationGuide as jest.Mock).mockReturnValue({
loading: false,
error: true,
show: false,
});

const { container } = render(renderInvestigationGuide());
expect(container).toBeEmptyDOMElement();
const { getByTestId } = render(renderInvestigationGuide());
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ export const InvestigationGuide: React.FC = () => {
});
}, [eventId, indexName, openLeftPanel, scopeId]);

if (!dataFormattedForFieldBrowser || error) {
return null;
}

if (loading) {
return (
<EuiFlexGroup
Expand All @@ -73,7 +69,7 @@ export const InvestigationGuide: React.FC = () => {
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
{basicAlertData.ruleId && ruleNote ? (
{!error && basicAlertData.ruleId && ruleNote ? (
<EuiButton
onClick={goToInvestigationsTab}
iconType="documentation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export const PanelFooter: FC = () => {
[eventId, indexName, openRightPanel, scopeId, showHostIsolationPanel]
);

if (!dataFormattedForFieldBrowser || !dataAsNestedObject) {
return null;
}

return (
<FlyoutFooter
detailsData={dataFormattedForFieldBrowser}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
*/

import React from 'react';
import { EuiEmptyPrompt } from '@elastic/eui';
import { EuiEmptyPrompt, EuiFlexItem } from '@elastic/eui';
import { ERROR_MESSAGE, ERROR_TITLE, FLYOUT_ERROR } from '../translations';
import { FLYOUT_ERROR_TEST_ID } from '../test_ids';

/**
* Use this when you need to show an error state in the flyout
*/
export const FlyoutError: React.VFC = () => (
<EuiEmptyPrompt
iconType="error"
color="danger"
title={<h2>{ERROR_TITLE(FLYOUT_ERROR)}</h2>}
body={<p>{ERROR_MESSAGE(FLYOUT_ERROR)}</p>}
data-test-subj={FLYOUT_ERROR_TEST_ID}
/>
<EuiFlexItem>
<EuiEmptyPrompt
iconType="error"
color="danger"
title={<h2>{ERROR_TITLE(FLYOUT_ERROR)}</h2>}
body={<p>{ERROR_MESSAGE(FLYOUT_ERROR)}</p>}
data-test-subj={FLYOUT_ERROR_TEST_ID}
/>
</EuiFlexItem>
);

FlyoutError.displayName = 'FlyoutError';
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -33165,7 +33165,6 @@
"xpack.securitySolution.flyout.entities.relatedHostsTitle": "Hôtes associés",
"xpack.securitySolution.flyout.entities.relatedUsersTitle": "Utilisateurs associés",
"xpack.securitySolution.flyout.entities.usersInfoTitle": "Informations sur l’utilisateur",
"xpack.securitySolution.flyout.prevalenceErrorMessage": "prévalence",
"xpack.securitySolution.flyout.prevalenceTableAlertCountColumnTitle": "Nombre d'alertes",
"xpack.securitySolution.flyout.prevalenceTableDocCountColumnTitle": "Compte du document",
"xpack.securitySolution.flyout.response.title": "Réponses",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -33164,7 +33164,6 @@
"xpack.securitySolution.flyout.entities.relatedHostsTitle": "関連するホスト",
"xpack.securitySolution.flyout.entities.relatedUsersTitle": "関連するユーザー",
"xpack.securitySolution.flyout.entities.usersInfoTitle": "ユーザー情報",
"xpack.securitySolution.flyout.prevalenceErrorMessage": "発生率",
"xpack.securitySolution.flyout.prevalenceTableAlertCountColumnTitle": "アラート件数",
"xpack.securitySolution.flyout.prevalenceTableDocCountColumnTitle": "ドキュメントカウント",
"xpack.securitySolution.flyout.response.title": "対応",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -33160,7 +33160,6 @@
"xpack.securitySolution.flyout.entities.relatedHostsTitle": "相关主机",
"xpack.securitySolution.flyout.entities.relatedUsersTitle": "相关用户",
"xpack.securitySolution.flyout.entities.usersInfoTitle": "用户信息",
"xpack.securitySolution.flyout.prevalenceErrorMessage": "普及率",
"xpack.securitySolution.flyout.prevalenceTableAlertCountColumnTitle": "告警计数",
"xpack.securitySolution.flyout.prevalenceTableDocCountColumnTitle": "文档计数",
"xpack.securitySolution.flyout.response.title": "响应",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe(
`Discover Datagrid Cell Actions`,
{
env: { ftrConfig: { enableExperimental: ['discoverInTimeline'] } },
tags: ['@ess', '@serverless', '@brokenInServerless'],
tags: ['@serverless', '@brokenInServerless'],
},
() => {
beforeEach(() => {
Expand Down

0 comments on commit 99efc61

Please sign in to comment.