mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Expandable flyout testids (#166298)
This commit is contained in:
parent
b8560eb653
commit
bcfcb87b57
96 changed files with 1049 additions and 1423 deletions
|
@ -39,7 +39,7 @@ describe('Alert Event Details - dynamic params', { tags: ['@ess', '@serverless']
|
|||
|
||||
it('should substitute parameters in investigation guide', () => {
|
||||
cy.getBySel('expand-event').first().click();
|
||||
cy.getBySel('securitySolutionDocumentDetailsFlyoutInvestigationGuideButton').click();
|
||||
cy.getBySel('securitySolutionFlyoutInvestigationGuideButton').click();
|
||||
cy.contains('Get processes').click();
|
||||
cy.getBySel('flyout-body-osquery').within(() => {
|
||||
cy.contains("SELECT * FROM os_version where name='Ubuntu';");
|
||||
|
|
|
@ -35,7 +35,7 @@ describe('Alert Test', { tags: ['@ess'] }, () => {
|
|||
cy.getBySel('expand-event').first().click({ force: true });
|
||||
|
||||
cy.wait(500);
|
||||
cy.getBySel('securitySolutionDocumentDetailsFlyoutInvestigationGuideButton').click();
|
||||
cy.getBySel('securitySolutionFlyoutInvestigationGuideButton').click();
|
||||
cy.contains('Get processes').click();
|
||||
});
|
||||
|
||||
|
|
|
@ -5,4 +5,6 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const FLYOUT_HEADER_TITLE_TEST_ID = 'securitySolutionDocumentDetailsFlyoutHeaderTitle';
|
||||
import { PREFIX } from '../shared/test_ids';
|
||||
|
||||
export const FLYOUT_HEADER_TITLE_TEST_ID = `${PREFIX}HeaderTitle` as const;
|
||||
|
|
|
@ -27,6 +27,9 @@ export const AnalyzeGraph: FC = () => {
|
|||
);
|
||||
const filters = useMemo(() => ({ from, to }), [from, to]);
|
||||
|
||||
// TODO as part of https://github.com/elastic/security-team/issues/7032
|
||||
// bring back no data message if needed
|
||||
|
||||
return (
|
||||
<div data-test-subj={ANALYZER_GRAPH_TEST_ID}>
|
||||
<Resolver
|
||||
|
|
|
@ -40,15 +40,18 @@ jest.mock('react-redux', () => {
|
|||
const USER_TEST_ID = EXPANDABLE_PANEL_CONTENT_TEST_ID(USER_DETAILS_TEST_ID);
|
||||
const HOST_TEST_ID = EXPANDABLE_PANEL_CONTENT_TEST_ID(HOST_DETAILS_TEST_ID);
|
||||
|
||||
const renderEntitiesDetails = (contextValue: LeftPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider value={contextValue}>
|
||||
<EntitiesDetails />
|
||||
</LeftPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<EntitiesDetails />', () => {
|
||||
it('renders entities details correctly', () => {
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider value={mockContextValue}>
|
||||
<EntitiesDetails />
|
||||
</LeftPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId, queryByTestId } = renderEntitiesDetails(mockContextValue);
|
||||
expect(getByTestId(ENTITIES_DETAILS_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(USER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(HOST_TEST_ID)).toBeInTheDocument();
|
||||
|
@ -56,19 +59,12 @@ describe('<EntitiesDetails />', () => {
|
|||
});
|
||||
|
||||
it('should render no data message if user name and host name are not available', () => {
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider
|
||||
value={{
|
||||
...mockContextValue,
|
||||
getFieldsData: (fieldName) =>
|
||||
fieldName === '@timestamp' ? ['2022-07-25T08:20:18.966Z'] : [],
|
||||
}}
|
||||
>
|
||||
<EntitiesDetails />
|
||||
</LeftPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const contextValue = {
|
||||
...mockContextValue,
|
||||
getFieldsData: (fieldName: string) =>
|
||||
fieldName === '@timestamp' ? ['2022-07-25T08:20:18.966Z'] : [],
|
||||
};
|
||||
const { getByTestId, queryByTestId } = renderEntitiesDetails(contextValue);
|
||||
expect(getByTestId(ENTITIES_DETAILS_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(ENTITIES_DETAILS_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
'Host and user information are unavailable for this alert.'
|
||||
|
@ -78,27 +74,20 @@ describe('<EntitiesDetails />', () => {
|
|||
});
|
||||
|
||||
it('does not render user and host details if @timestamp is not available', () => {
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider
|
||||
value={{
|
||||
...mockContextValue,
|
||||
getFieldsData: (fieldName) => {
|
||||
switch (fieldName) {
|
||||
case 'host.name':
|
||||
return ['host1'];
|
||||
case 'user.name':
|
||||
return ['user1'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
},
|
||||
}}
|
||||
>
|
||||
<EntitiesDetails />
|
||||
</LeftPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const contextValue = {
|
||||
...mockContextValue,
|
||||
getFieldsData: (fieldName: string) => {
|
||||
switch (fieldName) {
|
||||
case 'host.name':
|
||||
return ['host1'];
|
||||
case 'user.name':
|
||||
return ['user1'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
},
|
||||
};
|
||||
const { getByTestId, queryByTestId } = renderEntitiesDetails(contextValue);
|
||||
expect(getByTestId(ENTITIES_DETAILS_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(ENTITIES_DETAILS_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
'Host and user information are unavailable for this alert.'
|
||||
|
|
|
@ -121,6 +121,14 @@ const mockRelatedUsersResponse = {
|
|||
relatedUsers: [{ user: 'test user', ip: ['100.XXX.XXX'], risk: RiskSeverity.low }],
|
||||
loading: false,
|
||||
};
|
||||
|
||||
const renderHostDetails = () =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<HostDetails />', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
@ -131,21 +139,13 @@ describe('<HostDetails />', () => {
|
|||
});
|
||||
|
||||
it('should render host details correctly', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHostDetails();
|
||||
expect(getByTestId(EXPANDABLE_PANEL_CONTENT_TEST_ID(HOST_DETAILS_TEST_ID))).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('Host overview', () => {
|
||||
it('should render the HostOverview with correct dates and indices', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHostDetails();
|
||||
expect(mockUseHostDetails).toBeCalledWith({
|
||||
id: 'entities-hosts-details-uuid',
|
||||
startDate: from,
|
||||
|
@ -164,32 +164,20 @@ describe('<HostDetails />', () => {
|
|||
});
|
||||
mockUseRiskScore.mockReturnValue({ data: [], isAuthorized: true });
|
||||
|
||||
const { getByText } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByText } = renderHostDetails();
|
||||
expect(getByText('Host risk score')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render host risk score when unauthorized', () => {
|
||||
mockUseRiskScore.mockReturnValue({ data: [], isAuthorized: false });
|
||||
const { queryByText } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryByText } = renderHostDetails();
|
||||
expect(queryByText('Host risk score')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Related users', () => {
|
||||
it('should render the related user table with correct dates and indices', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHostDetails();
|
||||
expect(mockUseHostsRelatedUsers).toBeCalledWith({
|
||||
from: timestamp,
|
||||
hostName: 'test host',
|
||||
|
@ -206,11 +194,7 @@ describe('<HostDetails />', () => {
|
|||
});
|
||||
mockUseHasSecurityCapability.mockReturnValue(true);
|
||||
|
||||
const { queryAllByRole } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryAllByRole } = renderHostDetails();
|
||||
expect(queryAllByRole('columnheader').length).toBe(3);
|
||||
expect(queryAllByRole('row')[1].textContent).toContain('test user');
|
||||
expect(queryAllByRole('row')[1].textContent).toContain('100.XXX.XXX');
|
||||
|
@ -224,20 +208,12 @@ describe('<HostDetails />', () => {
|
|||
});
|
||||
mockUseHasSecurityCapability.mockReturnValue(false);
|
||||
|
||||
const { queryAllByRole } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryAllByRole } = renderHostDetails();
|
||||
expect(queryAllByRole('columnheader').length).toBe(2);
|
||||
});
|
||||
|
||||
it('should not render host risk score column when license is not valid', () => {
|
||||
const { queryAllByRole } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryAllByRole } = renderHostDetails();
|
||||
expect(queryAllByRole('columnheader').length).toBe(2);
|
||||
});
|
||||
|
||||
|
@ -248,11 +224,7 @@ describe('<HostDetails />', () => {
|
|||
loading: false,
|
||||
});
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<HostDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHostDetails();
|
||||
expect(getByTestId(HOST_DETAILS_RELATED_USERS_TABLE_TEST_ID).textContent).toContain(
|
||||
'No users identified'
|
||||
);
|
||||
|
|
|
@ -15,9 +15,9 @@ import {
|
|||
PREVALENCE_DETAILS_TABLE_DOC_COUNT_CELL_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_NO_DATA_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_UPSELL_TEST_ID,
|
||||
PREVALENCE_DETAILS_UPSELL_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_USER_PREVALENCE_CELL_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_VALUE_CELL_TEST_ID,
|
||||
} from './test_ids';
|
||||
|
@ -113,8 +113,8 @@ describe('PrevalenceDetails', () => {
|
|||
expect(
|
||||
getAllByTestId(PREVALENCE_DETAILS_TABLE_USER_PREVALENCE_CELL_TEST_ID).length
|
||||
).toBeGreaterThan(1);
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_TABLE_UPSELL_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_UPSELL_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render formatted numbers for the alert and document count columns', () => {
|
||||
|
@ -198,7 +198,7 @@ describe('PrevalenceDetails', () => {
|
|||
expect(
|
||||
getAllByTestId(PREVALENCE_DETAILS_TABLE_USER_PREVALENCE_CELL_TEST_ID).length
|
||||
).toBeGreaterThan(1);
|
||||
expect(getByTestId(PREVALENCE_DETAILS_TABLE_UPSELL_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(PREVALENCE_DETAILS_UPSELL_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render loading', () => {
|
||||
|
@ -211,8 +211,8 @@ describe('PrevalenceDetails', () => {
|
|||
const { getByTestId, queryByTestId } = renderPrevalenceDetails();
|
||||
|
||||
expect(getByTestId(PREVALENCE_DETAILS_LOADING_TEST_ID)).toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_TABLE_UPSELL_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_UPSELL_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render no data message if call errors out', () => {
|
||||
|
@ -224,8 +224,8 @@ describe('PrevalenceDetails', () => {
|
|||
|
||||
const { getByTestId, queryByTestId } = renderPrevalenceDetails();
|
||||
|
||||
expect(getByTestId(PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
expect(getByTestId(PREVALENCE_DETAILS_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(PREVALENCE_DETAILS_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
'No prevalence data available.'
|
||||
);
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_LOADING_TEST_ID)).not.toBeInTheDocument();
|
||||
|
@ -240,8 +240,8 @@ describe('PrevalenceDetails', () => {
|
|||
|
||||
const { getByTestId, queryByTestId } = renderPrevalenceDetails();
|
||||
|
||||
expect(getByTestId(PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
expect(getByTestId(PREVALENCE_DETAILS_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(PREVALENCE_DETAILS_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
'No prevalence data available.'
|
||||
);
|
||||
expect(queryByTestId(PREVALENCE_DETAILS_LOADING_TEST_ID)).not.toBeInTheDocument();
|
||||
|
|
|
@ -35,10 +35,10 @@ import {
|
|||
PREVALENCE_DETAILS_TABLE_VALUE_CELL_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_FIELD_CELL_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_USER_PREVALENCE_CELL_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID,
|
||||
PREVALENCE_DETAILS_NO_DATA_TEST_ID,
|
||||
PREVALENCE_DETAILS_DATE_PICKER_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_TEST_ID,
|
||||
PREVALENCE_DETAILS_TABLE_UPSELL_TEST_ID,
|
||||
PREVALENCE_DETAILS_UPSELL_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { useLeftPanelContext } from '../context';
|
||||
import {
|
||||
|
@ -334,7 +334,7 @@ export const PrevalenceDetails: React.FC = () => {
|
|||
|
||||
const upsell = (
|
||||
<>
|
||||
<EuiCallOut data-test-subj={PREVALENCE_DETAILS_TABLE_UPSELL_TEST_ID}>
|
||||
<EuiCallOut data-test-subj={PREVALENCE_DETAILS_UPSELL_TEST_ID}>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.left.insights.prevalence.tableAlertUpsellDescription"
|
||||
defaultMessage="Preview of a {subscription} feature showing host and user prevalence."
|
||||
|
@ -372,7 +372,7 @@ export const PrevalenceDetails: React.FC = () => {
|
|||
data-test-subj={PREVALENCE_DETAILS_TABLE_TEST_ID}
|
||||
/>
|
||||
) : (
|
||||
<p data-test-subj={PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID}>
|
||||
<p data-test-subj={PREVALENCE_DETAILS_NO_DATA_TEST_ID}>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.left.insights.prevalence.noDataDescription"
|
||||
defaultMessage="No prevalence data available."
|
||||
|
|
|
@ -39,6 +39,18 @@ const TITLE_TEXT = EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID(
|
|||
CORRELATIONS_DETAILS_BY_ANCESTRY_SECTION_TEST_ID
|
||||
);
|
||||
|
||||
const renderRelatedAlertsByAncestry = () =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsByAncestry
|
||||
documentId={documentId}
|
||||
indices={indices}
|
||||
scopeId={scopeId}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<RelatedAlertsByAncestry />', () => {
|
||||
it('should render many related alerts correctly', () => {
|
||||
(useFetchRelatedAlertsByAncestry as jest.Mock).mockReturnValue({
|
||||
|
@ -74,16 +86,7 @@ describe('<RelatedAlertsByAncestry />', () => {
|
|||
],
|
||||
});
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsByAncestry
|
||||
documentId={documentId}
|
||||
indices={indices}
|
||||
scopeId={scopeId}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderRelatedAlertsByAncestry();
|
||||
expect(getByTestId(TOGGLE_ICON)).toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_ICON)).toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_TEXT)).toBeInTheDocument();
|
||||
|
@ -99,16 +102,7 @@ describe('<RelatedAlertsByAncestry />', () => {
|
|||
error: true,
|
||||
});
|
||||
|
||||
const { container } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsByAncestry
|
||||
documentId={documentId}
|
||||
indices={indices}
|
||||
scopeId={scopeId}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
const { container } = renderRelatedAlertsByAncestry();
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
||||
|
@ -125,16 +119,7 @@ describe('<RelatedAlertsByAncestry />', () => {
|
|||
data: [],
|
||||
});
|
||||
|
||||
const { getByText } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsByAncestry
|
||||
documentId={documentId}
|
||||
indices={indices}
|
||||
scopeId={scopeId}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByText } = renderRelatedAlertsByAncestry();
|
||||
expect(getByText('No alerts related by ancestry.')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,6 +38,17 @@ const TITLE_TEXT = EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID(
|
|||
CORRELATIONS_DETAILS_BY_SOURCE_SECTION_TEST_ID
|
||||
);
|
||||
|
||||
const renderRelatedAlertsBySameSourceEvent = () =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsBySameSourceEvent
|
||||
originalEventId={originalEventId}
|
||||
scopeId={scopeId}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<RelatedAlertsBySameSourceEvent />', () => {
|
||||
it('should render component correctly', () => {
|
||||
(useFetchRelatedAlertsBySameSourceEvent as jest.Mock).mockReturnValue({
|
||||
|
@ -73,15 +84,7 @@ describe('<RelatedAlertsBySameSourceEvent />', () => {
|
|||
],
|
||||
});
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsBySameSourceEvent
|
||||
originalEventId={originalEventId}
|
||||
scopeId={scopeId}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderRelatedAlertsBySameSourceEvent();
|
||||
expect(getByTestId(TOGGLE_ICON)).toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_ICON)).toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_TEXT)).toBeInTheDocument();
|
||||
|
@ -97,15 +100,7 @@ describe('<RelatedAlertsBySameSourceEvent />', () => {
|
|||
error: true,
|
||||
});
|
||||
|
||||
const { container } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsBySameSourceEvent
|
||||
originalEventId={originalEventId}
|
||||
scopeId={scopeId}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
const { container } = renderRelatedAlertsBySameSourceEvent();
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
||||
|
@ -122,15 +117,7 @@ describe('<RelatedAlertsBySameSourceEvent />', () => {
|
|||
data: [],
|
||||
});
|
||||
|
||||
const { getByText } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsBySameSourceEvent
|
||||
originalEventId={originalEventId}
|
||||
scopeId={scopeId}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByText } = renderRelatedAlertsBySameSourceEvent();
|
||||
expect(getByText('No related source events.')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,6 +38,13 @@ const TITLE_TEXT = EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID(
|
|||
CORRELATIONS_DETAILS_BY_SESSION_SECTION_TEST_ID
|
||||
);
|
||||
|
||||
const renderRelatedAlertsBySession = () =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsBySession entityId={entityId} scopeId={scopeId} eventId={eventId} />
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<RelatedAlertsBySession />', () => {
|
||||
it('should render component correctly', () => {
|
||||
(useFetchRelatedAlertsBySession as jest.Mock).mockReturnValue({
|
||||
|
@ -73,11 +80,7 @@ describe('<RelatedAlertsBySession />', () => {
|
|||
],
|
||||
});
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsBySession entityId={entityId} scopeId={scopeId} eventId={eventId} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderRelatedAlertsBySession();
|
||||
expect(getByTestId(TOGGLE_ICON)).toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_ICON)).toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_TEXT)).toBeInTheDocument();
|
||||
|
@ -93,11 +96,7 @@ describe('<RelatedAlertsBySession />', () => {
|
|||
error: true,
|
||||
});
|
||||
|
||||
const { container } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsBySession entityId={entityId} scopeId={scopeId} eventId={eventId} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { container } = renderRelatedAlertsBySession();
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
||||
|
@ -114,11 +113,7 @@ describe('<RelatedAlertsBySession />', () => {
|
|||
data: [],
|
||||
});
|
||||
|
||||
const { getByText } = render(
|
||||
<TestProviders>
|
||||
<RelatedAlertsBySession entityId={entityId} scopeId={scopeId} eventId={eventId} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByText } = renderRelatedAlertsBySession();
|
||||
expect(getByText('No alerts related by session.')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,18 +10,26 @@ import { render } from '@testing-library/react';
|
|||
import '@testing-library/jest-dom';
|
||||
import { LeftPanelContext } from '../context';
|
||||
import { rawEventData, TestProviders } from '../../../common/mock';
|
||||
import { RESPONSE_DETAILS_TEST_ID, RESPONSE_EMPTY_TEST_ID } from './test_ids';
|
||||
import { RESPONSE_DETAILS_TEST_ID, RESPONSE_NO_DATA_TEST_ID } from './test_ids';
|
||||
import { ResponseDetails } from './response_details';
|
||||
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features';
|
||||
|
||||
jest.mock('../../../common/hooks/use_experimental_features');
|
||||
|
||||
jest.mock('../../../common/lib/kibana', () => {
|
||||
const originalModule = jest.requireActual('../../../common/lib/kibana');
|
||||
return {
|
||||
...originalModule,
|
||||
useKibana: jest.fn().mockReturnValue({
|
||||
services: {
|
||||
data: {
|
||||
search: {
|
||||
search: () => ({
|
||||
subscribe: () => ({
|
||||
unsubscribe: jest.fn(),
|
||||
}),
|
||||
}),
|
||||
},
|
||||
},
|
||||
osquery: {
|
||||
OsqueryResults: jest.fn().mockReturnValue(null),
|
||||
fetchAllLiveQueries: jest.fn().mockReturnValue({
|
||||
|
@ -76,7 +84,7 @@ const contextWithResponseActions = {
|
|||
};
|
||||
|
||||
// Renders System Under Test
|
||||
const renderSUT = (contextValue: LeftPanelContext) =>
|
||||
const renderResponseDetails = (contextValue: LeftPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider value={contextValue}>
|
||||
|
@ -98,34 +106,37 @@ describe('<ResponseDetails />', () => {
|
|||
useIsExperimentalFeatureEnabledMock
|
||||
);
|
||||
});
|
||||
|
||||
it('should render the view with response actions', () => {
|
||||
const wrapper = renderSUT(contextWithResponseActions);
|
||||
const wrapper = renderResponseDetails(contextWithResponseActions);
|
||||
|
||||
expect(wrapper.getByTestId(RESPONSE_DETAILS_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.getByTestId('responseActionsViewWrapper')).toBeInTheDocument();
|
||||
expect(wrapper.queryByTestId('osqueryViewWrapper')).not.toBeInTheDocument();
|
||||
|
||||
expect(wrapper.queryByTestId(RESPONSE_EMPTY_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(wrapper.queryByTestId(RESPONSE_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render the view with osquery only', () => {
|
||||
featureFlags.responseActionsEnabled = true;
|
||||
featureFlags.endpointResponseActionsEnabled = false;
|
||||
|
||||
const wrapper = renderSUT(contextWithResponseActions);
|
||||
const wrapper = renderResponseDetails(contextWithResponseActions);
|
||||
|
||||
expect(wrapper.getByTestId(RESPONSE_DETAILS_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.queryByTestId('responseActionsViewWrapper')).not.toBeInTheDocument();
|
||||
expect(wrapper.getByTestId('osqueryViewWrapper')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render the empty information', () => {
|
||||
const wrapper = renderSUT(defaultContextValue);
|
||||
const wrapper = renderResponseDetails(defaultContextValue);
|
||||
|
||||
expect(wrapper.getByTestId(RESPONSE_DETAILS_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.queryByTestId('responseActionsViewWrapper')).not.toBeInTheDocument();
|
||||
expect(wrapper.queryByTestId('osqueryViewWrapper')).not.toBeInTheDocument();
|
||||
|
||||
expect(wrapper.getByTestId(RESPONSE_EMPTY_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.getByTestId(RESPONSE_EMPTY_TEST_ID)).toHaveTextContent(
|
||||
expect(wrapper.getByTestId(RESPONSE_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.getByTestId(RESPONSE_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
'There are no response actions defined for this event. To add some, edit the rule’s settings and set up response actionsExternal link(opens in a new tab or window).'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import { EuiLink, EuiSpacer, EuiTitle } from '@elastic/eui';
|
||||
import styled from 'styled-components';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { RESPONSE_DETAILS_TEST_ID, RESPONSE_EMPTY_TEST_ID } from './test_ids';
|
||||
import { RESPONSE_DETAILS_TEST_ID, RESPONSE_NO_DATA_TEST_ID } from './test_ids';
|
||||
import { expandDottedObject } from '../../../../common/utils/expand_dotted';
|
||||
import type {
|
||||
ExpandedEventFieldsObject,
|
||||
|
@ -66,7 +66,7 @@ export const ResponseDetails: React.FC = () => {
|
|||
</EuiTitle>
|
||||
<EuiSpacer size="s" />
|
||||
{!responseActions ? (
|
||||
<InlineBlock data-test-subj={RESPONSE_EMPTY_TEST_ID}>
|
||||
<InlineBlock data-test-subj={RESPONSE_NO_DATA_TEST_ID}>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.left.response.noDataDescription"
|
||||
defaultMessage="There are no response actions defined for this event. To add some, edit the rule’s settings and set up {link}."
|
||||
|
|
|
@ -10,7 +10,7 @@ import { render } from '@testing-library/react';
|
|||
import '@testing-library/jest-dom';
|
||||
import { LeftPanelContext } from '../context';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { SESSION_VIEW_ERROR_TEST_ID, SESSION_VIEW_TEST_ID } from './test_ids';
|
||||
import { SESSION_VIEW_TEST_ID } from './test_ids';
|
||||
import { SessionView } from './session_view';
|
||||
import {
|
||||
ANCESTOR_INDEX,
|
||||
|
@ -46,6 +46,15 @@ jest.mock('../../../common/lib/kibana', () => {
|
|||
};
|
||||
});
|
||||
|
||||
const renderSessionView = (contextValue: LeftPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider value={contextValue}>
|
||||
<SessionView />
|
||||
</LeftPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<SessionView />', () => {
|
||||
it('renders session view correctly', () => {
|
||||
const contextValue = {
|
||||
|
@ -53,13 +62,7 @@ describe('<SessionView />', () => {
|
|||
indexName: '.ds-logs-endpoint.events.process-default',
|
||||
} as unknown as LeftPanelContext;
|
||||
|
||||
const wrapper = render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider value={contextValue}>
|
||||
<SessionView />
|
||||
</LeftPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const wrapper = renderSessionView(contextValue);
|
||||
expect(wrapper.getByTestId(SESSION_VIEW_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
@ -69,30 +72,7 @@ describe('<SessionView />', () => {
|
|||
indexName: '.alerts-security', // it should prioritize KIBANA_ANCESTOR_INDEX above indexName
|
||||
} as unknown as LeftPanelContext;
|
||||
|
||||
const wrapper = render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider value={contextValue}>
|
||||
<SessionView />
|
||||
</LeftPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const wrapper = renderSessionView(contextValue);
|
||||
expect(wrapper.getByTestId(SESSION_VIEW_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render error message on null eventId', () => {
|
||||
const contextValue = {
|
||||
getFieldsData: () => {},
|
||||
} as unknown as LeftPanelContext;
|
||||
|
||||
const wrapper = render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider value={contextValue}>
|
||||
<SessionView />
|
||||
</LeftPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
expect(wrapper.getByTestId(SESSION_VIEW_ERROR_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.getByText('Unable to display session view')).toBeInTheDocument();
|
||||
expect(wrapper.getByText('There was an error displaying session view')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,15 +7,13 @@
|
|||
|
||||
import type { FC } from 'react';
|
||||
import React from 'react';
|
||||
import { EuiEmptyPrompt } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import {
|
||||
ANCESTOR_INDEX,
|
||||
ENTRY_LEADER_ENTITY_ID,
|
||||
ENTRY_LEADER_START,
|
||||
} from '../../shared/constants/field_names';
|
||||
import { getField } from '../../shared/utils';
|
||||
import { SESSION_VIEW_ERROR_TEST_ID, SESSION_VIEW_TEST_ID } from './test_ids';
|
||||
import { SESSION_VIEW_TEST_ID } from './test_ids';
|
||||
import { useKibana } from '../../../common/lib/kibana';
|
||||
import { useLeftPanelContext } from '../context';
|
||||
|
||||
|
@ -29,37 +27,12 @@ export const SessionView: FC = () => {
|
|||
const { getFieldsData, indexName } = useLeftPanelContext();
|
||||
|
||||
const ancestorIndex = getField(getFieldsData(ANCESTOR_INDEX)); // e.g in case of alert, we want to grab it's origin index
|
||||
const sessionEntityId = getField(getFieldsData(ENTRY_LEADER_ENTITY_ID));
|
||||
const sessionStartTime = getField(getFieldsData(ENTRY_LEADER_START));
|
||||
const sessionEntityId = getField(getFieldsData(ENTRY_LEADER_ENTITY_ID)) || '';
|
||||
const sessionStartTime = getField(getFieldsData(ENTRY_LEADER_START)) || '';
|
||||
const index = ancestorIndex || indexName;
|
||||
|
||||
if (!index || !sessionEntityId || !sessionStartTime) {
|
||||
return (
|
||||
<EuiEmptyPrompt
|
||||
iconType="error"
|
||||
color="danger"
|
||||
title={
|
||||
<h2>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.left.visualize.sessionView.errorMessageTitle"
|
||||
defaultMessage="Unable to display {title}"
|
||||
values={{ title: 'session view' }}
|
||||
/>
|
||||
</h2>
|
||||
}
|
||||
body={
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.left.visualize.sessionView.errorMessageDescription"
|
||||
defaultMessage="There was an error displaying {message}"
|
||||
values={{ message: 'session view' }}
|
||||
/>
|
||||
</p>
|
||||
}
|
||||
data-test-subj={SESSION_VIEW_ERROR_TEST_ID}
|
||||
/>
|
||||
);
|
||||
}
|
||||
// TODO as part of https://github.com/elastic/security-team/issues/7031
|
||||
// bring back no data message if needed
|
||||
|
||||
return (
|
||||
<div data-test-subj={SESSION_VIEW_TEST_ID}>
|
||||
|
|
|
@ -5,23 +5,24 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { PREFIX } from '../../shared/test_ids';
|
||||
|
||||
/* Visualization tab */
|
||||
|
||||
const PREFIX = 'securitySolutionDocumentDetailsFlyout' as const;
|
||||
|
||||
export const ANALYZER_GRAPH_TEST_ID = `${PREFIX}AnalyzerGraph` as const;
|
||||
export const ANALYZE_GRAPH_ERROR_TEST_ID = `${PREFIX}AnalyzerGraphError` as const;
|
||||
export const SESSION_VIEW_TEST_ID = `${PREFIX}SessionView` as const;
|
||||
export const SESSION_VIEW_ERROR_TEST_ID = `${PREFIX}SessionViewError` as const;
|
||||
|
||||
/* Insights tab */
|
||||
|
||||
/* Prevalence */
|
||||
|
||||
const PREVALENCE_DETAILS_TEST_ID = `${PREFIX}PrevalenceDetails` as const;
|
||||
export const PREVALENCE_DETAILS_DATE_PICKER_TEST_ID =
|
||||
`${PREFIX}PrevalenceDetailsDatePicker` as const;
|
||||
export const PREVALENCE_DETAILS_TABLE_TEST_ID = `${PREFIX}PrevalenceDetailsTable` as const;
|
||||
export const PREVALENCE_DETAILS_LOADING_TEST_ID = `${PREFIX}PrevalenceDetailsLoading` as const;
|
||||
`${PREVALENCE_DETAILS_TEST_ID}DatePicker` as const;
|
||||
export const PREVALENCE_DETAILS_LOADING_TEST_ID = `${PREVALENCE_DETAILS_TEST_ID}Loading` as const;
|
||||
export const PREVALENCE_DETAILS_NO_DATA_TEST_ID = `${PREVALENCE_DETAILS_TEST_ID}NoData` as const;
|
||||
export const PREVALENCE_DETAILS_UPSELL_TEST_ID = `${PREVALENCE_DETAILS_TEST_ID}Upsell` as const;
|
||||
export const PREVALENCE_DETAILS_TABLE_TEST_ID = `${PREVALENCE_DETAILS_TEST_ID}Table` as const;
|
||||
export const PREVALENCE_DETAILS_TABLE_FIELD_CELL_TEST_ID =
|
||||
`${PREVALENCE_DETAILS_TABLE_TEST_ID}FieldCell` as const;
|
||||
export const PREVALENCE_DETAILS_TABLE_VALUE_CELL_TEST_ID =
|
||||
|
@ -34,33 +35,31 @@ export const PREVALENCE_DETAILS_TABLE_HOST_PREVALENCE_CELL_TEST_ID =
|
|||
`${PREVALENCE_DETAILS_TABLE_TEST_ID}HostPrevalenceCell` as const;
|
||||
export const PREVALENCE_DETAILS_TABLE_USER_PREVALENCE_CELL_TEST_ID =
|
||||
`${PREVALENCE_DETAILS_TABLE_TEST_ID}UserPrevalenceCell` as const;
|
||||
export const PREVALENCE_DETAILS_TABLE_ERROR_TEST_ID =
|
||||
`${PREVALENCE_DETAILS_TABLE_TEST_ID}Error` as const;
|
||||
export const PREVALENCE_DETAILS_TABLE_NO_DATA_TEST_ID =
|
||||
`${PREVALENCE_DETAILS_TABLE_TEST_ID}NoData` as const;
|
||||
export const PREVALENCE_DETAILS_TABLE_UPSELL_TEST_ID =
|
||||
`${PREVALENCE_DETAILS_TABLE_TEST_ID}Upsell` as const;
|
||||
|
||||
/* Entities */
|
||||
|
||||
export const ENTITIES_DETAILS_TEST_ID = `${PREFIX}EntitiesDetails` as const;
|
||||
export const ENTITIES_DETAILS_NO_DATA_TEST_ID = `${ENTITIES_DETAILS_TEST_ID}NoData` as const;
|
||||
export const USER_DETAILS_TEST_ID = `${PREFIX}UsersDetails` as const;
|
||||
export const USER_DETAILS_INFO_TEST_ID = 'user-overview';
|
||||
export const USER_DETAILS_RELATED_HOSTS_TABLE_TEST_ID =
|
||||
`${PREFIX}UsersDetailsRelatedHostsTable` as const;
|
||||
`${USER_DETAILS_TEST_ID}RelatedHostsTable` as const;
|
||||
export const USER_DETAILS_INFO_TEST_ID = 'user-overview' as const;
|
||||
export const HOST_DETAILS_TEST_ID = `${PREFIX}HostsDetails` as const;
|
||||
export const HOST_DETAILS_INFO_TEST_ID = 'host-overview';
|
||||
export const HOST_DETAILS_RELATED_USERS_TABLE_TEST_ID =
|
||||
`${PREFIX}HostsDetailsRelatedUsersTable` as const;
|
||||
`${HOST_DETAILS_TEST_ID}RelatedUsersTable` as const;
|
||||
export const HOST_DETAILS_INFO_TEST_ID = 'host-overview' as const;
|
||||
|
||||
export const CORRELATIONS_DETAILS_TEST_ID = `${PREFIX}CorrelationsDetails` as const;
|
||||
export const CORRELATIONS_DETAILS_NO_DATA_TEST_ID =
|
||||
`${CORRELATIONS_DETAILS_TEST_ID}NoData` as const;
|
||||
/* Threat Intelligence */
|
||||
|
||||
export const THREAT_INTELLIGENCE_DETAILS_ENRICHMENTS_TEST_ID = `threat-match-detected` as const;
|
||||
export const THREAT_INTELLIGENCE_DETAILS_SPINNER_TEST_ID =
|
||||
`${PREFIX}ThreatIntelligenceDetailsLoadingSpinner` as const;
|
||||
export const THREAT_INTELLIGENCE_DETAILS_LOADING_TEST_ID =
|
||||
`${PREFIX}ThreatIntelligenceDetailsLoading` as const;
|
||||
|
||||
/* Correlations */
|
||||
|
||||
const CORRELATIONS_DETAILS_TEST_ID = `${PREFIX}CorrelationsDetails` as const;
|
||||
export const CORRELATIONS_DETAILS_NO_DATA_TEST_ID =
|
||||
`${CORRELATIONS_DETAILS_TEST_ID}NoData` as const;
|
||||
|
||||
export const CORRELATIONS_DETAILS_BY_ANCESTRY_SECTION_TEST_ID =
|
||||
`${CORRELATIONS_DETAILS_TEST_ID}AlertsByAncestrySection` as const;
|
||||
|
@ -82,9 +81,14 @@ export const CORRELATIONS_DETAILS_SUPPRESSED_ALERTS_SECTION_TEST_ID =
|
|||
`${CORRELATIONS_DETAILS_TEST_ID}SuppressedAlertsSection` as const;
|
||||
export const SUPPRESSED_ALERTS_SECTION_TECHNICAL_PREVIEW_TEST_ID =
|
||||
`${CORRELATIONS_DETAILS_TEST_ID}SuppressedAlertsSectionTechnicalPreview` as const;
|
||||
export const RESPONSE_BASE_TEST_ID = `${PREFIX}Responses` as const;
|
||||
export const RESPONSE_DETAILS_TEST_ID = `${RESPONSE_BASE_TEST_ID}Details` as const;
|
||||
export const RESPONSE_EMPTY_TEST_ID = `${RESPONSE_BASE_TEST_ID}Empty` as const;
|
||||
|
||||
export const INVESTIGATION_GUIDE_LOADING_TEST_ID = `${PREFIX}InvestigationGuideLoading`;
|
||||
export const INVESTIGATION_GUIDE_NO_DATA_TEST_ID = `${PREFIX}NoData`;
|
||||
/* Response */
|
||||
|
||||
const RESPONSE_TEST_ID = `${PREFIX}Response` as const;
|
||||
export const RESPONSE_DETAILS_TEST_ID = `${RESPONSE_TEST_ID}Details` as const;
|
||||
export const RESPONSE_NO_DATA_TEST_ID = `${RESPONSE_TEST_ID}NoData` as const;
|
||||
|
||||
/* Investigation */
|
||||
|
||||
export const INVESTIGATION_GUIDE_LOADING_TEST_ID = `${PREFIX}InvestigationGuideLoading` as const;
|
||||
export const INVESTIGATION_GUIDE_NO_DATA_TEST_ID = `${PREFIX}NoData` as const;
|
||||
|
|
|
@ -12,7 +12,7 @@ import { LeftPanelContext } from '../context';
|
|||
import { TestProviders } from '../../../common/mock';
|
||||
import {
|
||||
THREAT_INTELLIGENCE_DETAILS_ENRICHMENTS_TEST_ID,
|
||||
THREAT_INTELLIGENCE_DETAILS_SPINNER_TEST_ID,
|
||||
THREAT_INTELLIGENCE_DETAILS_LOADING_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { ThreatIntelligenceDetails } from './threat_intelligence_details';
|
||||
import { useThreatIntelligenceDetails } from '../hooks/use_threat_intelligence_details';
|
||||
|
@ -38,7 +38,7 @@ const defaultContextValue = {
|
|||
} as unknown as LeftPanelContext;
|
||||
|
||||
// Renders System Under Test
|
||||
const renderSUT = (contextValue: LeftPanelContext) =>
|
||||
const renderThreatIntelligenceDetails = (contextValue: LeftPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<LeftPanelContext.Provider value={contextValue}>
|
||||
|
@ -59,7 +59,7 @@ describe('<ThreatIntelligenceDetails />', () => {
|
|||
eventFields: {},
|
||||
});
|
||||
|
||||
const wrapper = renderSUT(defaultContextValue);
|
||||
const wrapper = renderThreatIntelligenceDetails(defaultContextValue);
|
||||
|
||||
expect(
|
||||
wrapper.getByTestId(THREAT_INTELLIGENCE_DETAILS_ENRICHMENTS_TEST_ID)
|
||||
|
@ -79,9 +79,9 @@ describe('<ThreatIntelligenceDetails />', () => {
|
|||
eventFields: {},
|
||||
});
|
||||
|
||||
const wrapper = renderSUT(defaultContextValue);
|
||||
const wrapper = renderThreatIntelligenceDetails(defaultContextValue);
|
||||
|
||||
expect(wrapper.getByTestId(THREAT_INTELLIGENCE_DETAILS_SPINNER_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.getByTestId(THREAT_INTELLIGENCE_DETAILS_LOADING_TEST_ID)).toBeInTheDocument();
|
||||
|
||||
expect(useThreatIntelligenceDetails).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ import isEmpty from 'lodash/isEmpty';
|
|||
import { EnrichmentRangePicker } from '../../../common/components/event_details/cti_details/enrichment_range_picker';
|
||||
import { ThreatDetailsView } from '../../../common/components/event_details/cti_details/threat_details_view';
|
||||
import { useThreatIntelligenceDetails } from '../hooks/use_threat_intelligence_details';
|
||||
import { THREAT_INTELLIGENCE_DETAILS_SPINNER_TEST_ID } from './test_ids';
|
||||
import { THREAT_INTELLIGENCE_DETAILS_LOADING_TEST_ID } from './test_ids';
|
||||
|
||||
export const THREAT_INTELLIGENCE_TAB_ID = 'threat-intelligence-details';
|
||||
|
||||
|
@ -33,7 +33,7 @@ export const ThreatIntelligenceDetails: React.FC = () => {
|
|||
return (
|
||||
<EuiFlexGroup
|
||||
justifyContent="spaceAround"
|
||||
data-test-subj={THREAT_INTELLIGENCE_DETAILS_SPINNER_TEST_ID}
|
||||
data-test-subj={THREAT_INTELLIGENCE_DETAILS_LOADING_TEST_ID}
|
||||
>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiLoadingSpinner size="m" />
|
||||
|
|
|
@ -119,7 +119,14 @@ const mockRelatedHostsResponse = {
|
|||
loading: false,
|
||||
};
|
||||
|
||||
describe('<HostDetails />', () => {
|
||||
const renderUserDetails = () =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<UserDetails />', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockUseMlUserPermissions.mockReturnValue({ isPlatinumOrTrialLicense: false, capabilities: {} });
|
||||
|
@ -129,21 +136,13 @@ describe('<HostDetails />', () => {
|
|||
});
|
||||
|
||||
it('should render host details correctly', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderUserDetails();
|
||||
expect(getByTestId(EXPANDABLE_PANEL_CONTENT_TEST_ID(USER_DETAILS_TEST_ID))).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('Host overview', () => {
|
||||
it('should render the HostOverview with correct dates and indices', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderUserDetails();
|
||||
expect(mockUseObservedUserDetails).toBeCalledWith({
|
||||
id: 'entities-users-details-uuid',
|
||||
startDate: from,
|
||||
|
@ -160,32 +159,20 @@ describe('<HostDetails />', () => {
|
|||
isPlatinumOrTrialLicense: true,
|
||||
capabilities: {},
|
||||
});
|
||||
const { getByText } = render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByText } = renderUserDetails();
|
||||
expect(getByText('User risk score')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render user risk score when license is not valid', () => {
|
||||
mockUseRiskScore.mockReturnValue({ data: [], isAuthorized: false });
|
||||
const { queryByText } = render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryByText } = renderUserDetails();
|
||||
expect(queryByText('User risk score')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Related hosts', () => {
|
||||
it('should render the related host table with correct dates and indices', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderUserDetails();
|
||||
expect(mockUseUsersRelatedHosts).toBeCalledWith({
|
||||
from: timestamp,
|
||||
userName: 'test user',
|
||||
|
@ -200,11 +187,7 @@ describe('<HostDetails />', () => {
|
|||
isPlatinumOrTrialLicense: true,
|
||||
capabilities: {},
|
||||
});
|
||||
const { queryAllByRole } = render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryAllByRole } = renderUserDetails();
|
||||
expect(queryAllByRole('columnheader').length).toBe(3);
|
||||
expect(queryAllByRole('row')[1].textContent).toContain('test host');
|
||||
expect(queryAllByRole('row')[1].textContent).toContain('100.XXX.XXX');
|
||||
|
@ -212,11 +195,7 @@ describe('<HostDetails />', () => {
|
|||
});
|
||||
|
||||
it('should not render host risk score column when license is not valid', () => {
|
||||
const { queryAllByRole } = render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryAllByRole } = renderUserDetails();
|
||||
expect(queryAllByRole('columnheader').length).toBe(2);
|
||||
});
|
||||
|
||||
|
@ -227,11 +206,7 @@ describe('<HostDetails />', () => {
|
|||
loading: false,
|
||||
});
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<UserDetails {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderUserDetails();
|
||||
expect(getByTestId(USER_DETAILS_RELATED_HOSTS_TABLE_TEST_ID).textContent).toContain(
|
||||
'No hosts identified'
|
||||
);
|
||||
|
|
|
@ -17,7 +17,7 @@ jest.mock('../services/find_alerts');
|
|||
|
||||
describe('useFetchAlerts', () => {
|
||||
beforeEach(() => {
|
||||
jest.mocked(useKibana).mockReturnValue({
|
||||
(useKibana as jest.Mock).mockReturnValue({
|
||||
services: {
|
||||
data: {
|
||||
search: {
|
||||
|
@ -25,8 +25,7 @@ describe('useFetchAlerts', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any);
|
||||
});
|
||||
});
|
||||
|
||||
it('fetches alerts and handles loading state', async () => {
|
||||
|
@ -66,6 +65,9 @@ describe('useFetchAlerts', () => {
|
|||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
);
|
||||
|
||||
// hide console error due to the line after
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
jest
|
||||
.mocked(createFindAlerts)
|
||||
.mockReturnValue(jest.fn().mockRejectedValue(new Error('Fetch failed')));
|
||||
|
|
|
@ -5,31 +5,13 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { ALERT_RISK_SCORE, ALERT_SEVERITY } from '@kbn/rule-data-utils';
|
||||
import { mockBrowserFields } from '../../shared/mocks/mock_browser_fields';
|
||||
import { mockSearchHit } from '../../shared/mocks/mock_search_hit';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { mockDataAsNestedObject } from '../../shared/mocks/mock_data_as_nested_object';
|
||||
import type { LeftPanelContext } from '../context';
|
||||
|
||||
/**
|
||||
* Returns mocked data for field (mock this method: x-pack/plugins/security_solution/public/common/hooks/use_get_fields_data.ts)
|
||||
* @param field
|
||||
* @returns string[]
|
||||
*/
|
||||
export const mockGetFieldsData = (field: string): string[] => {
|
||||
switch (field) {
|
||||
case ALERT_SEVERITY:
|
||||
return ['low'];
|
||||
case ALERT_RISK_SCORE:
|
||||
return ['0'];
|
||||
case 'host.name':
|
||||
return ['host1'];
|
||||
case 'user.name':
|
||||
return ['user1'];
|
||||
case '@timestamp':
|
||||
return ['2022-07-25T08:20:18.966Z'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Mock contextValue for left panel context
|
||||
*/
|
||||
|
@ -37,15 +19,10 @@ export const mockContextValue: LeftPanelContext = {
|
|||
eventId: 'eventId',
|
||||
indexName: 'index',
|
||||
scopeId: 'scopeId',
|
||||
browserFields: {},
|
||||
dataFormattedForFieldBrowser: [],
|
||||
browserFields: mockBrowserFields,
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
getFieldsData: mockGetFieldsData,
|
||||
searchHit: {
|
||||
_id: 'testId',
|
||||
_index: 'testIndex',
|
||||
},
|
||||
dataAsNestedObject: {
|
||||
_id: 'testId',
|
||||
},
|
||||
searchHit: mockSearchHit,
|
||||
dataAsNestedObject: mockDataAsNestedObject,
|
||||
investigationFields: [],
|
||||
};
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const VISUALIZE_TAB_BUTTON_GROUP_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutVisualizeTabButtonGroup';
|
||||
import { PREFIX } from '../../shared/test_ids';
|
||||
|
||||
const VISUALIZE_TAB_TEST_ID = `${PREFIX}VisualizeTab` as const;
|
||||
export const VISUALIZE_TAB_BUTTON_GROUP_TEST_ID = `${VISUALIZE_TAB_TEST_ID}ButtonGroup` as const;
|
||||
export const VISUALIZE_TAB_SESSION_VIEW_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutVisualizeTabSessionViewButton';
|
||||
`${VISUALIZE_TAB_TEST_ID}SessionViewButton` as const;
|
||||
export const VISUALIZE_TAB_GRAPH_ANALYZER_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutVisualizeTabGraphAnalyzerButton';
|
||||
export const INSIGHTS_TAB_BUTTON_GROUP_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInsightsTabButtonGroup';
|
||||
`${VISUALIZE_TAB_TEST_ID}GraphAnalyzerButton` as const;
|
||||
const INSIGHTS_TAB_TEST_ID = `${PREFIX}InsightsTab` as const;
|
||||
export const INSIGHTS_TAB_BUTTON_GROUP_TEST_ID = `${INSIGHTS_TAB_TEST_ID}ButtonGroup` as const;
|
||||
export const INSIGHTS_TAB_ENTITIES_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInsightsTabEntitiesButton';
|
||||
`${INSIGHTS_TAB_TEST_ID}EntitiesButton` as const;
|
||||
export const INSIGHTS_TAB_THREAT_INTELLIGENCE_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInsightsTabThreatIntelligenceButton';
|
||||
`${INSIGHTS_TAB_TEST_ID}ThreatIntelligenceButton` as const;
|
||||
export const INSIGHTS_TAB_PREVALENCE_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInsightsTabPrevalenceButton';
|
||||
`${INSIGHTS_TAB_TEST_ID}PrevalenceButton` as const;
|
||||
export const INSIGHTS_TAB_CORRELATIONS_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInsightsTabCorrelationsButton';
|
||||
export const INVESTIGATION_TAB_CONTENT_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInvestigationsTabContent';
|
||||
export const RESPONSE_TAB_CONTENT_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutResponseTabContent';
|
||||
`${INSIGHTS_TAB_TEST_ID}CorrelationsButton` as const;
|
||||
export const INVESTIGATION_TAB_CONTENT_TEST_ID = `${PREFIX}InvestigationsTabContent` as const;
|
||||
export const RESPONSE_TAB_CONTENT_TEST_ID = `${PREFIX}ResponseTabContent` as const;
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const VISUALIZE_TAB_TEST_ID = 'securitySolutionDocumentDetailsFlyoutVisualizeTab';
|
||||
export const INSIGHTS_TAB_TEST_ID = 'securitySolutionDocumentDetailsFlyoutInsightsTab';
|
||||
export const INVESTIGATION_TAB_TEST_ID = 'securitySolutionDocumentDetailsFlyoutInvestigationTab';
|
||||
export const RESPONSE_TAB_TEST_ID = 'securitySolutionDocumentDetailsFlyoutResponseTab';
|
||||
import { PREFIX } from '../shared/test_ids';
|
||||
|
||||
export const VISUALIZE_TAB_TEST_ID = `${PREFIX}FlyoutVisualizeTab` as const;
|
||||
export const INSIGHTS_TAB_TEST_ID = `${PREFIX}FlyoutInsightsTab` as const;
|
||||
export const INVESTIGATION_TAB_TEST_ID = `${PREFIX}FlyoutInvestigationTab` as const;
|
||||
export const RESPONSE_TAB_TEST_ID = `${PREFIX}FlyoutResponseTab` as const;
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { PreviewPanelContext } from '../context';
|
||||
import { mockContextValue } from '../mocks/mock_preview_panel_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { ALERT_REASON_PREVIEW_BODY_TEST_ID } from './test_ids';
|
||||
import { AlertReasonPreview } from './alert_reason_preview';
|
||||
import { ThemeProvider } from 'styled-components';
|
||||
|
@ -24,7 +24,7 @@ const panelContextValue = {
|
|||
describe('<AlertReasonPreview />', () => {
|
||||
it('should render alert reason preview', () => {
|
||||
const { getByTestId } = render(
|
||||
<IntlProvider locale="en>">
|
||||
<IntlProvider locale="en">
|
||||
<PreviewPanelContext.Provider value={panelContextValue}>
|
||||
<ThemeProvider theme={mockTheme}>
|
||||
<AlertReasonPreview />
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { act, render } from '@testing-library/react';
|
||||
import { RulePreview } from './rule_preview';
|
||||
import { PreviewPanelContext } from '../context';
|
||||
import { mockContextValue } from '../mocks/mock_preview_panel_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { mockFlyoutContextValue } from '../../shared/mocks/mock_flyout_context';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { ThemeProvider } from 'styled-components';
|
||||
|
@ -54,6 +54,19 @@ const contextValue = {
|
|||
ruleId: 'rule id',
|
||||
};
|
||||
|
||||
const renderRulePreview = () =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<ThemeProvider theme={mockTheme}>
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<PreviewPanelContext.Provider value={contextValue}>
|
||||
<RulePreview />
|
||||
</PreviewPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</ThemeProvider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<RulePreview />', () => {
|
||||
beforeEach(() => {
|
||||
// (useAppToasts as jest.Mock).mockReturnValue(useAppToastsValueMock);
|
||||
|
@ -63,7 +76,7 @@ describe('<RulePreview />', () => {
|
|||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should render rule preview and its sub sections', () => {
|
||||
it('should render rule preview and its sub sections', async () => {
|
||||
mockUseRuleWithFallback.mockReturnValue({
|
||||
rule: { name: 'rule name', description: 'rule description' },
|
||||
});
|
||||
|
@ -74,34 +87,27 @@ describe('<RulePreview />', () => {
|
|||
ruleActionsData: { actions: ['action'] },
|
||||
});
|
||||
mockUseGetSavedQuery.mockReturnValue({ isSavedQueryLoading: false, savedQueryBar: null });
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<ThemeProvider theme={mockTheme}>
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<PreviewPanelContext.Provider value={contextValue}>
|
||||
<RulePreview />
|
||||
</PreviewPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</ThemeProvider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
expect(getByTestId(RULE_PREVIEW_BODY_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_ABOUT_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_ABOUT_HEADER_TEST_ID)).toHaveTextContent('About');
|
||||
expect(getByTestId(RULE_PREVIEW_ABOUT_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_DEFINITION_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_DEFINITION_HEADER_TEST_ID)).toHaveTextContent('Definition');
|
||||
expect(getByTestId(RULE_PREVIEW_DEFINITION_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_SCHEDULE_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_SCHEDULE_HEADER_TEST_ID)).toHaveTextContent('Schedule');
|
||||
expect(getByTestId(RULE_PREVIEW_SCHEDULE_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_ACTIONS_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_ACTIONS_HEADER_TEST_ID)).toHaveTextContent('Actions');
|
||||
expect(getByTestId(RULE_PREVIEW_ACTIONS_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
const { getByTestId } = renderRulePreview();
|
||||
|
||||
await act(async () => {
|
||||
expect(getByTestId(RULE_PREVIEW_BODY_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_ABOUT_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_ABOUT_HEADER_TEST_ID)).toHaveTextContent('About');
|
||||
expect(getByTestId(RULE_PREVIEW_ABOUT_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_DEFINITION_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_DEFINITION_HEADER_TEST_ID)).toHaveTextContent('Definition');
|
||||
expect(getByTestId(RULE_PREVIEW_DEFINITION_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_SCHEDULE_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_SCHEDULE_HEADER_TEST_ID)).toHaveTextContent('Schedule');
|
||||
expect(getByTestId(RULE_PREVIEW_SCHEDULE_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_ACTIONS_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_ACTIONS_HEADER_TEST_ID)).toHaveTextContent('Actions');
|
||||
expect(getByTestId(RULE_PREVIEW_ACTIONS_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not render actions if action is not available', () => {
|
||||
it('should not render actions if action is not available', async () => {
|
||||
mockUseRuleWithFallback.mockReturnValue({
|
||||
rule: { name: 'rule name', description: 'rule description' },
|
||||
});
|
||||
|
@ -110,51 +116,27 @@ describe('<RulePreview />', () => {
|
|||
defineRuleData: mockDefineStepRule(),
|
||||
scheduleRuleData: mockScheduleStepRule(),
|
||||
});
|
||||
const { queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<ThemeProvider theme={mockTheme}>
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<PreviewPanelContext.Provider value={contextValue}>
|
||||
<RulePreview />
|
||||
</PreviewPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</ThemeProvider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryByTestId } = renderRulePreview();
|
||||
|
||||
expect(queryByTestId(RULE_PREVIEW_ACTIONS_HEADER_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(RULE_PREVIEW_ACTIONS_CONTENT_TEST_ID)).not.toBeInTheDocument();
|
||||
await act(async () => {
|
||||
expect(queryByTestId(RULE_PREVIEW_ACTIONS_HEADER_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(RULE_PREVIEW_ACTIONS_CONTENT_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('should render loading spinner when rule is loading', () => {
|
||||
it('should render loading spinner when rule is loading', async () => {
|
||||
mockUseRuleWithFallback.mockReturnValue({ loading: true, rule: null });
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<ThemeProvider theme={mockTheme}>
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<PreviewPanelContext.Provider value={contextValue}>
|
||||
<RulePreview />
|
||||
</PreviewPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</ThemeProvider>
|
||||
</TestProviders>
|
||||
);
|
||||
expect(getByTestId(RULE_PREVIEW_LOADING_TEST_ID)).toBeInTheDocument();
|
||||
const { getByTestId } = renderRulePreview();
|
||||
await act(async () => {
|
||||
expect(getByTestId(RULE_PREVIEW_LOADING_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not render rule preview when rule is null', () => {
|
||||
it('should not render rule preview when rule is null', async () => {
|
||||
mockUseRuleWithFallback.mockReturnValue({});
|
||||
const { queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<ThemeProvider theme={mockTheme}>
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<PreviewPanelContext.Provider value={contextValue}>
|
||||
<RulePreview />
|
||||
</PreviewPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</ThemeProvider>
|
||||
</TestProviders>
|
||||
);
|
||||
expect(queryByTestId(RULE_PREVIEW_BODY_TEST_ID)).not.toBeInTheDocument();
|
||||
const { queryByTestId } = renderRulePreview();
|
||||
await act(async () => {
|
||||
expect(queryByTestId(RULE_PREVIEW_BODY_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,25 +8,27 @@
|
|||
import { render } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { mockContextValue } from '../mocks/mock_preview_panel_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { PreviewPanelContext } from '../context';
|
||||
import { RULE_PREVIEW_FOOTER_TEST_ID, RULE_PREVIEW_NAVIGATE_TO_RULE_TEST_ID } from './test_ids';
|
||||
import { RulePreviewFooter } from './rule_preview_footer';
|
||||
|
||||
const contextValue = {
|
||||
...mockContextValue,
|
||||
ruleId: 'rule id',
|
||||
};
|
||||
const renderRulePreviewFooter = (contextValue: PreviewPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<PreviewPanelContext.Provider value={contextValue}>
|
||||
<RulePreviewFooter />
|
||||
</PreviewPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<RulePreviewFooter />', () => {
|
||||
it('renders rule details link correctly when ruleId is available', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<PreviewPanelContext.Provider value={contextValue}>
|
||||
<RulePreviewFooter />
|
||||
</PreviewPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const contextValue = {
|
||||
...mockContextValue,
|
||||
ruleId: 'rule id',
|
||||
};
|
||||
const { getByTestId } = renderRulePreviewFooter(contextValue);
|
||||
|
||||
expect(getByTestId(RULE_PREVIEW_FOOTER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_NAVIGATE_TO_RULE_TEST_ID)).toBeInTheDocument();
|
||||
|
@ -36,13 +38,7 @@ describe('<RulePreviewFooter />', () => {
|
|||
});
|
||||
|
||||
it('should not render rule details link when ruleId is not available', () => {
|
||||
const { queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<PreviewPanelContext.Provider value={mockContextValue}>
|
||||
<RulePreviewFooter />
|
||||
</PreviewPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryByTestId } = renderRulePreviewFooter(mockContextValue);
|
||||
|
||||
expect(queryByTestId(RULE_PREVIEW_FOOTER_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(RULE_PREVIEW_NAVIGATE_TO_RULE_TEST_ID)).not.toBeInTheDocument();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import type { RulePreviewTitleProps } from './rule_preview_title';
|
||||
import { RulePreviewTitle } from './rule_preview_title';
|
||||
import { mockFlyoutContextValue } from '../../shared/mocks/mock_flyout_context';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
|
@ -24,15 +25,19 @@ const defaultProps = {
|
|||
isSuppressed: false,
|
||||
};
|
||||
|
||||
const renderRulePreviewTitle = (props: RulePreviewTitleProps) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<RulePreviewTitle {...props} />
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<RulePreviewTitle />', () => {
|
||||
it('should render title and its components', () => {
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<RulePreviewTitle {...defaultProps} />
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId, queryByTestId } = renderRulePreviewTitle(defaultProps);
|
||||
|
||||
expect(getByTestId(RULE_PREVIEW_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_RULE_CREATED_BY_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RULE_PREVIEW_RULE_UPDATED_BY_TEST_ID)).toBeInTheDocument();
|
||||
|
@ -44,13 +49,7 @@ describe('<RulePreviewTitle />', () => {
|
|||
...defaultProps,
|
||||
isSuppressed: true,
|
||||
};
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<RulePreviewTitle {...props} />
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderRulePreviewTitle(props);
|
||||
expect(getByTestId(RULE_PREVIEW_RULE_TITLE_SUPPRESSED_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
RULE_PREVIEW_RULE_TITLE_SUPPRESSED_TEST_ID,
|
||||
} from './test_ids';
|
||||
|
||||
interface RulePreviewTitleProps {
|
||||
export interface RulePreviewTitleProps {
|
||||
/**
|
||||
* Rule object that represents relevant information about a rule
|
||||
*/
|
||||
|
|
|
@ -5,40 +5,34 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { PREFIX } from '../../shared/test_ids';
|
||||
import { CONTENT_TEST_ID, HEADER_TEST_ID } from '../../right/components/expandable_section';
|
||||
|
||||
/* Rule preview */
|
||||
|
||||
export const RULE_PREVIEW_TITLE_TEST_ID = 'securitySolutionDocumentDetailsFlyoutRulePreviewTitle';
|
||||
const RULE_PREVIEW_TEST_ID = `${PREFIX}RulePreview` as const;
|
||||
export const RULE_PREVIEW_TITLE_TEST_ID = `${RULE_PREVIEW_TEST_ID}RulePreviewTitle` as const;
|
||||
export const RULE_PREVIEW_RULE_TITLE_SUPPRESSED_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutRulePreviewTitleSuppressed';
|
||||
export const RULE_PREVIEW_RULE_CREATED_BY_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutRulePreviewCreatedByText';
|
||||
export const RULE_PREVIEW_RULE_UPDATED_BY_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutRulePreviewUpdatedByText';
|
||||
|
||||
export const RULE_PREVIEW_BODY_TEST_ID = 'securitySolutionDocumentDetailsFlyoutRulePreviewBody';
|
||||
export const RULE_PREVIEW_ABOUT_TEST_ID = `securitySolutionDocumentDetailsFlyoutRulePreviewAboutSection`;
|
||||
`${RULE_PREVIEW_TITLE_TEST_ID}Suppressed` as const;
|
||||
export const RULE_PREVIEW_RULE_CREATED_BY_TEST_ID = `${RULE_PREVIEW_TEST_ID}CreatedByText` as const;
|
||||
export const RULE_PREVIEW_RULE_UPDATED_BY_TEST_ID = `${RULE_PREVIEW_TEST_ID}UpdatedByText` as const;
|
||||
export const RULE_PREVIEW_BODY_TEST_ID = `${RULE_PREVIEW_TEST_ID}Body` as const;
|
||||
export const RULE_PREVIEW_ABOUT_TEST_ID = `${RULE_PREVIEW_TEST_ID}AboutSection` as const;
|
||||
export const RULE_PREVIEW_ABOUT_HEADER_TEST_ID = RULE_PREVIEW_ABOUT_TEST_ID + HEADER_TEST_ID;
|
||||
export const RULE_PREVIEW_ABOUT_CONTENT_TEST_ID = RULE_PREVIEW_ABOUT_TEST_ID + CONTENT_TEST_ID;
|
||||
export const RULE_PREVIEW_DEFINITION_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutRulePreviewDefinitionSection';
|
||||
export const RULE_PREVIEW_DEFINITION_TEST_ID = `${RULE_PREVIEW_TEST_ID}DefinitionSection` as const;
|
||||
export const RULE_PREVIEW_DEFINITION_HEADER_TEST_ID =
|
||||
RULE_PREVIEW_DEFINITION_TEST_ID + HEADER_TEST_ID;
|
||||
export const RULE_PREVIEW_DEFINITION_CONTENT_TEST_ID =
|
||||
RULE_PREVIEW_DEFINITION_TEST_ID + CONTENT_TEST_ID;
|
||||
export const RULE_PREVIEW_SCHEDULE_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutRulePreviewScheduleSection';
|
||||
export const RULE_PREVIEW_SCHEDULE_TEST_ID = `${RULE_PREVIEW_TEST_ID}ScheduleSection` as const;
|
||||
export const RULE_PREVIEW_SCHEDULE_HEADER_TEST_ID = RULE_PREVIEW_SCHEDULE_TEST_ID + HEADER_TEST_ID;
|
||||
export const RULE_PREVIEW_SCHEDULE_CONTENT_TEST_ID =
|
||||
RULE_PREVIEW_SCHEDULE_TEST_ID + CONTENT_TEST_ID;
|
||||
export const RULE_PREVIEW_ACTIONS_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutRulePreviewActionsSection';
|
||||
export const RULE_PREVIEW_ACTIONS_TEST_ID = `${RULE_PREVIEW_TEST_ID}ActionsSection` as const;
|
||||
export const RULE_PREVIEW_ACTIONS_HEADER_TEST_ID = RULE_PREVIEW_ACTIONS_TEST_ID + HEADER_TEST_ID;
|
||||
export const RULE_PREVIEW_ACTIONS_CONTENT_TEST_ID = RULE_PREVIEW_ACTIONS_TEST_ID + CONTENT_TEST_ID;
|
||||
export const RULE_PREVIEW_LOADING_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutRulePreviewLoadingSpinner';
|
||||
export const RULE_PREVIEW_FOOTER_TEST_ID = 'securitySolutionDocumentDetailsFlyoutRulePreviewFooter';
|
||||
export const RULE_PREVIEW_NAVIGATE_TO_RULE_TEST_ID = 'goToRuleDetails';
|
||||
export const ALERT_REASON_PREVIEW_BODY_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutAlertReasonPreviewBody';
|
||||
export const RULE_PREVIEW_LOADING_TEST_ID = `${RULE_PREVIEW_TEST_ID}Loading` as const;
|
||||
export const RULE_PREVIEW_FOOTER_TEST_ID = `${RULE_PREVIEW_TEST_ID}Footer` as const;
|
||||
export const RULE_PREVIEW_NAVIGATE_TO_RULE_TEST_ID = 'goToRuleDetails' as const;
|
||||
export const ALERT_REASON_PREVIEW_BODY_TEST_ID = `${PREFIX}AlertReasonPreviewBody` as const;
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs';
|
||||
import { mockDataAsNestedObject } from '../../shared/mocks/mock_context';
|
||||
import { mockDataAsNestedObject } from '../../shared/mocks/mock_data_as_nested_object';
|
||||
import type { PreviewPanelContext } from '../context';
|
||||
|
||||
/**
|
||||
|
@ -18,5 +17,5 @@ export const mockContextValue: PreviewPanelContext = {
|
|||
scopeId: 'scopeId',
|
||||
ruleId: '',
|
||||
indexPattern: { fields: [], title: 'test index' },
|
||||
dataAsNestedObject: mockDataAsNestedObject as unknown as Ecs,
|
||||
dataAsNestedObject: mockDataAsNestedObject,
|
||||
};
|
|
@ -6,51 +6,45 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { act, render } from '@testing-library/react';
|
||||
import { ABOUT_SECTION_CONTENT_TEST_ID, ABOUT_SECTION_HEADER_TEST_ID } from './test_ids';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { AboutSection } from './about_section';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { mockContextValue } from '../mocks/mock_right_panel_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
|
||||
jest.mock('../../../common/components/link_to');
|
||||
|
||||
const renderAboutSection = (expanded: boolean = false) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={mockContextValue}>
|
||||
<AboutSection expanded={expanded} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<AboutSection />', () => {
|
||||
it('should render the component collapsed', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={mockContextValue}>
|
||||
<AboutSection />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
expect(getByTestId(ABOUT_SECTION_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
it('should render the component collapsed', async () => {
|
||||
const { getByTestId } = renderAboutSection();
|
||||
await act(async () => {
|
||||
expect(getByTestId(ABOUT_SECTION_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('should render the component expanded', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={mockContextValue}>
|
||||
<AboutSection expanded={true} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
expect(getByTestId(ABOUT_SECTION_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(ABOUT_SECTION_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
it('should render the component expanded', async () => {
|
||||
const { getByTestId } = renderAboutSection(true);
|
||||
await act(async () => {
|
||||
expect(getByTestId(ABOUT_SECTION_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(ABOUT_SECTION_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('should expand the component when clicking on the arrow on header', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={mockContextValue}>
|
||||
<AboutSection />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
getByTestId(ABOUT_SECTION_HEADER_TEST_ID).click();
|
||||
expect(getByTestId(ABOUT_SECTION_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
it('should expand the component when clicking on the arrow on header', async () => {
|
||||
const { getByTestId } = renderAboutSection();
|
||||
await act(async () => {
|
||||
getByTestId(ABOUT_SECTION_HEADER_TEST_ID).click();
|
||||
expect(getByTestId(ABOUT_SECTION_CONTENT_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,8 +9,8 @@ import { render } from '@testing-library/react';
|
|||
import React from 'react';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { useAlertPrevalenceFromProcessTree } from '../../../common/containers/alerts/use_alert_prevalence_from_process_tree';
|
||||
import { mockContextValue } from '../mocks/mock_right_panel_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { AnalyzerPreview } from './analyzer_preview';
|
||||
import { ANALYZER_PREVIEW_TEST_ID } from './test_ids';
|
||||
|
@ -21,43 +21,33 @@ jest.mock('../../../common/containers/alerts/use_alert_prevalence_from_process_t
|
|||
}));
|
||||
const mockUseAlertPrevalenceFromProcessTree = useAlertPrevalenceFromProcessTree as jest.Mock;
|
||||
|
||||
const contextValue = {
|
||||
...mockContextValue,
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
};
|
||||
|
||||
const contextValueEmpty = {
|
||||
...mockContextValue,
|
||||
dataFormattedForFieldBrowser: [
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.uuid',
|
||||
values: ['rule-uuid'],
|
||||
originalValue: ['rule-uuid'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
const renderAnalyzerPreview = (contextValue: RightPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<AnalyzerPreview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<AnalyzerPreview />', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
it('shows analyzer preview correctly when documentid and index are present', () => {
|
||||
it('shows analyzer preview correctly when documentId and index are present', () => {
|
||||
mockUseAlertPrevalenceFromProcessTree.mockReturnValue({
|
||||
loading: false,
|
||||
error: false,
|
||||
alertIds: ['alertid'],
|
||||
statsNodes: mock.mockStatsNodes,
|
||||
});
|
||||
const wrapper = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<AnalyzerPreview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const contextValue = {
|
||||
...mockContextValue,
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
};
|
||||
|
||||
const wrapper = renderAnalyzerPreview(contextValue);
|
||||
|
||||
expect(mockUseAlertPrevalenceFromProcessTree).toHaveBeenCalledWith({
|
||||
isActiveTimeline: false,
|
||||
|
@ -67,20 +57,26 @@ describe('<AnalyzerPreview />', () => {
|
|||
expect(wrapper.getByTestId(ANALYZER_PREVIEW_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not show analyzer preview when documentid and index are not present', () => {
|
||||
it('does not show analyzer preview when documentId and index are not present', () => {
|
||||
mockUseAlertPrevalenceFromProcessTree.mockReturnValue({
|
||||
loading: false,
|
||||
error: false,
|
||||
alertIds: undefined,
|
||||
statsNodes: undefined,
|
||||
});
|
||||
const { queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValueEmpty}>
|
||||
<AnalyzerPreview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const contextValue = {
|
||||
...mockContextValue,
|
||||
dataFormattedForFieldBrowser: [
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.uuid',
|
||||
values: ['rule-uuid'],
|
||||
originalValue: ['rule-uuid'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
const { queryByTestId } = renderAnalyzerPreview(contextValue);
|
||||
|
||||
expect(mockUseAlertPrevalenceFromProcessTree).toHaveBeenCalledWith({
|
||||
isActiveTimeline: false,
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID,
|
||||
EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID,
|
||||
} from '../../shared/components/test_ids';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { useInvestigateInTimeline } from '../../../detections/components/alerts_table/timeline_actions/use_investigate_in_timeline';
|
||||
|
||||
jest.mock('../../../detections/components/alerts_table/timeline_actions/investigate_in_resolver');
|
||||
|
@ -33,6 +33,14 @@ jest.mock('react-router-dom', () => {
|
|||
const actual = jest.requireActual('react-router-dom');
|
||||
return { ...actual, useLocation: jest.fn().mockReturnValue({ pathname: '' }) };
|
||||
});
|
||||
jest.mock('react-redux', () => {
|
||||
const original = jest.requireActual('react-redux');
|
||||
|
||||
return {
|
||||
...original,
|
||||
useDispatch: () => jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
const panelContextValue = {
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
|
|
|
@ -14,13 +14,13 @@ import { CorrelationsOverview } from './correlations_overview';
|
|||
import { CORRELATIONS_TAB_ID } from '../../left/components/correlations_details';
|
||||
import { LeftPanelInsightsTab, LeftPanelKey } from '../../left';
|
||||
import {
|
||||
INSIGHTS_CORRELATIONS_NO_DATA_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_TEST_ID,
|
||||
CORRELATIONS_NO_DATA_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID,
|
||||
CORRELATIONS_RELATED_CASES_TEST_ID,
|
||||
CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID,
|
||||
CORRELATIONS_TEST_ID,
|
||||
SUMMARY_ROW_VALUE_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { useShowRelatedAlertsByAncestry } from '../../shared/hooks/use_show_related_alerts_by_ancestry';
|
||||
|
@ -49,32 +49,22 @@ jest.mock('../../shared/hooks/use_fetch_related_alerts_by_ancestry');
|
|||
jest.mock('../../shared/hooks/use_fetch_related_alerts_by_same_source_event');
|
||||
jest.mock('../../shared/hooks/use_fetch_related_cases');
|
||||
|
||||
const TOGGLE_ICON_TEST_ID = EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID(INSIGHTS_CORRELATIONS_TEST_ID);
|
||||
const TITLE_LINK_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_TEST_ID
|
||||
);
|
||||
const TITLE_ICON_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_TEST_ID
|
||||
);
|
||||
const TITLE_TEXT_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_TEST_ID
|
||||
);
|
||||
const TOGGLE_ICON_TEST_ID = EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID(CORRELATIONS_TEST_ID);
|
||||
const TITLE_LINK_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(CORRELATIONS_TEST_ID);
|
||||
const TITLE_ICON_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID(CORRELATIONS_TEST_ID);
|
||||
const TITLE_TEXT_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID(CORRELATIONS_TEST_ID);
|
||||
|
||||
const SUPPRESSED_ALERTS_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID
|
||||
);
|
||||
const SUPPRESSED_ALERTS_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID);
|
||||
const RELATED_ALERTS_BY_ANCESTRY_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID
|
||||
CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID
|
||||
);
|
||||
const RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID
|
||||
);
|
||||
const RELATED_ALERTS_BY_SESSION_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID
|
||||
);
|
||||
const RELATED_CASES_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID
|
||||
);
|
||||
const RELATED_CASES_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_RELATED_CASES_TEST_ID);
|
||||
|
||||
const panelContextValue = {
|
||||
eventId: 'event id',
|
||||
|
@ -147,7 +137,7 @@ describe('<CorrelationsOverview />', () => {
|
|||
expect(getByTestId(RELATED_ALERTS_BY_SESSION_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RELATED_CASES_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(SUPPRESSED_ALERTS_TEST_ID)).toBeInTheDocument();
|
||||
expect(queryByTestId(INSIGHTS_CORRELATIONS_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(CORRELATIONS_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should hide rows and show error message if show values are false', () => {
|
||||
|
@ -169,8 +159,8 @@ describe('<CorrelationsOverview />', () => {
|
|||
expect(queryByTestId(RELATED_ALERTS_BY_SESSION_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(RELATED_CASES_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(SUPPRESSED_ALERTS_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(getByTestId(INSIGHTS_CORRELATIONS_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(INSIGHTS_CORRELATIONS_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
expect(getByTestId(CORRELATIONS_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(CORRELATIONS_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
'No correlations data available.'
|
||||
);
|
||||
});
|
||||
|
@ -188,7 +178,7 @@ describe('<CorrelationsOverview />', () => {
|
|||
expect(queryByTestId(RELATED_ALERTS_BY_SESSION_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(RELATED_CASES_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(SUPPRESSED_ALERTS_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(INSIGHTS_CORRELATIONS_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(CORRELATIONS_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should navigate to the left section Insights tab when clicking on button', () => {
|
||||
|
|
|
@ -20,7 +20,7 @@ import { SuppressedAlerts } from './suppressed_alerts';
|
|||
import { useShowSuppressedAlerts } from '../../shared/hooks/use_show_suppressed_alerts';
|
||||
import { RelatedCases } from './related_cases';
|
||||
import { useShowRelatedCases } from '../../shared/hooks/use_show_related_cases';
|
||||
import { INSIGHTS_CORRELATIONS_NO_DATA_TEST_ID, INSIGHTS_CORRELATIONS_TEST_ID } from './test_ids';
|
||||
import { CORRELATIONS_NO_DATA_TEST_ID, CORRELATIONS_TEST_ID } from './test_ids';
|
||||
import { useRightPanelContext } from '../context';
|
||||
import { LeftPanelKey, LeftPanelInsightsTab } from '../../left';
|
||||
import { CORRELATIONS_TAB_ID } from '../../left/components/correlations_details';
|
||||
|
@ -93,7 +93,7 @@ export const CorrelationsOverview: React.FC = () => {
|
|||
callback: goToCorrelationsTab,
|
||||
iconType: 'arrowStart',
|
||||
}}
|
||||
data-test-subj={INSIGHTS_CORRELATIONS_TEST_ID}
|
||||
data-test-subj={CORRELATIONS_TEST_ID}
|
||||
>
|
||||
{canShowAtLeastOneInsight ? (
|
||||
<EuiFlexGroup direction="column" gutterSize="none">
|
||||
|
@ -112,7 +112,7 @@ export const CorrelationsOverview: React.FC = () => {
|
|||
)}
|
||||
</EuiFlexGroup>
|
||||
) : (
|
||||
<p data-test-subj={INSIGHTS_CORRELATIONS_NO_DATA_TEST_ID}>
|
||||
<p data-test-subj={CORRELATIONS_NO_DATA_TEST_ID}>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.right.insights.correlations.noDataDescription"
|
||||
defaultMessage="No correlations data available."
|
||||
|
|
|
@ -11,7 +11,7 @@ import { render } from '@testing-library/react';
|
|||
import { DESCRIPTION_TITLE_TEST_ID, RULE_SUMMARY_BUTTON_TEST_ID } from './test_ids';
|
||||
import { Description } from './description';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import type { TimelineEventsDetailsItem } from '@kbn/timelines-plugin/common';
|
||||
import { PreviewPanelKey } from '../../preview';
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
} from './test_ids';
|
||||
import { EntitiesOverview } from './entities_overview';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import {
|
||||
EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID,
|
||||
EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID,
|
||||
|
@ -36,15 +36,18 @@ const mockContextValue = {
|
|||
getFieldsData: mockGetFieldsData,
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const renderEntitiesOverview = (contextValue: RightPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<EntitiesOverview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<EntitiesOverview />', () => {
|
||||
it('should render wrapper component', () => {
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={mockContextValue}>
|
||||
<EntitiesOverview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId, queryByTestId } = renderEntitiesOverview(mockContextValue);
|
||||
|
||||
expect(queryByTestId(TOGGLE_ICON_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_LINK_TEST_ID)).toBeInTheDocument();
|
||||
|
@ -54,13 +57,7 @@ describe('<EntitiesOverview />', () => {
|
|||
});
|
||||
|
||||
it('should render user and host', () => {
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={mockContextValue}>
|
||||
<EntitiesOverview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId, queryByTestId } = renderEntitiesOverview(mockContextValue);
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_TEST_ID)).toBeInTheDocument();
|
||||
expect(queryByTestId(INSIGHTS_ENTITIES_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
|
@ -72,13 +69,7 @@ describe('<EntitiesOverview />', () => {
|
|||
getFieldsData: (field: string) => (field === 'user.name' ? 'user1' : null),
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const { queryByTestId, getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<EntitiesOverview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryByTestId, getByTestId } = renderEntitiesOverview(contextValue);
|
||||
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_TEST_ID)).toBeInTheDocument();
|
||||
expect(queryByTestId(ENTITIES_HOST_OVERVIEW_TEST_ID)).not.toBeInTheDocument();
|
||||
|
@ -91,13 +82,7 @@ describe('<EntitiesOverview />', () => {
|
|||
getFieldsData: (field: string) => (field === 'host.name' ? 'host1' : null),
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const { queryByTestId, getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<EntitiesOverview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryByTestId, getByTestId } = renderEntitiesOverview(contextValue);
|
||||
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_TEST_ID)).toBeInTheDocument();
|
||||
expect(queryByTestId(ENTITIES_USER_OVERVIEW_TEST_ID)).not.toBeInTheDocument();
|
||||
|
@ -110,13 +95,7 @@ describe('<EntitiesOverview />', () => {
|
|||
getFieldsData: (field: string) => {},
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const { queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<EntitiesOverview />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { queryByTestId } = renderEntitiesOverview(contextValue);
|
||||
|
||||
expect(queryByTestId(INSIGHTS_ENTITIES_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(queryByTestId(INSIGHTS_ENTITIES_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
|
|
|
@ -15,34 +15,29 @@ const testId = 'test';
|
|||
const headerTestId = testId + HEADER_TEST_ID;
|
||||
const contentTestId = testId + CONTENT_TEST_ID;
|
||||
|
||||
const renderExpandableSection = (expanded: boolean) =>
|
||||
render(
|
||||
<ExpandableSection expanded={expanded} title={title} data-test-subj={testId}>
|
||||
{children}
|
||||
</ExpandableSection>
|
||||
);
|
||||
|
||||
describe('<ExpandableSection />', () => {
|
||||
it('should render the component collapsed', () => {
|
||||
const { getByTestId } = render(
|
||||
<ExpandableSection expanded={false} title={title} data-test-subj={testId}>
|
||||
{children}
|
||||
</ExpandableSection>
|
||||
);
|
||||
const { getByTestId } = renderExpandableSection(false);
|
||||
|
||||
expect(getByTestId(headerTestId)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render the component expanded', () => {
|
||||
const { getByTestId } = render(
|
||||
<ExpandableSection expanded={true} title={title} data-test-subj={testId}>
|
||||
{children}
|
||||
</ExpandableSection>
|
||||
);
|
||||
const { getByTestId } = renderExpandableSection(true);
|
||||
|
||||
expect(getByTestId(headerTestId)).toBeInTheDocument();
|
||||
expect(getByTestId(contentTestId)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should expand the component when clicking on the arrow on header', () => {
|
||||
const { getByTestId } = render(
|
||||
<ExpandableSection expanded={false} title={title} data-test-subj={testId}>
|
||||
{children}
|
||||
</ExpandableSection>
|
||||
);
|
||||
const { getByTestId } = renderExpandableSection(false);
|
||||
|
||||
getByTestId(headerTestId).click();
|
||||
expect(getByTestId(contentTestId)).toBeInTheDocument();
|
||||
|
|
|
@ -10,16 +10,17 @@ import { render } from '@testing-library/react';
|
|||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { RightPanelContext } from '../context';
|
||||
import {
|
||||
FLYOUT_HEADER_CHAT_BUTTON_TEST_ID,
|
||||
FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID,
|
||||
FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID,
|
||||
FLYOUT_HEADER_SHARE_BUTTON_TEST_ID,
|
||||
CHAT_BUTTON_TEST_ID,
|
||||
RISK_SCORE_VALUE_TEST_ID,
|
||||
SEVERITY_TITLE_TEST_ID,
|
||||
SHARE_BUTTON_TEST_ID,
|
||||
FLYOUT_HEADER_TITLE_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { HeaderTitle } from './header_title';
|
||||
import moment from 'moment-timezone';
|
||||
import { useDateFormat, useTimeZone } from '../../../common/lib/kibana';
|
||||
import { mockDataFormattedForFieldBrowser, mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { useAssistant } from '../hooks/use_assistant';
|
||||
import { TestProvidersComponent } from '../../../common/mock';
|
||||
import { useGetAlertDetailsFlyoutLink } from '../../../timelines/components/side_panel/event_details/use_get_alert_details_flyout_link';
|
||||
|
@ -63,8 +64,8 @@ describe('<HeaderTitle />', () => {
|
|||
const { getByTestId } = renderHeader(mockContextValue);
|
||||
|
||||
expect(getByTestId(FLYOUT_HEADER_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(RISK_SCORE_VALUE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(SEVERITY_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render rule name in the title if document is an alert', () => {
|
||||
|
@ -76,7 +77,7 @@ describe('<HeaderTitle />', () => {
|
|||
it('should render share button in the title', () => {
|
||||
const { getByTestId } = renderHeader(mockContextValue);
|
||||
|
||||
expect(getByTestId(FLYOUT_HEADER_SHARE_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(SHARE_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render share button in the title if alert is missing url info', () => {
|
||||
|
@ -84,13 +85,13 @@ describe('<HeaderTitle />', () => {
|
|||
|
||||
const { queryByTestId } = renderHeader(mockContextValue);
|
||||
|
||||
expect(queryByTestId(FLYOUT_HEADER_SHARE_BUTTON_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(SHARE_BUTTON_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render chat button in the title', () => {
|
||||
const { getByTestId } = renderHeader(mockContextValue);
|
||||
|
||||
expect(getByTestId(FLYOUT_HEADER_CHAT_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(CHAT_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render chat button in the title if should not be shown', () => {
|
||||
|
@ -98,7 +99,7 @@ describe('<HeaderTitle />', () => {
|
|||
|
||||
const { queryByTestId } = renderHeader(mockContextValue);
|
||||
|
||||
expect(queryByTestId(FLYOUT_HEADER_CHAT_BUTTON_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(CHAT_BUTTON_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render default document detail title if document is not an alert', () => {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { render } from '@testing-library/react';
|
|||
import { RightPanelContext } from '../context';
|
||||
import { HIGHLIGHTED_FIELDS_DETAILS_TEST_ID, HIGHLIGHTED_FIELDS_TITLE_TEST_ID } from './test_ids';
|
||||
import { HighlightedFields } from './highlighted_fields';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { useHighlightedFields } from '../../shared/hooks/use_highlighted_fields';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { useRuleWithFallback } from '../../../detection_engine/rule_management/logic/use_rule_with_fallback';
|
||||
|
@ -18,13 +18,22 @@ import { useRuleWithFallback } from '../../../detection_engine/rule_management/l
|
|||
jest.mock('../../shared/hooks/use_highlighted_fields');
|
||||
jest.mock('../../../detection_engine/rule_management/logic/use_rule_with_fallback');
|
||||
|
||||
const renderHighlightedFields = (contextValue: RightPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<HighlightedFields />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<HighlightedFields />', () => {
|
||||
beforeEach(() => {
|
||||
(useRuleWithFallback as jest.Mock).mockReturnValue({ investigation_fields: undefined });
|
||||
});
|
||||
|
||||
it('should render the component', () => {
|
||||
const panelContextValue = {
|
||||
const contextValue = {
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
scopeId: 'scopeId',
|
||||
} as unknown as RightPanelContext;
|
||||
|
@ -34,30 +43,20 @@ describe('<HighlightedFields />', () => {
|
|||
},
|
||||
});
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<HighlightedFields />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHighlightedFields(contextValue);
|
||||
|
||||
expect(getByTestId(HIGHLIGHTED_FIELDS_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(HIGHLIGHTED_FIELDS_DETAILS_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it(`should render empty component if there aren't any highlighted fields`, () => {
|
||||
const panelContextValue = {
|
||||
const contextValue = {
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
scopeId: 'scopeId',
|
||||
} as unknown as RightPanelContext;
|
||||
(useHighlightedFields as jest.Mock).mockReturnValue({});
|
||||
|
||||
const { container } = render(
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<HighlightedFields />
|
||||
</RightPanelContext.Provider>
|
||||
);
|
||||
const { container } = renderHighlightedFields(contextValue);
|
||||
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
|
|
@ -18,6 +18,9 @@ import { RightPanelContext } from '../context';
|
|||
import { LeftPanelInsightsTab, LeftPanelKey } from '../../left';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { ENTITIES_TAB_ID } from '../../left/components/entities_details';
|
||||
import { useGetEndpointDetails } from '../../../management/hooks';
|
||||
|
||||
jest.mock('../../../management/hooks');
|
||||
|
||||
const flyoutContextValue = {
|
||||
openLeftPanel: jest.fn(),
|
||||
|
@ -72,6 +75,7 @@ describe('<HighlightedFieldsCell />', () => {
|
|||
});
|
||||
|
||||
it('should render agent status cell if field is agent.status', () => {
|
||||
(useGetEndpointDetails as jest.Mock).mockReturnValue({});
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<HighlightedFieldsCell values={['value']} field={'agent.status'} />
|
||||
|
|
|
@ -18,8 +18,8 @@ import {
|
|||
ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { mockContextValue } from '../mocks/mock_right_panel_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { LeftPanelInsightsTab, LeftPanelKey } from '../../left';
|
||||
import { ENTITIES_TAB_ID } from '../../left/components/entities_details';
|
||||
|
@ -66,19 +66,24 @@ jest.mock('../../../explore/containers/risk_score');
|
|||
const mockUseFirstLastSeen = useFirstLastSeen as jest.Mock;
|
||||
jest.mock('../../../common/containers/use_first_last_seen');
|
||||
|
||||
const renderHostEntityContent = () =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<ExpandableFlyoutContext.Provider value={flyoutContextValue}>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<HostEntityOverview hostName={hostName} />
|
||||
</RightPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<HostEntityContent />', () => {
|
||||
describe('license is valid', () => {
|
||||
it('should render os family and host risk classification', () => {
|
||||
mockUseHostDetails.mockReturnValue([false, { hostDetails: hostData }]);
|
||||
mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true });
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<HostEntityOverview hostName={hostName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHostEntityContent();
|
||||
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID)).toHaveTextContent(osFamily);
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('Medium');
|
||||
|
@ -88,13 +93,8 @@ describe('<HostEntityContent />', () => {
|
|||
mockUseHostDetails.mockReturnValue([false, { hostDetails: null }]);
|
||||
mockUseRiskScore.mockReturnValue({ data: null, isAuthorized: true });
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<HostEntityOverview hostName={hostName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHostEntityContent();
|
||||
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID)).toHaveTextContent('—');
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('—');
|
||||
});
|
||||
|
@ -106,13 +106,7 @@ describe('<HostEntityContent />', () => {
|
|||
mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: false });
|
||||
mockUseFirstLastSeen.mockReturnValue([false, { lastSeen }]);
|
||||
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<HostEntityOverview hostName={hostName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId, queryByTestId } = renderHostEntityContent();
|
||||
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID)).toHaveTextContent(osFamily);
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID)).toHaveTextContent(lastSeenText);
|
||||
|
@ -124,13 +118,7 @@ describe('<HostEntityContent />', () => {
|
|||
mockUseRiskScore.mockReturnValue({ data: null, isAuthorized: false });
|
||||
mockUseFirstLastSeen.mockReturnValue([false, { lastSeen: null }]);
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<HostEntityOverview hostName={hostName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHostEntityContent();
|
||||
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID)).toHaveTextContent('—');
|
||||
expect(getByTestId(ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID)).toHaveTextContent('—');
|
||||
|
@ -140,15 +128,7 @@ describe('<HostEntityContent />', () => {
|
|||
mockUseHostDetails.mockReturnValue([false, { hostDetails: hostData }]);
|
||||
mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true });
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<ExpandableFlyoutContext.Provider value={flyoutContextValue}>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<HostEntityOverview hostName={hostName} />
|
||||
</RightPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderHostEntityContent();
|
||||
|
||||
getByTestId(ENTITIES_HOST_OVERVIEW_LINK_TEST_ID).click();
|
||||
expect(flyoutContextValue.openLeftPanel).toHaveBeenCalledWith({
|
||||
|
|
|
@ -10,7 +10,8 @@ import { render } from '@testing-library/react';
|
|||
import { RightPanelContext } from '../context';
|
||||
import { INSIGHTS_HEADER_TEST_ID } from './test_ids';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { mockDataFormattedForFieldBrowser, mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { InsightsSection } from './insights_section';
|
||||
import { useAlertPrevalence } from '../../../common/containers/alerts/use_alert_prevalence';
|
||||
|
||||
|
@ -40,6 +41,15 @@ jest.mock('react-router-dom', () => {
|
|||
alertIds: [],
|
||||
});
|
||||
|
||||
const renderInsightsSection = (contextValue: RightPanelContext, expanded: boolean) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<InsightsSection expanded={expanded} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<InsightsSection />', () => {
|
||||
it('should render insights component', () => {
|
||||
const contextValue = {
|
||||
|
@ -47,13 +57,7 @@ describe('<InsightsSection />', () => {
|
|||
getFieldsData: mockGetFieldsData,
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const wrapper = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<InsightsSection />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const wrapper = renderInsightsSection(contextValue, false);
|
||||
|
||||
expect(wrapper.getByTestId(INSIGHTS_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.getAllByRole('button')[0]).toHaveAttribute('aria-expanded', 'false');
|
||||
|
@ -67,13 +71,7 @@ describe('<InsightsSection />', () => {
|
|||
getFieldsData: mockGetFieldsData,
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const wrapper = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<InsightsSection expanded={true} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const wrapper = renderInsightsSection(contextValue, true);
|
||||
|
||||
expect(wrapper.getByTestId(INSIGHTS_HEADER_TEST_ID)).toBeInTheDocument();
|
||||
expect(wrapper.getAllByRole('button')[0]).toHaveAttribute('aria-expanded', 'true');
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
INVESTIGATION_GUIDE_NO_DATA_TEST_ID,
|
||||
INVESTIGATION_GUIDE_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { mockContextValue } from '../mocks/mock_right_panel_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { mockFlyoutContextValue } from '../../shared/mocks/mock_flyout_context';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { useInvestigationGuide } from '../../shared/hooks/use_investigation_guide';
|
||||
|
@ -24,15 +24,16 @@ import { LeftPanelInvestigationTab, LeftPanelKey } from '../../left';
|
|||
|
||||
jest.mock('../../shared/hooks/use_investigation_guide');
|
||||
|
||||
const renderInvestigationGuide = () => (
|
||||
<IntlProvider locale="en">
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<RightPanelContext.Provider value={mockContextValue}>
|
||||
<InvestigationGuide />
|
||||
</RightPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
const renderInvestigationGuide = () =>
|
||||
render(
|
||||
<IntlProvider locale="en">
|
||||
<ExpandableFlyoutContext.Provider value={mockFlyoutContextValue}>
|
||||
<RightPanelContext.Provider value={mockContextValue}>
|
||||
<InvestigationGuide />
|
||||
</RightPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
|
||||
describe('<InvestigationGuide />', () => {
|
||||
it('should render investigation guide button correctly', () => {
|
||||
|
@ -42,7 +43,7 @@ describe('<InvestigationGuide />', () => {
|
|||
basicAlertData: { ruleId: 'ruleId' },
|
||||
ruleNote: 'test note',
|
||||
});
|
||||
const { getByTestId, queryByTestId } = render(renderInvestigationGuide());
|
||||
const { getByTestId, queryByTestId } = renderInvestigationGuide();
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_TEST_ID)).toHaveTextContent('Investigation guide');
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
|
@ -57,7 +58,7 @@ describe('<InvestigationGuide />', () => {
|
|||
(useInvestigationGuide as jest.Mock).mockReturnValue({
|
||||
loading: true,
|
||||
});
|
||||
const { getByTestId, queryByTestId } = render(renderInvestigationGuide());
|
||||
const { getByTestId, queryByTestId } = renderInvestigationGuide();
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_LOADING_TEST_ID)).toBeInTheDocument();
|
||||
expect(queryByTestId(INVESTIGATION_GUIDE_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(INVESTIGATION_GUIDE_BUTTON_TEST_ID)).not.toBeInTheDocument();
|
||||
|
@ -69,7 +70,7 @@ describe('<InvestigationGuide />', () => {
|
|||
basicAlertData: {},
|
||||
ruleNote: 'test note',
|
||||
});
|
||||
const { getByTestId, queryByTestId } = render(renderInvestigationGuide());
|
||||
const { getByTestId, queryByTestId } = renderInvestigationGuide();
|
||||
expect(queryByTestId(INVESTIGATION_GUIDE_BUTTON_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
|
@ -82,7 +83,7 @@ describe('<InvestigationGuide />', () => {
|
|||
basicAlertData: { ruleId: 'ruleId' },
|
||||
ruleNote: undefined,
|
||||
});
|
||||
const { getByTestId, queryByTestId } = render(renderInvestigationGuide());
|
||||
const { getByTestId, queryByTestId } = renderInvestigationGuide();
|
||||
expect(queryByTestId(INVESTIGATION_GUIDE_BUTTON_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
|
@ -96,7 +97,7 @@ describe('<InvestigationGuide />', () => {
|
|||
error: true,
|
||||
});
|
||||
|
||||
const { getByTestId } = render(renderInvestigationGuide());
|
||||
const { getByTestId } = renderInvestigationGuide();
|
||||
expect(getByTestId(INVESTIGATION_GUIDE_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
@ -108,7 +109,7 @@ describe('<InvestigationGuide />', () => {
|
|||
ruleNote: 'test note',
|
||||
});
|
||||
|
||||
const { getByTestId } = render(renderInvestigationGuide());
|
||||
const { getByTestId } = renderInvestigationGuide();
|
||||
getByTestId(INVESTIGATION_GUIDE_BUTTON_TEST_ID).click();
|
||||
|
||||
expect(mockFlyoutContextValue.openLeftPanel).toHaveBeenCalledWith({
|
||||
|
|
|
@ -16,14 +16,15 @@ import { RightPanelContext } from '../context';
|
|||
import { InvestigationSection } from './investigation_section';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { useRuleWithFallback } from '../../../detection_engine/rule_management/logic/use_rule_with_fallback';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
|
||||
const mockUseRuleWithFallback = useRuleWithFallback as jest.Mock;
|
||||
jest.mock('../../../detection_engine/rule_management/logic/use_rule_with_fallback');
|
||||
|
||||
const flyoutContextValue = {} as unknown as ExpandableFlyoutContext;
|
||||
const panelContextValue = {
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser.filter(
|
||||
(d) => d.field !== 'kibana.alert.rule.type'
|
||||
),
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const renderInvestigationSection = (expanded: boolean = false) =>
|
||||
|
@ -40,7 +41,7 @@ const renderInvestigationSection = (expanded: boolean = false) =>
|
|||
describe('<InvestigationSection />', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockUseRuleWithFallback.mockReturnValue({ rule: { note: 'test note' } });
|
||||
(useRuleWithFallback as jest.Mock).mockReturnValue({ rule: { note: 'test note' } });
|
||||
});
|
||||
it('should render the component collapsed', () => {
|
||||
const { getByTestId } = renderInvestigationSection();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import type { Story } from '@storybook/react';
|
||||
import { mockSearchHit } from '../mocks/mock_context';
|
||||
import { mockSearchHit } from '../../shared/mocks/mock_search_hit';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { MitreAttack } from './mitre_attack';
|
||||
|
||||
|
|
|
@ -6,39 +6,42 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { act, render } from '@testing-library/react';
|
||||
import { MitreAttack } from './mitre_attack';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { MITRE_ATTACK_DETAILS_TEST_ID, MITRE_ATTACK_TITLE_TEST_ID } from './test_ids';
|
||||
import { mockSearchHit } from '../mocks/mock_context';
|
||||
import { mockSearchHit } from '../../shared/mocks/mock_search_hit';
|
||||
|
||||
const renderMitreAttack = (contextValue: RightPanelContext) =>
|
||||
render(
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<MitreAttack />
|
||||
</RightPanelContext.Provider>
|
||||
);
|
||||
|
||||
describe('<MitreAttack />', () => {
|
||||
it('should render mitre attack information', () => {
|
||||
it('should render mitre attack information', async () => {
|
||||
const contextValue = { searchHit: mockSearchHit } as unknown as RightPanelContext;
|
||||
|
||||
const { getByTestId } = render(
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<MitreAttack />
|
||||
</RightPanelContext.Provider>
|
||||
);
|
||||
const { getByTestId } = renderMitreAttack(contextValue);
|
||||
|
||||
expect(getByTestId(MITRE_ATTACK_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(MITRE_ATTACK_DETAILS_TEST_ID)).toBeInTheDocument();
|
||||
await act(async () => {
|
||||
expect(getByTestId(MITRE_ATTACK_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(MITRE_ATTACK_DETAILS_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('should render empty component if missing mitre attack value', () => {
|
||||
it('should render empty component if missing mitre attack value', async () => {
|
||||
const contextValue = {
|
||||
searchHit: {
|
||||
some_field: 'some_value',
|
||||
},
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const { container } = render(
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<MitreAttack />
|
||||
</RightPanelContext.Provider>
|
||||
);
|
||||
const { container } = renderMitreAttack(contextValue);
|
||||
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
await act(async () => {
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@ import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
|||
import { render } from '@testing-library/react';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { INSIGHTS_PREVALENCE_NO_DATA_TEST_ID, INSIGHTS_PREVALENCE_TEST_ID } from './test_ids';
|
||||
import { PREVALENCE_NO_DATA_TEST_ID, PREVALENCE_TEST_ID } from './test_ids';
|
||||
import { LeftPanelInsightsTab, LeftPanelKey } from '../../left';
|
||||
import React from 'react';
|
||||
import { PrevalenceOverview } from './prevalence_overview';
|
||||
|
@ -22,28 +22,29 @@ import {
|
|||
EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID,
|
||||
} from '../../shared/components/test_ids';
|
||||
import { usePrevalence } from '../../shared/hooks/use_prevalence';
|
||||
import { mockContextValue } from '../mocks/mock_right_panel_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
|
||||
jest.mock('../../shared/hooks/use_prevalence');
|
||||
|
||||
const TOGGLE_ICON_TEST_ID = EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID(INSIGHTS_PREVALENCE_TEST_ID);
|
||||
const TITLE_LINK_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(INSIGHTS_PREVALENCE_TEST_ID);
|
||||
const TITLE_ICON_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID(INSIGHTS_PREVALENCE_TEST_ID);
|
||||
const TITLE_TEXT_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID(INSIGHTS_PREVALENCE_TEST_ID);
|
||||
const TOGGLE_ICON_TEST_ID = EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID(PREVALENCE_TEST_ID);
|
||||
const TITLE_LINK_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(PREVALENCE_TEST_ID);
|
||||
const TITLE_ICON_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID(PREVALENCE_TEST_ID);
|
||||
const TITLE_TEXT_TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID(PREVALENCE_TEST_ID);
|
||||
|
||||
const flyoutContextValue = {
|
||||
openLeftPanel: jest.fn(),
|
||||
} as unknown as ExpandableFlyoutContext;
|
||||
|
||||
const renderPrevalenceOverview = (contextValue: RightPanelContext = mockContextValue) => (
|
||||
<TestProviders>
|
||||
<ExpandableFlyoutContext.Provider value={flyoutContextValue}>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<PrevalenceOverview />
|
||||
</RightPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const renderPrevalenceOverview = (contextValue: RightPanelContext = mockContextValue) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<ExpandableFlyoutContext.Provider value={flyoutContextValue}>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<PrevalenceOverview />
|
||||
</RightPanelContext.Provider>
|
||||
</ExpandableFlyoutContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<PrevalenceOverview />', () => {
|
||||
it('should render wrapper component', () => {
|
||||
|
@ -53,7 +54,7 @@ describe('<PrevalenceOverview />', () => {
|
|||
data: [],
|
||||
});
|
||||
|
||||
const { getByTestId, queryByTestId } = render(renderPrevalenceOverview());
|
||||
const { getByTestId, queryByTestId } = renderPrevalenceOverview();
|
||||
expect(queryByTestId(TOGGLE_ICON_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_LINK_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(TITLE_LINK_TEST_ID)).toHaveTextContent('Prevalence');
|
||||
|
@ -68,12 +69,10 @@ describe('<PrevalenceOverview />', () => {
|
|||
data: [],
|
||||
});
|
||||
|
||||
const { getByTestId, queryByTestId } = render(renderPrevalenceOverview());
|
||||
const { getByTestId, queryByTestId } = renderPrevalenceOverview();
|
||||
|
||||
expect(
|
||||
getByTestId(EXPANDABLE_PANEL_LOADING_TEST_ID(INSIGHTS_PREVALENCE_TEST_ID))
|
||||
).toBeInTheDocument();
|
||||
expect(queryByTestId(INSIGHTS_PREVALENCE_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(getByTestId(EXPANDABLE_PANEL_LOADING_TEST_ID(PREVALENCE_TEST_ID))).toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render no-data message', () => {
|
||||
|
@ -83,10 +82,10 @@ describe('<PrevalenceOverview />', () => {
|
|||
data: [],
|
||||
});
|
||||
|
||||
const { getByTestId } = render(renderPrevalenceOverview());
|
||||
const { getByTestId } = renderPrevalenceOverview();
|
||||
|
||||
expect(getByTestId(INSIGHTS_PREVALENCE_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(INSIGHTS_PREVALENCE_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
expect(getByTestId(PREVALENCE_NO_DATA_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(PREVALENCE_NO_DATA_TEST_ID)).toHaveTextContent(
|
||||
'No prevalence data available.'
|
||||
);
|
||||
});
|
||||
|
@ -117,22 +116,22 @@ describe('<PrevalenceOverview />', () => {
|
|||
],
|
||||
});
|
||||
|
||||
const { queryByTestId, getByTestId } = render(renderPrevalenceOverview());
|
||||
const { queryByTestId, getByTestId } = renderPrevalenceOverview();
|
||||
|
||||
expect(getByTestId(TITLE_LINK_TEST_ID)).toHaveTextContent('Prevalence');
|
||||
|
||||
const iconDataTestSubj1 = `${INSIGHTS_PREVALENCE_TEST_ID}${field1}Icon`;
|
||||
const valueDataTestSubj1 = `${INSIGHTS_PREVALENCE_TEST_ID}${field1}Value`;
|
||||
const iconDataTestSubj1 = `${PREVALENCE_TEST_ID}${field1}Icon`;
|
||||
const valueDataTestSubj1 = `${PREVALENCE_TEST_ID}${field1}Value`;
|
||||
expect(getByTestId(iconDataTestSubj1)).toBeInTheDocument();
|
||||
expect(getByTestId(valueDataTestSubj1)).toBeInTheDocument();
|
||||
expect(getByTestId(valueDataTestSubj1)).toHaveTextContent('field1, value1 is uncommon');
|
||||
|
||||
const iconDataTestSubj2 = `${INSIGHTS_PREVALENCE_TEST_ID}${field2}Icon`;
|
||||
const valueDataTestSubj2 = `${INSIGHTS_PREVALENCE_TEST_ID}${field2}Value`;
|
||||
const iconDataTestSubj2 = `${PREVALENCE_TEST_ID}${field2}Icon`;
|
||||
const valueDataTestSubj2 = `${PREVALENCE_TEST_ID}${field2}Value`;
|
||||
expect(queryByTestId(iconDataTestSubj2)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(valueDataTestSubj2)).not.toBeInTheDocument();
|
||||
|
||||
expect(queryByTestId(INSIGHTS_PREVALENCE_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
expect(queryByTestId(PREVALENCE_NO_DATA_TEST_ID)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should navigate to left section Insights tab when clicking on button', () => {
|
||||
|
@ -151,7 +150,7 @@ describe('<PrevalenceOverview />', () => {
|
|||
],
|
||||
});
|
||||
|
||||
const { getByTestId } = render(renderPrevalenceOverview());
|
||||
const { getByTestId } = renderPrevalenceOverview();
|
||||
|
||||
getByTestId(TITLE_LINK_TEST_ID).click();
|
||||
expect(flyoutContextValue.openLeftPanel).toHaveBeenCalledWith({
|
||||
|
|
|
@ -12,7 +12,7 @@ import { useExpandableFlyoutContext } from '@kbn/expandable-flyout';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { ExpandablePanel } from '../../shared/components/expandable_panel';
|
||||
import { usePrevalence } from '../../shared/hooks/use_prevalence';
|
||||
import { INSIGHTS_PREVALENCE_NO_DATA_TEST_ID, INSIGHTS_PREVALENCE_TEST_ID } from './test_ids';
|
||||
import { PREVALENCE_NO_DATA_TEST_ID, PREVALENCE_TEST_ID } from './test_ids';
|
||||
import { useRightPanelContext } from '../context';
|
||||
import { LeftPanelKey, LeftPanelInsightsTab } from '../../left';
|
||||
import { PREVALENCE_TAB_ID } from '../../left/components/prevalence_details';
|
||||
|
@ -80,7 +80,7 @@ export const PrevalenceOverview: FC = () => {
|
|||
iconType: 'arrowStart',
|
||||
}}
|
||||
content={{ loading, error }}
|
||||
data-test-subj={INSIGHTS_PREVALENCE_TEST_ID}
|
||||
data-test-subj={PREVALENCE_TEST_ID}
|
||||
>
|
||||
<EuiFlexGroup direction="column" gutterSize="none">
|
||||
{uncommonData.length > 0 ? (
|
||||
|
@ -94,11 +94,12 @@ export const PrevalenceOverview: FC = () => {
|
|||
values={{ field: d.field, value: d.value }}
|
||||
/>
|
||||
}
|
||||
data-test-subj={`${INSIGHTS_PREVALENCE_TEST_ID}${d.field}`}
|
||||
data-test-subj={`${PREVALENCE_TEST_ID}${d.field}`}
|
||||
key={`${PREVALENCE_TEST_ID}${d.field}`}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
<p data-test-subj={INSIGHTS_PREVALENCE_NO_DATA_TEST_ID}>
|
||||
<p data-test-subj={PREVALENCE_NO_DATA_TEST_ID}>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.right.insights.prevalence.noDataDescription"
|
||||
defaultMessage="No prevalence data available."
|
||||
|
|
|
@ -15,8 +15,9 @@ import {
|
|||
} from './test_ids';
|
||||
import { Reason } from './reason';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { mockDataFormattedForFieldBrowser, mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { PreviewPanelKey } from '../../preview';
|
||||
|
||||
const flyoutContextValue = {
|
||||
|
@ -54,8 +55,9 @@ describe('<Reason />', () => {
|
|||
});
|
||||
|
||||
it('should render the component for document', () => {
|
||||
const dataFormattedForFieldBrowser = [...mockDataFormattedForFieldBrowser];
|
||||
dataFormattedForFieldBrowser.shift();
|
||||
const dataFormattedForFieldBrowser = mockDataFormattedForFieldBrowser.filter(
|
||||
(d) => d.field !== 'kibana.alert.rule.uuid'
|
||||
);
|
||||
const panelContext = {
|
||||
...panelContextValue,
|
||||
dataFormattedForFieldBrowser,
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
SUMMARY_ROW_ICON_TEST_ID,
|
||||
SUMMARY_ROW_VALUE_TEST_ID,
|
||||
SUMMARY_ROW_LOADING_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { RelatedAlertsByAncestry } from './related_alerts_by_ancestry';
|
||||
import { useFetchRelatedAlertsByAncestry } from '../../shared/hooks/use_fetch_related_alerts_by_ancestry';
|
||||
|
@ -23,14 +23,10 @@ const documentId = 'documentId';
|
|||
const indices = ['indices'];
|
||||
const scopeId = 'scopeId';
|
||||
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID
|
||||
);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID
|
||||
);
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID);
|
||||
const LOADING_TEST_ID = SUMMARY_ROW_LOADING_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID
|
||||
CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID
|
||||
);
|
||||
|
||||
const renderRelatedAlertsByAncestry = () =>
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { useFetchRelatedAlertsByAncestry } from '../../shared/hooks/use_fetch_related_alerts_by_ancestry';
|
||||
import { InsightsSummaryRow } from './insights_summary_row';
|
||||
import { INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID } from './test_ids';
|
||||
import { CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID } from './test_ids';
|
||||
|
||||
const ICON = 'warning';
|
||||
|
||||
|
@ -56,7 +56,7 @@ export const RelatedAlertsByAncestry: React.VFC<RelatedAlertsByAncestryProps> =
|
|||
icon={ICON}
|
||||
value={dataCount}
|
||||
text={text}
|
||||
data-test-subj={INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID}
|
||||
data-test-subj={CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID}
|
||||
key={`correlation-row-${text}`}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
SUMMARY_ROW_ICON_TEST_ID,
|
||||
SUMMARY_ROW_VALUE_TEST_ID,
|
||||
SUMMARY_ROW_LOADING_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { useFetchRelatedAlertsBySameSourceEvent } from '../../shared/hooks/use_fetch_related_alerts_by_same_source_event';
|
||||
import { RelatedAlertsBySameSourceEvent } from './related_alerts_by_same_source_event';
|
||||
|
@ -23,13 +23,13 @@ const originalEventId = 'originalEventId';
|
|||
const scopeId = 'scopeId';
|
||||
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID
|
||||
);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID
|
||||
);
|
||||
const LOADING_TEST_ID = SUMMARY_ROW_LOADING_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID
|
||||
);
|
||||
|
||||
const renderRelatedAlertsBySameSourceEvent = () =>
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { useFetchRelatedAlertsBySameSourceEvent } from '../../shared/hooks/use_fetch_related_alerts_by_same_source_event';
|
||||
import { InsightsSummaryRow } from './insights_summary_row';
|
||||
import { INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID } from './test_ids';
|
||||
import { CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID } from './test_ids';
|
||||
|
||||
const ICON = 'warning';
|
||||
|
||||
|
@ -50,7 +50,7 @@ export const RelatedAlertsBySameSourceEvent: React.VFC<RelatedAlertsBySameSource
|
|||
icon={ICON}
|
||||
value={dataCount}
|
||||
text={text}
|
||||
data-test-subj={INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID}
|
||||
data-test-subj={CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID}
|
||||
key={`correlation-row-${text}`}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
SUMMARY_ROW_ICON_TEST_ID,
|
||||
SUMMARY_ROW_VALUE_TEST_ID,
|
||||
SUMMARY_ROW_LOADING_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { RelatedAlertsBySession } from './related_alerts_by_session';
|
||||
import { useFetchRelatedAlertsBySession } from '../../shared/hooks/use_fetch_related_alerts_by_session';
|
||||
|
@ -22,15 +22,9 @@ jest.mock('../../shared/hooks/use_fetch_related_alerts_by_session');
|
|||
const entityId = 'entityId';
|
||||
const scopeId = 'scopeId';
|
||||
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID
|
||||
);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID
|
||||
);
|
||||
const LOADING_TEST_ID = SUMMARY_ROW_LOADING_TEST_ID(
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID
|
||||
);
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID);
|
||||
const LOADING_TEST_ID = SUMMARY_ROW_LOADING_TEST_ID(CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID);
|
||||
|
||||
const renderRelatedAlertsBySession = () =>
|
||||
render(
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { useFetchRelatedAlertsBySession } from '../../shared/hooks/use_fetch_related_alerts_by_session';
|
||||
import { InsightsSummaryRow } from './insights_summary_row';
|
||||
import { INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID } from './test_ids';
|
||||
import { CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID } from './test_ids';
|
||||
|
||||
const ICON = 'warning';
|
||||
|
||||
|
@ -50,7 +50,7 @@ export const RelatedAlertsBySession: React.VFC<RelatedAlertsBySessionProps> = ({
|
|||
icon={ICON}
|
||||
value={dataCount}
|
||||
text={text}
|
||||
data-test-subj={INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID}
|
||||
data-test-subj={CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID}
|
||||
key={`correlation-row-${text}`}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
|
||||
import { render } from '@testing-library/react';
|
||||
import {
|
||||
INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID,
|
||||
CORRELATIONS_RELATED_CASES_TEST_ID,
|
||||
SUMMARY_ROW_ICON_TEST_ID,
|
||||
SUMMARY_ROW_LOADING_TEST_ID,
|
||||
SUMMARY_ROW_VALUE_TEST_ID,
|
||||
|
@ -21,9 +21,9 @@ jest.mock('../../shared/hooks/use_fetch_related_cases');
|
|||
|
||||
const eventId = 'eventId';
|
||||
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID);
|
||||
const LOADING_TEST_ID = SUMMARY_ROW_LOADING_TEST_ID(INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID);
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(CORRELATIONS_RELATED_CASES_TEST_ID);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_RELATED_CASES_TEST_ID);
|
||||
const LOADING_TEST_ID = SUMMARY_ROW_LOADING_TEST_ID(CORRELATIONS_RELATED_CASES_TEST_ID);
|
||||
|
||||
const renderRelatedCases = () =>
|
||||
render(
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { useFetchRelatedCases } from '../../shared/hooks/use_fetch_related_cases';
|
||||
import { InsightsSummaryRow } from './insights_summary_row';
|
||||
import { INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID } from './test_ids';
|
||||
import { CORRELATIONS_RELATED_CASES_TEST_ID } from './test_ids';
|
||||
|
||||
const ICON = 'warning';
|
||||
|
||||
|
@ -40,7 +40,7 @@ export const RelatedCases: React.VFC<RelatedCasesProps> = ({ eventId }) => {
|
|||
icon={ICON}
|
||||
value={dataCount}
|
||||
text={text}
|
||||
data-test-subj={INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID}
|
||||
data-test-subj={CORRELATIONS_RELATED_CASES_TEST_ID}
|
||||
key={`correlation-row-${text}`}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -10,7 +10,7 @@ import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
|
|||
import { render } from '@testing-library/react';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { RESPONSE_BUTTON_TEST_ID, RESPONSE_EMPTY_TEST_ID } from './test_ids';
|
||||
import { mockContextValue } from '../mocks/mock_right_panel_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { mockFlyoutContextValue } from '../../shared/mocks/mock_flyout_context';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { ResponseButton } from './response_button';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import type { Story } from '@storybook/react';
|
||||
import { mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { RiskScore } from './risk_score';
|
||||
import { RightPanelContext } from '../context';
|
||||
|
||||
|
|
|
@ -9,12 +9,9 @@ import React from 'react';
|
|||
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { RightPanelContext } from '../context';
|
||||
import {
|
||||
FLYOUT_HEADER_RISK_SCORE_TITLE_TEST_ID,
|
||||
FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { RISK_SCORE_TITLE_TEST_ID, RISK_SCORE_VALUE_TEST_ID } from './test_ids';
|
||||
import { RiskScore } from './risk_score';
|
||||
import { mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
|
||||
const renderRiskScore = (contextValue: RightPanelContext) =>
|
||||
render(
|
||||
|
@ -33,8 +30,8 @@ describe('<RiskScore />', () => {
|
|||
|
||||
const { getByTestId } = renderRiskScore(contextValue);
|
||||
|
||||
expect(getByTestId(FLYOUT_HEADER_RISK_SCORE_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
const riskScore = getByTestId(FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID);
|
||||
expect(getByTestId(RISK_SCORE_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
const riskScore = getByTestId(RISK_SCORE_VALUE_TEST_ID);
|
||||
expect(riskScore).toBeInTheDocument();
|
||||
expect(riskScore).toHaveTextContent('0');
|
||||
});
|
||||
|
|
|
@ -10,10 +10,7 @@ import React, { memo } from 'react';
|
|||
import { EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';
|
||||
import { ALERT_RISK_SCORE } from '@kbn/rule-data-utils';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import {
|
||||
FLYOUT_HEADER_RISK_SCORE_TITLE_TEST_ID,
|
||||
FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { RISK_SCORE_TITLE_TEST_ID, RISK_SCORE_VALUE_TEST_ID } from './test_ids';
|
||||
import { useRightPanelContext } from '../context';
|
||||
|
||||
/**
|
||||
|
@ -39,7 +36,7 @@ export const RiskScore: FC = memo(() => {
|
|||
return (
|
||||
<EuiFlexGroup alignItems="center" direction="row" gutterSize="xs">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiTitle size="xxs" data-test-subj={FLYOUT_HEADER_RISK_SCORE_TITLE_TEST_ID}>
|
||||
<EuiTitle size="xxs" data-test-subj={RISK_SCORE_TITLE_TEST_ID}>
|
||||
<h5>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.right.header.riskScoreTitle"
|
||||
|
@ -49,7 +46,7 @@ export const RiskScore: FC = memo(() => {
|
|||
</EuiTitle>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<span data-test-subj={FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID}>{alertRiskScore}</span>
|
||||
<span data-test-subj={RISK_SCORE_VALUE_TEST_ID}>{alertRiskScore}</span>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
);
|
||||
|
|
|
@ -24,7 +24,7 @@ import {
|
|||
EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID,
|
||||
EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID,
|
||||
} from '../../shared/components/test_ids';
|
||||
import { mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
|
||||
jest.mock('../hooks/use_session_preview');
|
||||
jest.mock('../../../common/hooks/use_license');
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import type { Story } from '@storybook/react';
|
||||
import { mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { DocumentSeverity } from './severity';
|
||||
import { RightPanelContext } from '../context';
|
||||
|
||||
|
|
|
@ -8,14 +8,20 @@
|
|||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { RightPanelContext } from '../context';
|
||||
import {
|
||||
FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID,
|
||||
FLYOUT_HEADER_SEVERITY_VALUE_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { SEVERITY_TITLE_TEST_ID, SEVERITY_VALUE_TEST_ID } from './test_ids';
|
||||
import { DocumentSeverity } from './severity';
|
||||
import { mockGetFieldsData } from '../mocks/mock_context';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
|
||||
const renderDocumentSeverity = (contextValue: RightPanelContext) =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<DocumentSeverity />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<DocumentSeverity />', () => {
|
||||
it('should render severity information', () => {
|
||||
const contextValue = {
|
||||
|
@ -23,16 +29,10 @@ describe('<DocumentSeverity />', () => {
|
|||
scopeId: 'scopeId',
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<DocumentSeverity />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderDocumentSeverity(contextValue);
|
||||
|
||||
expect(getByTestId(FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
const severity = getByTestId(FLYOUT_HEADER_SEVERITY_VALUE_TEST_ID);
|
||||
expect(getByTestId(SEVERITY_TITLE_TEST_ID)).toBeInTheDocument();
|
||||
const severity = getByTestId(SEVERITY_VALUE_TEST_ID);
|
||||
expect(severity).toBeInTheDocument();
|
||||
expect(severity).toHaveTextContent('Low');
|
||||
});
|
||||
|
@ -43,11 +43,7 @@ describe('<DocumentSeverity />', () => {
|
|||
scopeId: 'scopeId',
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const { container } = render(
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<DocumentSeverity />
|
||||
</RightPanelContext.Provider>
|
||||
);
|
||||
const { container } = renderDocumentSeverity(contextValue);
|
||||
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
@ -58,11 +54,7 @@ describe('<DocumentSeverity />', () => {
|
|||
scopeId: 'scopeId',
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const { container } = render(
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<DocumentSeverity />
|
||||
</RightPanelContext.Provider>
|
||||
);
|
||||
const { container } = renderDocumentSeverity(contextValue);
|
||||
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
@ -73,11 +65,7 @@ describe('<DocumentSeverity />', () => {
|
|||
scopeId: 'scopeId',
|
||||
} as unknown as RightPanelContext;
|
||||
|
||||
const { container } = render(
|
||||
<RightPanelContext.Provider value={contextValue}>
|
||||
<DocumentSeverity />
|
||||
</RightPanelContext.Provider>
|
||||
);
|
||||
const { container } = renderDocumentSeverity(contextValue);
|
||||
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ import { SecurityCellActions } from '../../../common/components/cell_actions';
|
|||
import { SecurityCellActionsTrigger } from '../../../actions/constants';
|
||||
import { useRightPanelContext } from '../context';
|
||||
import { SeverityBadge } from '../../../detections/components/rules/severity_badge';
|
||||
import { FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID } from './test_ids';
|
||||
import { SEVERITY_TITLE_TEST_ID } from './test_ids';
|
||||
|
||||
const isSeverity = (x: unknown): x is Severity =>
|
||||
x === 'low' || x === 'medium' || x === 'high' || x === 'critical';
|
||||
|
@ -45,7 +45,7 @@ export const DocumentSeverity: FC = memo(() => {
|
|||
return (
|
||||
<EuiFlexGroup alignItems="center" direction="row" gutterSize="xs">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiTitle size="xxs" data-test-subj={FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID}>
|
||||
<EuiTitle size="xxs" data-test-subj={SEVERITY_TITLE_TEST_ID}>
|
||||
<h5>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.right.header.severityTitle"
|
||||
|
|
|
@ -10,7 +10,7 @@ import { render, screen, fireEvent } from '@testing-library/react';
|
|||
import { copyToClipboard } from '@elastic/eui';
|
||||
import { ShareButton } from './share_button';
|
||||
import React from 'react';
|
||||
import { FLYOUT_HEADER_SHARE_BUTTON_TEST_ID } from './test_ids';
|
||||
import { SHARE_BUTTON_TEST_ID } from './test_ids';
|
||||
import { FLYOUT_URL_PARAM } from '../../shared/hooks/url/use_sync_flyout_state_with_url';
|
||||
|
||||
jest.mock('@elastic/eui', () => ({
|
||||
|
@ -36,7 +36,7 @@ describe('ShareButton', () => {
|
|||
it('renders the share button', () => {
|
||||
renderShareButton();
|
||||
|
||||
expect(screen.getByTestId(FLYOUT_HEADER_SHARE_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
expect(screen.getByTestId(SHARE_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('copies the alert URL to clipboard', () => {
|
||||
|
@ -51,7 +51,7 @@ describe('ShareButton', () => {
|
|||
|
||||
renderShareButton();
|
||||
|
||||
fireEvent.click(screen.getByTestId(FLYOUT_HEADER_SHARE_BUTTON_TEST_ID));
|
||||
fireEvent.click(screen.getByTestId(SHARE_BUTTON_TEST_ID));
|
||||
|
||||
expect(copyToClipboard).toHaveBeenCalledWith(
|
||||
`${alertUrl}&${FLYOUT_URL_PARAM}=${syncedFlyoutState}`
|
||||
|
|
|
@ -10,7 +10,7 @@ import type { FC } from 'react';
|
|||
import React from 'react';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { FLYOUT_URL_PARAM } from '../../shared/hooks/url/use_sync_flyout_state_with_url';
|
||||
import { FLYOUT_HEADER_SHARE_BUTTON_TEST_ID } from './test_ids';
|
||||
import { SHARE_BUTTON_TEST_ID } from './test_ids';
|
||||
|
||||
interface ShareButtonProps {
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ export const ShareButton: FC<ShareButtonProps> = ({ alertUrl }) => {
|
|||
copyToClipboard(alertDetailsLink);
|
||||
}}
|
||||
iconType="share"
|
||||
data-test-subj={FLYOUT_HEADER_SHARE_BUTTON_TEST_ID}
|
||||
data-test-subj={SHARE_BUTTON_TEST_ID}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.flyout.right.header.shareButtonLabel"
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
import React from 'react';
|
||||
import type { Story } from '@storybook/react';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { mockBrowserFields } from '../../shared/mocks/mock_browser_fields';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { StorybookProviders } from '../../../common/mock/storybook_providers';
|
||||
import { DocumentStatus } from './status';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { mockBrowserFields, mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
|
||||
export default {
|
||||
component: DocumentStatus,
|
||||
|
|
|
@ -10,10 +10,10 @@ import { render } from '@testing-library/react';
|
|||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { DocumentStatus } from './status';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { useAlertsActions } from '../../../detections/components/alerts_table/timeline_actions/use_alerts_actions';
|
||||
import { FLYOUT_HEADER_STATUS_BUTTON_TEST_ID } from './test_ids';
|
||||
import { STATUS_BUTTON_TEST_ID } from './test_ids';
|
||||
|
||||
jest.mock('../../../detections/components/alerts_table/timeline_actions/use_alerts_actions');
|
||||
|
||||
|
@ -53,10 +53,10 @@ describe('<DocumentStatus />', () => {
|
|||
|
||||
const { getByTestId, getByText } = renderStatus(contextValue);
|
||||
|
||||
expect(getByTestId(FLYOUT_HEADER_STATUS_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByTestId(STATUS_BUTTON_TEST_ID)).toBeInTheDocument();
|
||||
expect(getByText('open')).toBeInTheDocument();
|
||||
|
||||
getByTestId(FLYOUT_HEADER_STATUS_BUTTON_TEST_ID).click();
|
||||
getByTestId(STATUS_BUTTON_TEST_ID).click();
|
||||
expect(getByTestId('data-test-subj')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ import { render } from '@testing-library/react';
|
|||
import {
|
||||
SUMMARY_ROW_ICON_TEST_ID,
|
||||
SUMMARY_ROW_VALUE_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID,
|
||||
CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID,
|
||||
CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { SuppressedAlerts } from './suppressed_alerts';
|
||||
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID);
|
||||
const ICON_TEST_ID = SUMMARY_ROW_ICON_TEST_ID(CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID);
|
||||
const VALUE_TEST_ID = SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID);
|
||||
|
||||
const renderSuppressedAlerts = (alertSuppressionCount: number) =>
|
||||
render(
|
||||
|
@ -36,7 +36,7 @@ describe('<SuppressedAlerts />', () => {
|
|||
expect(value).toHaveTextContent('0 suppressed alert');
|
||||
expect(getByTestId(VALUE_TEST_ID)).toBeInTheDocument();
|
||||
expect(
|
||||
getByTestId(INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID)
|
||||
getByTestId(CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
@ -49,7 +49,7 @@ describe('<SuppressedAlerts />', () => {
|
|||
expect(value).toHaveTextContent('1 suppressed alert');
|
||||
expect(getByTestId(VALUE_TEST_ID)).toBeInTheDocument();
|
||||
expect(
|
||||
getByTestId(INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID)
|
||||
getByTestId(CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
@ -62,7 +62,7 @@ describe('<SuppressedAlerts />', () => {
|
|||
expect(value).toHaveTextContent('2 suppressed alerts');
|
||||
expect(getByTestId(VALUE_TEST_ID)).toBeInTheDocument();
|
||||
expect(
|
||||
getByTestId(INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID)
|
||||
getByTestId(CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,8 +9,8 @@ import React from 'react';
|
|||
import { EuiFlexGroup, EuiFlexItem, EuiBetaBadge } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import {
|
||||
INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID,
|
||||
CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID,
|
||||
CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { InsightsSummaryRow } from './insights_summary_row';
|
||||
import { SUPPRESSED_ALERTS_COUNT_TECHNICAL_PREVIEW } from '../../../common/components/event_details/insights/translations';
|
||||
|
@ -41,7 +41,7 @@ export const SuppressedAlerts: React.VFC<SuppressedAlertsProps> = ({ alertSuppre
|
|||
values={{ count: alertSuppressionCount }}
|
||||
/>
|
||||
}
|
||||
data-test-subj={INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID}
|
||||
data-test-subj={CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID}
|
||||
key={`correlation-row-suppressed-alerts`}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
|
@ -57,7 +57,7 @@ export const SuppressedAlerts: React.VFC<SuppressedAlertsProps> = ({ alertSuppre
|
|||
/>
|
||||
}
|
||||
tooltipPosition="bottom"
|
||||
data-test-subj={INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID}
|
||||
data-test-subj={CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
|
|
@ -5,74 +5,66 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { RESPONSE_BASE_TEST_ID } from '../../left/components/test_ids';
|
||||
import { PREFIX } from '../../shared/test_ids';
|
||||
import { CONTENT_TEST_ID, HEADER_TEST_ID } from './expandable_section';
|
||||
|
||||
/* Header */
|
||||
|
||||
export const FLYOUT_HEADER_TITLE_TEST_ID = 'securitySolutionDocumentDetailsFlyoutHeaderTitle';
|
||||
export const EXPAND_DETAILS_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutHeaderExpandDetailButton';
|
||||
const FLYOUT_HEADER_TEST_ID = `${PREFIX}Header` as const;
|
||||
export const FLYOUT_HEADER_TITLE_TEST_ID = `${FLYOUT_HEADER_TEST_ID}Title` as const;
|
||||
export const EXPAND_DETAILS_BUTTON_TEST_ID = `${FLYOUT_HEADER_TEST_ID}ExpandDetailButton` as const;
|
||||
export const COLLAPSE_DETAILS_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutHeaderCollapseDetailButton';
|
||||
export const FLYOUT_HEADER_STATUS_BUTTON_TEST_ID = 'rule-status-badge';
|
||||
export const FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID =
|
||||
'securitySolutionAlertDetailsFlyoutHeaderSeverityTitle';
|
||||
export const FLYOUT_HEADER_SEVERITY_VALUE_TEST_ID = 'severity';
|
||||
export const FLYOUT_HEADER_RISK_SCORE_TITLE_TEST_ID =
|
||||
'securitySolutionAlertDetailsFlyoutHeaderRiskScoreTitle';
|
||||
export const FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID =
|
||||
'securitySolutionAlertDetailsFlyoutHeaderRiskScoreValue';
|
||||
export const FLYOUT_HEADER_SHARE_BUTTON_TEST_ID =
|
||||
'securitySolutionAlertDetailsFlyoutHeaderShareButton';
|
||||
export const FLYOUT_HEADER_CHAT_BUTTON_TEST_ID = 'newChatById';
|
||||
`${FLYOUT_HEADER_TEST_ID}CollapseDetailButton` as const;
|
||||
export const STATUS_BUTTON_TEST_ID = 'rule-status-badge' as const;
|
||||
export const SEVERITY_TITLE_TEST_ID = `${FLYOUT_HEADER_TEST_ID}SeverityTitle` as const;
|
||||
export const SEVERITY_VALUE_TEST_ID = 'severity' as const;
|
||||
export const RISK_SCORE_TITLE_TEST_ID = `${FLYOUT_HEADER_TEST_ID}RiskScoreTitle` as const;
|
||||
export const RISK_SCORE_VALUE_TEST_ID = `${FLYOUT_HEADER_TEST_ID}RiskScoreValue` as const;
|
||||
export const SHARE_BUTTON_TEST_ID = `${FLYOUT_HEADER_TEST_ID}ShareButton` as const;
|
||||
export const CHAT_BUTTON_TEST_ID = 'newChatById' as const;
|
||||
|
||||
/* About section */
|
||||
|
||||
export const ABOUT_SECTION_TEST_ID = 'securitySolutionDocumentDetailsFlyoutAboutSection';
|
||||
export const ABOUT_SECTION_TEST_ID = `${PREFIX}AboutSection` as const;
|
||||
export const ABOUT_SECTION_HEADER_TEST_ID = ABOUT_SECTION_TEST_ID + HEADER_TEST_ID;
|
||||
export const ABOUT_SECTION_CONTENT_TEST_ID = ABOUT_SECTION_TEST_ID + CONTENT_TEST_ID;
|
||||
export const RULE_SUMMARY_BUTTON_TEST_ID = 'securitySolutionDocumentDetailsFlyoutRuleSummaryButton';
|
||||
export const DESCRIPTION_TITLE_TEST_ID = 'securitySolutionDocumentDetailsFlyoutDescriptionTitle';
|
||||
export const DESCRIPTION_DETAILS_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutDescriptionDetails';
|
||||
export const REASON_TITLE_TEST_ID = 'securitySolutionDocumentDetailsFlyoutReasonTitle';
|
||||
export const REASON_DETAILS_TEST_ID = 'securitySolutionDocumentDetailsFlyoutReasonDetails';
|
||||
export const REASON_DETAILS_PREVIEW_BUTTON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutReasonDetailsPreviewButton';
|
||||
export const MITRE_ATTACK_TITLE_TEST_ID = 'securitySolutionAlertDetailsFlyoutMitreAttackTitle';
|
||||
export const MITRE_ATTACK_DETAILS_TEST_ID = 'securitySolutionAlertDetailsFlyoutMitreAttackDetails';
|
||||
export const RULE_SUMMARY_BUTTON_TEST_ID = `${PREFIX}RuleSummaryButton` as const;
|
||||
const DESCRIPTION_TEST_ID = `${PREFIX}Description` as const;
|
||||
export const DESCRIPTION_TITLE_TEST_ID = `${DESCRIPTION_TEST_ID}Title` as const;
|
||||
export const DESCRIPTION_DETAILS_TEST_ID = `${DESCRIPTION_TEST_ID}Details` as const;
|
||||
const REASON_TEST_ID = `${PREFIX}Reason` as const;
|
||||
export const REASON_TITLE_TEST_ID = `${REASON_TEST_ID}Title` as const;
|
||||
export const REASON_DETAILS_TEST_ID = `${REASON_TEST_ID}Details` as const;
|
||||
export const REASON_DETAILS_PREVIEW_BUTTON_TEST_ID = `${REASON_TEST_ID}PreviewButton` as const;
|
||||
const MITRE_ATTACK_TEST_ID = `${PREFIX}MitreAttack` as const;
|
||||
export const MITRE_ATTACK_TITLE_TEST_ID = `${MITRE_ATTACK_TEST_ID}Title` as const;
|
||||
export const MITRE_ATTACK_DETAILS_TEST_ID = `${MITRE_ATTACK_TEST_ID}Details` as const;
|
||||
|
||||
/* Investigation section */
|
||||
|
||||
export const INVESTIGATION_SECTION_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInvestigationSection';
|
||||
export const INVESTIGATION_SECTION_TEST_ID = `${PREFIX}InvestigationSection` as const;
|
||||
export const INVESTIGATION_SECTION_HEADER_TEST_ID = INVESTIGATION_SECTION_TEST_ID + HEADER_TEST_ID;
|
||||
export const INVESTIGATION_SECTION_CONTENT_TEST_ID =
|
||||
INVESTIGATION_SECTION_TEST_ID + CONTENT_TEST_ID;
|
||||
export const HIGHLIGHTED_FIELDS_TITLE_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutHighlightedFieldsTitle';
|
||||
export const HIGHLIGHTED_FIELDS_DETAILS_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutHighlightedFieldsDetails';
|
||||
export const HIGHLIGHTED_FIELDS_CELL_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutHighlightedFieldsCell';
|
||||
export const INVESTIGATION_GUIDE_TEST_ID = `${PREFIX}InvestigationGuide` as const;
|
||||
export const INVESTIGATION_GUIDE_BUTTON_TEST_ID = `${INVESTIGATION_GUIDE_TEST_ID}Button` as const;
|
||||
export const INVESTIGATION_GUIDE_LOADING_TEST_ID = `${INVESTIGATION_GUIDE_TEST_ID}Loading` as const;
|
||||
export const INVESTIGATION_GUIDE_NO_DATA_TEST_ID = `${INVESTIGATION_GUIDE_TEST_ID}NoData` as const;
|
||||
const HIGHLIGHTED_FIELDS_TEST_ID = `${PREFIX}HighlightedFields` as const;
|
||||
export const HIGHLIGHTED_FIELDS_TITLE_TEST_ID = `${HIGHLIGHTED_FIELDS_TEST_ID}Title` as const;
|
||||
export const HIGHLIGHTED_FIELDS_DETAILS_TEST_ID = `${HIGHLIGHTED_FIELDS_TEST_ID}Details` as const;
|
||||
export const HIGHLIGHTED_FIELDS_CELL_TEST_ID = `${HIGHLIGHTED_FIELDS_TEST_ID}Cell` as const;
|
||||
export const HIGHLIGHTED_FIELDS_BASIC_CELL_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutHighlightedFieldsBasicCell';
|
||||
`${HIGHLIGHTED_FIELDS_TEST_ID}BasicCell` as const;
|
||||
export const HIGHLIGHTED_FIELDS_LINKED_CELL_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutHighlightedFieldsLinkedCell';
|
||||
`${HIGHLIGHTED_FIELDS_TEST_ID}LinkedCell` as const;
|
||||
export const HIGHLIGHTED_FIELDS_AGENT_STATUS_CELL_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutHighlightedFieldsAgentStatusCell';
|
||||
|
||||
export const INVESTIGATION_GUIDE_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInvestigationGuide';
|
||||
export const INVESTIGATION_GUIDE_BUTTON_TEST_ID = `${INVESTIGATION_GUIDE_TEST_ID}Button`;
|
||||
export const INVESTIGATION_GUIDE_LOADING_TEST_ID = `${INVESTIGATION_GUIDE_TEST_ID}Loading`;
|
||||
export const INVESTIGATION_GUIDE_NO_DATA_TEST_ID = `${INVESTIGATION_GUIDE_TEST_ID}NoData`;
|
||||
`${HIGHLIGHTED_FIELDS_TEST_ID}AgentStatusCell` as const;
|
||||
|
||||
/* Insights section */
|
||||
|
||||
export const INSIGHTS_TEST_ID = 'securitySolutionDocumentDetailsFlyoutInsights';
|
||||
export const INSIGHTS_HEADER_TEST_ID = `${INSIGHTS_TEST_ID}Header`;
|
||||
export const INSIGHTS_TEST_ID = `${PREFIX}Insights` as const;
|
||||
export const INSIGHTS_HEADER_TEST_ID = `${INSIGHTS_TEST_ID}Header` as const;
|
||||
|
||||
/* Summary row */
|
||||
|
||||
|
@ -80,64 +72,71 @@ export const SUMMARY_ROW_LOADING_TEST_ID = (dataTestSubj: string) => `${dataTest
|
|||
export const SUMMARY_ROW_ICON_TEST_ID = (dataTestSubj: string) => `${dataTestSubj}Icon`;
|
||||
export const SUMMARY_ROW_VALUE_TEST_ID = (dataTestSubj: string) => `${dataTestSubj}Value`;
|
||||
|
||||
/* Insights Entities */
|
||||
/* Entities */
|
||||
|
||||
export const INSIGHTS_ENTITIES_TEST_ID = 'securitySolutionDocumentDetailsFlyoutInsightsEntities';
|
||||
export const INSIGHTS_ENTITIES_TEST_ID = `${PREFIX}InsightsEntities` as const;
|
||||
export const INSIGHTS_ENTITIES_NO_DATA_TEST_ID = `${INSIGHTS_ENTITIES_TEST_ID}NoData` as const;
|
||||
export const ENTITIES_USER_OVERVIEW_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutEntitiesUserOverview';
|
||||
export const ENTITIES_USER_OVERVIEW_LINK_TEST_ID = `${ENTITIES_USER_OVERVIEW_TEST_ID}Link`;
|
||||
export const ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID = `${ENTITIES_USER_OVERVIEW_TEST_ID}Domain`;
|
||||
export const ENTITIES_USER_OVERVIEW_LAST_SEEN_TEST_ID = `${ENTITIES_USER_OVERVIEW_TEST_ID}LastSeen`;
|
||||
export const ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID = `${ENTITIES_USER_OVERVIEW_TEST_ID}RiskLevel`;
|
||||
export const ENTITIES_HOST_OVERVIEW_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutEntitiesHostOverview';
|
||||
export const ENTITIES_HOST_OVERVIEW_LINK_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TEST_ID}Link`;
|
||||
export const ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TEST_ID}OsFamily`;
|
||||
export const ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TEST_ID}LastSeen`;
|
||||
export const ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TEST_ID}RiskLevel`;
|
||||
export const ENTITIES_USER_OVERVIEW_TEST_ID = `${INSIGHTS_ENTITIES_TEST_ID}UserOverview` as const;
|
||||
export const ENTITIES_USER_OVERVIEW_LINK_TEST_ID = `${ENTITIES_USER_OVERVIEW_TEST_ID}Link` as const;
|
||||
export const ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID =
|
||||
`${ENTITIES_USER_OVERVIEW_TEST_ID}Domain` as const;
|
||||
export const ENTITIES_USER_OVERVIEW_LAST_SEEN_TEST_ID =
|
||||
`${ENTITIES_USER_OVERVIEW_TEST_ID}LastSeen` as const;
|
||||
export const ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID =
|
||||
`${ENTITIES_USER_OVERVIEW_TEST_ID}RiskLevel` as const;
|
||||
export const ENTITIES_HOST_OVERVIEW_TEST_ID = `${INSIGHTS_ENTITIES_TEST_ID}HostOverview` as const;
|
||||
export const ENTITIES_HOST_OVERVIEW_LINK_TEST_ID = `${ENTITIES_HOST_OVERVIEW_TEST_ID}Link` as const;
|
||||
export const ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID =
|
||||
`${ENTITIES_HOST_OVERVIEW_TEST_ID}OsFamily` as const;
|
||||
export const ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID =
|
||||
`${ENTITIES_HOST_OVERVIEW_TEST_ID}LastSeen` as const;
|
||||
export const ENTITIES_HOST_OVERVIEW_RISK_LEVEL_TEST_ID =
|
||||
`${ENTITIES_HOST_OVERVIEW_TEST_ID}RiskLevel` as const;
|
||||
export const TECHNICAL_PREVIEW_ICON_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutTechnicalPreviewIcon';
|
||||
`${INSIGHTS_ENTITIES_TEST_ID}TechnicalPreviewIcon` as const;
|
||||
|
||||
/* Insights Threat intelligence */
|
||||
/* Threat intelligence */
|
||||
|
||||
export const INSIGHTS_THREAT_INTELLIGENCE_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInsightsThreatIntelligence';
|
||||
export const INSIGHTS_THREAT_INTELLIGENCE_CONTAINER_TEST_ID = `${INSIGHTS_THREAT_INTELLIGENCE_TEST_ID}Container`;
|
||||
export const INSIGHTS_THREAT_INTELLIGENCE_TEST_ID = `${PREFIX}InsightsThreatIntelligence` as const;
|
||||
|
||||
/* Insights Correlations */
|
||||
/* Correlations */
|
||||
|
||||
export const INSIGHTS_CORRELATIONS_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInsightsCorrelations';
|
||||
export const INSIGHTS_CORRELATIONS_NO_DATA_TEST_ID = `${INSIGHTS_CORRELATIONS_TEST_ID}NoData`;
|
||||
export const INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID = `${INSIGHTS_CORRELATIONS_TEST_ID}SuppressedAlerts`;
|
||||
export const INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID = `${INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID}TechnicalPreview`;
|
||||
export const INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID = `${INSIGHTS_CORRELATIONS_TEST_ID}RelatedCases`;
|
||||
export const INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID = `${INSIGHTS_CORRELATIONS_TEST_ID}RelatedAlertsBySession`;
|
||||
export const INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID = `${INSIGHTS_CORRELATIONS_TEST_ID}RelatedAlertsBySameSourceEvent`;
|
||||
export const INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID = `${INSIGHTS_CORRELATIONS_TEST_ID}RelatedAlertsByAncestry`;
|
||||
export const CORRELATIONS_TEST_ID = `${PREFIX}Correlations` as const;
|
||||
export const CORRELATIONS_NO_DATA_TEST_ID = `${CORRELATIONS_TEST_ID}NoData` as const;
|
||||
export const CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID =
|
||||
`${CORRELATIONS_TEST_ID}SuppressedAlerts` as const;
|
||||
export const CORRELATIONS_SUPPRESSED_ALERTS_TECHNICAL_PREVIEW_TEST_ID =
|
||||
`${CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID}TechnicalPreview` as const;
|
||||
export const CORRELATIONS_RELATED_CASES_TEST_ID = `${CORRELATIONS_TEST_ID}RelatedCases` as const;
|
||||
export const CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID =
|
||||
`${CORRELATIONS_TEST_ID}RelatedAlertsBySession` as const;
|
||||
export const CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID =
|
||||
`${CORRELATIONS_TEST_ID}RelatedAlertsBySameSourceEvent` as const;
|
||||
export const CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID =
|
||||
`${CORRELATIONS_TEST_ID}RelatedAlertsByAncestry` as const;
|
||||
|
||||
/* Insights Prevalence */
|
||||
|
||||
export const INSIGHTS_PREVALENCE_TEST_ID =
|
||||
'securitySolutionDocumentDetailsFlyoutInsightsPrevalence';
|
||||
export const INSIGHTS_PREVALENCE_NO_DATA_TEST_ID = `${INSIGHTS_PREVALENCE_TEST_ID}NoData`;
|
||||
export const PREVALENCE_TEST_ID = `${PREFIX}InsightsPrevalence` as const;
|
||||
export const PREVALENCE_NO_DATA_TEST_ID = `${PREVALENCE_TEST_ID}NoData` as const;
|
||||
|
||||
/* Visualizations section */
|
||||
|
||||
export const VISUALIZATIONS_SECTION_TEST_ID = 'securitySolutionDocumentDetailsVisualizationsTitle';
|
||||
const VISUALIZATIONS_TEST_ID = `${PREFIX}Visualizations` as const;
|
||||
export const VISUALIZATIONS_SECTION_TEST_ID = `${VISUALIZATIONS_TEST_ID}Title` as const;
|
||||
export const VISUALIZATIONS_SECTION_HEADER_TEST_ID =
|
||||
'securitySolutionDocumentDetailsVisualizationsTitleHeader';
|
||||
export const ANALYZER_PREVIEW_TEST_ID = 'securitySolutionDocumentDetailsAnalyzerPreview';
|
||||
export const ANALYZER_PREVIEW_NO_DATA_TEST_ID = `${ANALYZER_PREVIEW_TEST_ID}NoData`;
|
||||
export const SESSION_PREVIEW_TEST_ID = 'securitySolutionDocumentDetailsSessionPreview';
|
||||
export const SESSION_PREVIEW_UPSELL_TEST_ID = `${SESSION_PREVIEW_TEST_ID}UpSell`;
|
||||
export const SESSION_PREVIEW_NO_DATA_TEST_ID = `${SESSION_PREVIEW_TEST_ID}NoData`;
|
||||
`${VISUALIZATIONS_TEST_ID}TitleHeader` as const;
|
||||
export const ANALYZER_PREVIEW_TEST_ID = `${PREFIX}AnalyzerPreview` as const;
|
||||
export const ANALYZER_PREVIEW_NO_DATA_TEST_ID = `${ANALYZER_PREVIEW_TEST_ID}NoData` as const;
|
||||
export const SESSION_PREVIEW_TEST_ID = `${PREFIX}SessionPreview` as const;
|
||||
export const SESSION_PREVIEW_UPSELL_TEST_ID = `${SESSION_PREVIEW_TEST_ID}UpSell` as const;
|
||||
export const SESSION_PREVIEW_NO_DATA_TEST_ID = `${SESSION_PREVIEW_TEST_ID}NoData` as const;
|
||||
|
||||
/* Response section */
|
||||
|
||||
export const RESPONSE_SECTION_TEST_ID = 'securitySolutionDocumentDetailsFlyoutResponseSection';
|
||||
const RESPONSE_TEST_ID = `${PREFIX}Response` as const;
|
||||
export const RESPONSE_SECTION_TEST_ID = `${RESPONSE_TEST_ID}Section` as const;
|
||||
export const RESPONSE_SECTION_HEADER_TEST_ID = RESPONSE_SECTION_TEST_ID + HEADER_TEST_ID;
|
||||
export const RESPONSE_SECTION_CONTENT_TEST_ID = RESPONSE_SECTION_TEST_ID + CONTENT_TEST_ID;
|
||||
export const RESPONSE_BUTTON_TEST_ID = 'securitySolutionDocumentDetailsFlyoutResponseButton';
|
||||
export const RESPONSE_EMPTY_TEST_ID = `${RESPONSE_BASE_TEST_ID}Empty` as const;
|
||||
export const RESPONSE_BUTTON_TEST_ID = `${RESPONSE_TEST_ID}Button` as const;
|
||||
export const RESPONSE_EMPTY_TEST_ID = `${RESPONSE_TEST_ID}Empty` as const;
|
||||
|
|
|
@ -17,8 +17,8 @@ import {
|
|||
ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID,
|
||||
} from './test_ids';
|
||||
import { useObservedUserDetails } from '../../../explore/users/containers/users/observed_details';
|
||||
import { mockContextValue } from '../mocks/mock_right_panel_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { LeftPanelInsightsTab, LeftPanelKey } from '../../left';
|
||||
|
@ -66,19 +66,22 @@ jest.mock('../../../explore/containers/risk_score');
|
|||
const mockUseFirstLastSeen = useFirstLastSeen as jest.Mock;
|
||||
jest.mock('../../../common/containers/use_first_last_seen');
|
||||
|
||||
const renderUserEntityOverview = () =>
|
||||
render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<UserEntityOverview userName={userName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
describe('<UserEntityOverview />', () => {
|
||||
describe('license is valid', () => {
|
||||
it('should render user domain and user risk classification', () => {
|
||||
mockUseUserDetails.mockReturnValue([false, { userDetails: userData }]);
|
||||
mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true });
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<UserEntityOverview userName={userName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderUserEntityOverview();
|
||||
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID)).toHaveTextContent(domain);
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('Medium');
|
||||
|
@ -88,13 +91,8 @@ describe('<UserEntityOverview />', () => {
|
|||
mockUseUserDetails.mockReturnValue([false, { userDetails: null }]);
|
||||
mockUseRiskScore.mockReturnValue({ data: null, isAuthorized: true });
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<UserEntityOverview userName={userName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderUserEntityOverview();
|
||||
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID)).toHaveTextContent('—');
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_RISK_LEVEL_TEST_ID)).toHaveTextContent('—');
|
||||
});
|
||||
|
@ -106,13 +104,7 @@ describe('<UserEntityOverview />', () => {
|
|||
mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: false });
|
||||
mockUseFirstLastSeen.mockReturnValue([false, { lastSeen }]);
|
||||
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<UserEntityOverview userName={userName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId, queryByTestId } = renderUserEntityOverview();
|
||||
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID)).toHaveTextContent(domain);
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_LAST_SEEN_TEST_ID)).toHaveTextContent(lastSeenText);
|
||||
|
@ -124,13 +116,7 @@ describe('<UserEntityOverview />', () => {
|
|||
mockUseRiskScore.mockReturnValue({ data: null, isAuthorized: false });
|
||||
mockUseFirstLastSeen.mockReturnValue([false, { lastSeen: null }]);
|
||||
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RightPanelContext.Provider value={panelContextValue}>
|
||||
<UserEntityOverview userName={userName} />
|
||||
</RightPanelContext.Provider>
|
||||
</TestProviders>
|
||||
);
|
||||
const { getByTestId } = renderUserEntityOverview();
|
||||
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID)).toHaveTextContent('—');
|
||||
expect(getByTestId(ENTITIES_USER_OVERVIEW_LAST_SEEN_TEST_ID)).toHaveTextContent('—');
|
||||
|
|
|
@ -11,8 +11,8 @@ import { render } from '@testing-library/react';
|
|||
import { VISUALIZATIONS_SECTION_HEADER_TEST_ID } from './test_ids';
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { VisualizationsSection } from './visualizations_section';
|
||||
import { mockContextValue } from '../mocks/mock_right_panel_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockContextValue } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { RightPanelContext } from '../context';
|
||||
import { useAlertPrevalenceFromProcessTree } from '../../../common/containers/alerts/use_alert_prevalence_from_process_tree';
|
||||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
|
|
|
@ -10,7 +10,7 @@ import { render } from '@testing-library/react';
|
|||
import { ExpandableFlyoutContext } from '@kbn/expandable-flyout/src/context';
|
||||
import { TestProviders } from '../../common/mock';
|
||||
import { RightPanelContext } from './context';
|
||||
import { mockContextValue } from './mocks/mock_right_panel_context';
|
||||
import { mockContextValue } from './mocks/mock_context';
|
||||
import { PanelHeader } from './header';
|
||||
import {
|
||||
COLLAPSE_DETAILS_BUTTON_TEST_ID,
|
||||
|
|
|
@ -9,7 +9,7 @@ import type { RenderHookResult } from '@testing-library/react-hooks';
|
|||
import { renderHook } from '@testing-library/react-hooks';
|
||||
import type { UseAssistantParams, UseAssistantResult } from './use_assistant';
|
||||
import { useAssistant } from './use_assistant';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import { useAssistantOverlay } from '@kbn/elastic-assistant';
|
||||
import { useAssistantAvailability } from '../../../assistant/use_assistant_availability';
|
||||
|
||||
|
@ -78,10 +78,13 @@ describe('useAssistant', () => {
|
|||
|
||||
expect(await getPromptContext()).toEqual({
|
||||
'@timestamp': ['2023-01-01T01:01:01.000Z'],
|
||||
'event.category': ['registry'],
|
||||
'kibana.alert.ancestors.id': ['ancestors-id'],
|
||||
'kibana.alert.rule.description': ['rule-description'],
|
||||
'kibana.alert.rule.indices': ['rule-indices'],
|
||||
'kibana.alert.rule.name': ['rule-name'],
|
||||
'kibana.alert.rule.parameters.index': ['rule-parameters-index'],
|
||||
'kibana.alert.rule.type': ['query'],
|
||||
'kibana.alert.rule.uuid': ['rule-uuid'],
|
||||
'kibana.alert.workflow_status': ['open'],
|
||||
'process.entity_id': ['process-entity_id'],
|
||||
|
|
|
@ -5,176 +5,25 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import {
|
||||
ALERT_REASON,
|
||||
ALERT_RISK_SCORE,
|
||||
ALERT_SEVERITY,
|
||||
ALERT_SUPPRESSION_DOCS_COUNT,
|
||||
} from '@kbn/rule-data-utils';
|
||||
import { mockBrowserFields } from '../../shared/mocks/mock_browser_fields';
|
||||
import { mockSearchHit } from '../../shared/mocks/mock_search_hit';
|
||||
import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data';
|
||||
import { mockDataAsNestedObject } from '../../shared/mocks/mock_data_as_nested_object';
|
||||
import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser';
|
||||
import type { RightPanelContext } from '../context';
|
||||
|
||||
/**
|
||||
* Returns mocked data for field (mock this method: x-pack/plugins/security_solution/public/common/hooks/use_get_fields_data.ts)
|
||||
* @param field
|
||||
* @returns string[]
|
||||
* Mock contextValue for right panel context
|
||||
*/
|
||||
export const mockGetFieldsData = (field: string): string[] => {
|
||||
switch (field) {
|
||||
case ALERT_SEVERITY:
|
||||
return ['low'];
|
||||
case ALERT_RISK_SCORE:
|
||||
return ['0'];
|
||||
case 'host.name':
|
||||
return ['host1'];
|
||||
case 'user.name':
|
||||
return ['user1'];
|
||||
case ALERT_REASON:
|
||||
return ['reason'];
|
||||
case ALERT_SUPPRESSION_DOCS_COUNT:
|
||||
return ['1'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Mock an array of fields for an alert
|
||||
*/
|
||||
export const mockDataFormattedForFieldBrowser = [
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.uuid',
|
||||
values: ['rule-uuid'],
|
||||
originalValue: ['rule-uuid'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.name',
|
||||
values: ['rule-name'],
|
||||
originalValue: ['rule-name'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'base',
|
||||
field: '@timestamp',
|
||||
values: ['2023-01-01T01:01:01.000Z'],
|
||||
originalValue: ['2023-01-01T01:01:01.000Z'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.description',
|
||||
values: ['rule-description'],
|
||||
originalValue: ['rule-description'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.ancestors.id',
|
||||
values: ['ancestors-id'],
|
||||
originalValue: ['ancestors-id'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.parameters.index',
|
||||
values: ['rule-parameters-index'],
|
||||
originalValue: ['rule-parameters-index'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'process',
|
||||
field: 'process.entity_id',
|
||||
values: ['process-entity_id'],
|
||||
originalValue: ['process-entity_id'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.workflow_status',
|
||||
values: ['open'],
|
||||
originalValue: ['open'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Mock an object of nested properties for an alert
|
||||
*/
|
||||
export const mockDataAsNestedObject = {
|
||||
_id: '123',
|
||||
'@timestamp': ['2023-01-01T01:01:01.000Z'],
|
||||
event: {
|
||||
category: ['malware'],
|
||||
kind: ['signal'],
|
||||
},
|
||||
host: {
|
||||
name: ['host-name'],
|
||||
},
|
||||
kibana: {
|
||||
alert: {
|
||||
rule: {
|
||||
name: ['rule-name'],
|
||||
},
|
||||
severity: ['low'],
|
||||
},
|
||||
},
|
||||
process: {
|
||||
name: ['process-name'],
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Mock the document result of the search for an alert
|
||||
*/
|
||||
export const mockSearchHit = {
|
||||
fields: {
|
||||
'kibana.alert.rule.parameters': [
|
||||
{
|
||||
threat: [
|
||||
{
|
||||
framework: 'MITRE ATT&CK',
|
||||
tactic: {
|
||||
id: '123',
|
||||
reference: 'https://attack.mitre.org/tactics/123',
|
||||
name: 'Tactic',
|
||||
},
|
||||
technique: [
|
||||
{
|
||||
id: '456',
|
||||
reference: 'https://attack.mitre.org/techniques/456',
|
||||
name: 'Technique',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Mock the browserFields object
|
||||
*/
|
||||
export const mockBrowserFields = {
|
||||
kibana: {
|
||||
fields: {
|
||||
'kibana.alert.workflow_status': {
|
||||
aggregatable: true,
|
||||
count: 0,
|
||||
esTypes: [0],
|
||||
format: {
|
||||
id: 'string',
|
||||
params: undefined,
|
||||
},
|
||||
isMapped: true,
|
||||
name: 'kibana.alert.workflow_status',
|
||||
readFromDocValues: true,
|
||||
scripted: false,
|
||||
searchable: true,
|
||||
shortDotsEnable: false,
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
export const mockContextValue: RightPanelContext = {
|
||||
eventId: 'eventId',
|
||||
indexName: 'index',
|
||||
scopeId: 'scopeId',
|
||||
getFieldsData: mockGetFieldsData,
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
browserFields: mockBrowserFields,
|
||||
dataAsNestedObject: mockDataAsNestedObject,
|
||||
searchHit: mockSearchHit,
|
||||
investigationFields: [],
|
||||
refetchFlyoutData: jest.fn(),
|
||||
};
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* 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 type { IUiSettingsClient } from '@kbn/core/public';
|
||||
|
||||
const DEFAULT_DATE_FORMAT = 'dateFormat' as const;
|
||||
const DEFAULT_DATE_FORMAT_TZ = 'dateFormat:tz' as const;
|
||||
|
||||
/**
|
||||
* Creates an object to pass to the uiSettings property when creating a KibanaReactContext (see src/plugins/kibana_react/public/context/context.tsx).
|
||||
* @param dateFormat defaults to ''
|
||||
* @param timezone defaults to 'UTC
|
||||
* @returns the object {@link IUiSettingsClient}
|
||||
*/
|
||||
export const mockUiSettingsService = (dateFormat: string = '', timezone: string = 'UTC') =>
|
||||
({
|
||||
get: (key: string) => {
|
||||
const settings = {
|
||||
[DEFAULT_DATE_FORMAT]: dateFormat,
|
||||
[DEFAULT_DATE_FORMAT_TZ]: timezone,
|
||||
};
|
||||
// @ts-expect-error
|
||||
return settings[key];
|
||||
},
|
||||
} as unknown as IUiSettingsClient);
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* 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 type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs';
|
||||
import type { SearchHit } from '../../../../common/search_strategy';
|
||||
import type { RightPanelContext } from '../context';
|
||||
import {
|
||||
mockDataAsNestedObject,
|
||||
mockDataFormattedForFieldBrowser,
|
||||
mockGetFieldsData,
|
||||
mockSearchHit,
|
||||
} from './mock_context';
|
||||
|
||||
/**
|
||||
* Mock contextValue for right panel context
|
||||
*/
|
||||
export const mockContextValue: RightPanelContext = {
|
||||
eventId: 'eventId',
|
||||
indexName: 'index',
|
||||
scopeId: 'scopeId',
|
||||
getFieldsData: mockGetFieldsData,
|
||||
dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser,
|
||||
browserFields: {},
|
||||
dataAsNestedObject: mockDataAsNestedObject as unknown as Ecs,
|
||||
searchHit: mockSearchHit as unknown as SearchHit,
|
||||
investigationFields: [],
|
||||
refetchFlyoutData: jest.fn(),
|
||||
};
|
|
@ -5,7 +5,5 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const TABLE_TAB_CONTENT_TEST_ID = 'event-fields-browser';
|
||||
export const TABLE_TAB_ERROR_TEST_ID = 'securitySolutionAlertDetailsFlyoutTableTabError';
|
||||
export const JSON_TAB_CONTENT_TEST_ID = 'jsonView';
|
||||
export const JSON_TAB_ERROR_TEST_ID = 'securitySolutionDocumentDetailsFlyoutJsonTabError';
|
||||
export const TABLE_TAB_CONTENT_TEST_ID = 'event-fields-browser' as const;
|
||||
export const JSON_TAB_CONTENT_TEST_ID = 'jsonView' as const;
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const FLYOUT_BODY_TEST_ID = 'securitySolutionDocumentDetailsFlyoutBody';
|
||||
export const OVERVIEW_TAB_TEST_ID = 'securitySolutionDocumentDetailsFlyoutOverviewTab';
|
||||
export const TABLE_TAB_TEST_ID = 'securitySolutionDocumentDetailsFlyoutTableTab';
|
||||
export const JSON_TAB_TEST_ID = 'securitySolutionDocumentDetailsFlyoutJsonTab';
|
||||
import { PREFIX } from '../shared/test_ids';
|
||||
|
||||
export const FLYOUT_BODY_TEST_ID = `${PREFIX}Body` as const;
|
||||
export const OVERVIEW_TAB_TEST_ID = `${PREFIX}OverviewTab` as const;
|
||||
export const TABLE_TAB_TEST_ID = `${PREFIX}TableTab` as const;
|
||||
export const JSON_TAB_TEST_ID = `${PREFIX}JsonTab` as const;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { renderHook } from '@testing-library/react-hooks';
|
||||
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_data_formatted_for_field_browser';
|
||||
import { useHighlightedFields } from './use_highlighted_fields';
|
||||
|
||||
const dataFormattedForFieldBrowser = mockDataFormattedForFieldBrowser;
|
||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
|||
} from './use_investigation_guide';
|
||||
import { useBasicDataFromDetailsData } from '../../../timelines/components/side_panel/event_details/helpers';
|
||||
import { useRuleWithFallback } from '../../../detection_engine/rule_management/logic/use_rule_with_fallback';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_data_formatted_for_field_browser';
|
||||
import { useInvestigationGuide } from './use_investigation_guide';
|
||||
|
||||
jest.mock('../../../timelines/components/side_panel/event_details/helpers');
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { renderHook } from '@testing-library/react-hooks';
|
||||
|
||||
import { usePrevalence } from './use_prevalence';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_data_formatted_for_field_browser';
|
||||
import { useHighlightedFields } from './use_highlighted_fields';
|
||||
import {
|
||||
FIELD_NAMES_AGG_KEY,
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import type { RenderHookResult } from '@testing-library/react-hooks';
|
||||
import { renderHook } from '@testing-library/react-hooks';
|
||||
import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs';
|
||||
import type {
|
||||
UseShowRelatedAlertsByAncestryParams,
|
||||
UseShowRelatedAlertsByAncestryResult,
|
||||
|
@ -15,7 +14,8 @@ import type {
|
|||
import { useShowRelatedAlertsByAncestry } from './use_show_related_alerts_by_ancestry';
|
||||
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features';
|
||||
import { licenseService } from '../../../common/hooks/use_license';
|
||||
import { mockDataAsNestedObject, mockDataFormattedForFieldBrowser } from '../mocks/mock_context';
|
||||
import { mockDataFormattedForFieldBrowser } from '../mocks/mock_data_formatted_for_field_browser';
|
||||
import { mockDataAsNestedObject } from '../mocks/mock_data_as_nested_object';
|
||||
|
||||
jest.mock('../../../common/hooks/use_experimental_features');
|
||||
jest.mock('../../../common/hooks/use_license', () => {
|
||||
|
@ -31,7 +31,7 @@ jest.mock('../../../common/hooks/use_license', () => {
|
|||
});
|
||||
const licenseServiceMock = licenseService as jest.Mocked<typeof licenseService>;
|
||||
|
||||
const dataAsNestedObject = mockDataAsNestedObject as unknown as Ecs;
|
||||
const dataAsNestedObject = mockDataAsNestedObject;
|
||||
const dataFormattedForFieldBrowser = mockDataFormattedForFieldBrowser;
|
||||
|
||||
describe('useShowRelatedAlertsByAncestry', () => {
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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 type { BrowserFields } from '@kbn/timelines-plugin/common';
|
||||
|
||||
/**
|
||||
* Mock the browserFields object
|
||||
*/
|
||||
export const mockBrowserFields: BrowserFields = {
|
||||
kibana: {
|
||||
fields: {
|
||||
'kibana.alert.workflow_status': {
|
||||
aggregatable: true,
|
||||
esTypes: ['0'],
|
||||
format: '',
|
||||
name: 'kibana.alert.workflow_status',
|
||||
readFromDocValues: true,
|
||||
searchable: true,
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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 type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs';
|
||||
|
||||
/**
|
||||
* Mock an object of nested properties for an alert
|
||||
*/
|
||||
export const mockDataAsNestedObject: Ecs = {
|
||||
_id: 'testId',
|
||||
timestamp: '2023-01-01T01:01:01.000Z',
|
||||
agent: {
|
||||
type: ['endpoint'],
|
||||
},
|
||||
event: {
|
||||
category: ['malware'],
|
||||
kind: ['signal'],
|
||||
},
|
||||
host: {
|
||||
name: ['host-name'],
|
||||
},
|
||||
kibana: {
|
||||
alert: {
|
||||
rule: {
|
||||
name: ['rule-name'],
|
||||
parameters: {},
|
||||
uuid: [],
|
||||
},
|
||||
severity: ['low'],
|
||||
},
|
||||
},
|
||||
process: {
|
||||
name: ['process-name'],
|
||||
entity_id: ['process-entity_id'],
|
||||
},
|
||||
};
|
|
@ -5,54 +5,12 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Mock an object of nested properties for an alert
|
||||
*/
|
||||
export const mockDataAsNestedObject = {
|
||||
_id: '123',
|
||||
'@timestamp': ['2023-01-01T01:01:01.000Z'],
|
||||
agent: {
|
||||
type: ['endpoint'],
|
||||
},
|
||||
event: {
|
||||
category: ['malware'],
|
||||
kind: ['signal'],
|
||||
},
|
||||
host: {
|
||||
name: ['host-name'],
|
||||
},
|
||||
kibana: {
|
||||
alert: {
|
||||
rule: {
|
||||
name: ['rule-name'],
|
||||
},
|
||||
severity: ['low'],
|
||||
},
|
||||
},
|
||||
process: {
|
||||
name: ['process-name'],
|
||||
entity_id: ['process-entity_id'],
|
||||
},
|
||||
};
|
||||
import type { TimelineEventsDetailsItem } from '@kbn/timelines-plugin/common';
|
||||
|
||||
/**
|
||||
* Mock an array of fields for an alert
|
||||
*/
|
||||
export const mockDataFormattedForFieldBrowser = [
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.uuid',
|
||||
values: ['rule-uuid'],
|
||||
originalValue: ['rule-uuid'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.name',
|
||||
values: ['rule-name'],
|
||||
originalValue: ['rule-name'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
export const mockDataFormattedForFieldBrowser: TimelineEventsDetailsItem[] = [
|
||||
{
|
||||
category: 'base',
|
||||
field: '@timestamp',
|
||||
|
@ -60,41 +18,6 @@ export const mockDataFormattedForFieldBrowser = [
|
|||
originalValue: ['2023-01-01T01:01:01.000Z'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.description',
|
||||
values: ['rule-description'],
|
||||
originalValue: ['rule-description'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.ancestors.id',
|
||||
values: ['ancestors-id'],
|
||||
originalValue: ['ancestors-id'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.parameters.index',
|
||||
values: ['rule-parameters-index'],
|
||||
originalValue: ['rule-parameters-index'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.indices',
|
||||
values: ['rule-indices'],
|
||||
originalValue: ['rule-indices'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'process',
|
||||
field: 'process.entity_id',
|
||||
values: ['process-entity_id'],
|
||||
originalValue: ['process-entity_id'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'event',
|
||||
field: 'event.category',
|
||||
|
@ -102,6 +25,41 @@ export const mockDataFormattedForFieldBrowser = [
|
|||
originalValue: ['registry'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.ancestors.id',
|
||||
values: ['ancestors-id'],
|
||||
originalValue: ['ancestors-id'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.description',
|
||||
values: ['rule-description'],
|
||||
originalValue: ['rule-description'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.indices',
|
||||
values: ['rule-indices'],
|
||||
originalValue: ['rule-indices'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.name',
|
||||
values: ['rule-name'],
|
||||
originalValue: ['rule-name'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.parameters.index',
|
||||
values: ['rule-parameters-index'],
|
||||
originalValue: ['rule-parameters-index'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.type',
|
||||
|
@ -109,4 +67,25 @@ export const mockDataFormattedForFieldBrowser = [
|
|||
originalValue: ['query'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.rule.uuid',
|
||||
values: ['rule-uuid'],
|
||||
originalValue: ['rule-uuid'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'kibana',
|
||||
field: 'kibana.alert.workflow_status',
|
||||
values: ['open'],
|
||||
originalValue: ['open'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
{
|
||||
category: 'process',
|
||||
field: 'process.entity_id',
|
||||
values: ['process-entity_id'],
|
||||
originalValue: ['process-entity_id'],
|
||||
isObjectArray: false,
|
||||
},
|
||||
];
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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 {
|
||||
ALERT_REASON,
|
||||
ALERT_RISK_SCORE,
|
||||
ALERT_SEVERITY,
|
||||
ALERT_SUPPRESSION_DOCS_COUNT,
|
||||
} from '@kbn/rule-data-utils';
|
||||
|
||||
const mockFieldData: Record<string, string[]> = {
|
||||
[ALERT_SEVERITY]: ['low'],
|
||||
[ALERT_RISK_SCORE]: ['0'],
|
||||
'host.name': ['host1'],
|
||||
'user.name': ['user1'],
|
||||
[ALERT_REASON]: ['reason'],
|
||||
[ALERT_SUPPRESSION_DOCS_COUNT]: ['1'],
|
||||
'@timestamp': ['2023-01-01T00:00:00.000Z'],
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns mocked data for field (mock this method: x-pack/plugins/security_solution/public/common/hooks/use_get_fields_data.ts)
|
||||
* @param field
|
||||
* @returns string[]
|
||||
*/
|
||||
export const mockGetFieldsData = (field: string): string[] => mockFieldData[field] ?? [];
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 type { SearchHit } from '../../../../common/search_strategy';
|
||||
|
||||
/**
|
||||
* Mock the document result of the search for an alert
|
||||
*/
|
||||
export const mockSearchHit: SearchHit = {
|
||||
_index: 'index',
|
||||
_id: 'id',
|
||||
fields: {
|
||||
'kibana.alert.rule.parameters': [
|
||||
{
|
||||
threat: [
|
||||
{
|
||||
framework: 'MITRE ATT&CK',
|
||||
tactic: {
|
||||
id: '123',
|
||||
reference: 'https://attack.mitre.org/tactics/123',
|
||||
name: 'Tactic',
|
||||
},
|
||||
technique: [
|
||||
{
|
||||
id: '456',
|
||||
reference: 'https://attack.mitre.org/techniques/456',
|
||||
name: 'Technique',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
|
@ -5,9 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
/* Visualization tab */
|
||||
|
||||
const PREFIX = 'securitySolutionDocumentDetailsFlyout' as const;
|
||||
export const PREFIX = 'securitySolutionFlyout' as const;
|
||||
|
||||
export const FLYOUT_ERROR_TEST_ID = `${PREFIX}Error` as const;
|
||||
export const FLYOUT_LOADING_TEST_ID = `${PREFIX}Loading` as const;
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
import { RESPONSE_TAB_TEST_ID } from '@kbn/security-solution-plugin/public/flyout/left/test_ids';
|
||||
import { RESPONSE_EMPTY_TEST_ID } from '@kbn/security-solution-plugin/public/flyout/left/components/test_ids';
|
||||
import { RESPONSE_NO_DATA_TEST_ID } from '@kbn/security-solution-plugin/public/flyout/left/components/test_ids';
|
||||
import { getDataTestSubjectSelector } from '../../helpers/common';
|
||||
|
||||
export const DOCUMENT_DETAILS_FLYOUT_RESPONSE_TAB =
|
||||
getDataTestSubjectSelector(RESPONSE_TAB_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_RESPONSE_EMPTY =
|
||||
getDataTestSubjectSelector(RESPONSE_EMPTY_TEST_ID);
|
||||
getDataTestSubjectSelector(RESPONSE_NO_DATA_TEST_ID);
|
||||
|
|
|
@ -14,12 +14,12 @@ import {
|
|||
import {
|
||||
COLLAPSE_DETAILS_BUTTON_TEST_ID,
|
||||
EXPAND_DETAILS_BUTTON_TEST_ID,
|
||||
FLYOUT_HEADER_CHAT_BUTTON_TEST_ID,
|
||||
FLYOUT_HEADER_RISK_SCORE_TITLE_TEST_ID,
|
||||
FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID,
|
||||
FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID,
|
||||
FLYOUT_HEADER_SEVERITY_VALUE_TEST_ID,
|
||||
FLYOUT_HEADER_STATUS_BUTTON_TEST_ID,
|
||||
CHAT_BUTTON_TEST_ID,
|
||||
RISK_SCORE_TITLE_TEST_ID,
|
||||
RISK_SCORE_VALUE_TEST_ID,
|
||||
SEVERITY_TITLE_TEST_ID,
|
||||
SEVERITY_VALUE_TEST_ID,
|
||||
STATUS_BUTTON_TEST_ID,
|
||||
FLYOUT_HEADER_TITLE_TEST_ID,
|
||||
} from '@kbn/security-solution-plugin/public/flyout/right/components/test_ids';
|
||||
import { getDataTestSubjectSelector } from '../../helpers/common';
|
||||
|
@ -43,24 +43,18 @@ export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB =
|
|||
getDataTestSubjectSelector(OVERVIEW_TAB_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_TABLE_TAB = getDataTestSubjectSelector(TABLE_TAB_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_JSON_TAB = getDataTestSubjectSelector(JSON_TAB_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_STATUS = getDataTestSubjectSelector(
|
||||
FLYOUT_HEADER_STATUS_BUTTON_TEST_ID
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_RISK_SCORE = getDataTestSubjectSelector(
|
||||
FLYOUT_HEADER_RISK_SCORE_TITLE_TEST_ID
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_RISK_SCORE_VALUE = getDataTestSubjectSelector(
|
||||
FLYOUT_HEADER_RISK_SCORE_VALUE_TEST_ID
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_SEVERITY = getDataTestSubjectSelector(
|
||||
FLYOUT_HEADER_SEVERITY_TITLE_TEST_ID
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_SEVERITY_VALUE = getDataTestSubjectSelector(
|
||||
FLYOUT_HEADER_SEVERITY_VALUE_TEST_ID
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_CHAT_BUTTON = getDataTestSubjectSelector(
|
||||
FLYOUT_HEADER_CHAT_BUTTON_TEST_ID
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_STATUS =
|
||||
getDataTestSubjectSelector(STATUS_BUTTON_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_RISK_SCORE =
|
||||
getDataTestSubjectSelector(RISK_SCORE_TITLE_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_RISK_SCORE_VALUE =
|
||||
getDataTestSubjectSelector(RISK_SCORE_VALUE_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_SEVERITY =
|
||||
getDataTestSubjectSelector(SEVERITY_TITLE_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_SEVERITY_VALUE =
|
||||
getDataTestSubjectSelector(SEVERITY_VALUE_TEST_ID);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_HEADER_CHAT_BUTTON =
|
||||
getDataTestSubjectSelector(CHAT_BUTTON_TEST_ID);
|
||||
|
||||
/* Footer */
|
||||
|
||||
|
|
|
@ -30,14 +30,14 @@ import {
|
|||
RESPONSE_SECTION_HEADER_TEST_ID,
|
||||
RESPONSE_EMPTY_TEST_ID,
|
||||
INSIGHTS_THREAT_INTELLIGENCE_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_TEST_ID,
|
||||
INSIGHTS_PREVALENCE_TEST_ID,
|
||||
CORRELATIONS_TEST_ID,
|
||||
PREVALENCE_TEST_ID,
|
||||
SUMMARY_ROW_VALUE_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID,
|
||||
INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID,
|
||||
CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID,
|
||||
CORRELATIONS_RELATED_CASES_TEST_ID,
|
||||
CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID,
|
||||
INSIGHTS_ENTITIES_TEST_ID,
|
||||
REASON_DETAILS_PREVIEW_BUTTON_TEST_ID,
|
||||
ANALYZER_PREVIEW_TEST_ID,
|
||||
|
@ -118,42 +118,34 @@ export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_THREAT_INTELLIGENCE_V
|
|||
/* Insights Correlations */
|
||||
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_CORRELATIONS_HEADER =
|
||||
getDataTestSubjectSelector(
|
||||
EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(INSIGHTS_CORRELATIONS_TEST_ID)
|
||||
);
|
||||
getDataTestSubjectSelector(EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(CORRELATIONS_TEST_ID));
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_CORRELATIONS_CONTENT =
|
||||
getDataTestSubjectSelector(EXPANDABLE_PANEL_CONTENT_TEST_ID(INSIGHTS_CORRELATIONS_TEST_ID));
|
||||
getDataTestSubjectSelector(EXPANDABLE_PANEL_CONTENT_TEST_ID(CORRELATIONS_TEST_ID));
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_CORRELATIONS_VALUES_SUPPRESSED_ALERTS =
|
||||
getDataTestSubjectSelector(
|
||||
SUMMARY_ROW_VALUE_TEST_ID(INSIGHTS_CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID)
|
||||
);
|
||||
getDataTestSubjectSelector(SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_SUPPRESSED_ALERTS_TEST_ID));
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_CORRELATIONS_VALUES_RELATED_ALERTS_BY_ANCESTRY =
|
||||
getDataTestSubjectSelector(
|
||||
SUMMARY_ROW_VALUE_TEST_ID(INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID)
|
||||
SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID)
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_CORRELATIONS_VALUES_RELATED_ALERTS_BY_SAME_SOURCE_EVENT =
|
||||
getDataTestSubjectSelector(
|
||||
SUMMARY_ROW_VALUE_TEST_ID(INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID)
|
||||
SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID)
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_CORRELATIONS_VALUES_RELATED_ALERTS_BY_SESSION =
|
||||
getDataTestSubjectSelector(
|
||||
SUMMARY_ROW_VALUE_TEST_ID(INSIGHTS_CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID)
|
||||
SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_RELATED_ALERTS_BY_SESSION_TEST_ID)
|
||||
);
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_CORRELATIONS_VALUES_RELATED_CASES =
|
||||
getDataTestSubjectSelector(
|
||||
SUMMARY_ROW_VALUE_TEST_ID(INSIGHTS_CORRELATIONS_RELATED_CASES_TEST_ID)
|
||||
);
|
||||
getDataTestSubjectSelector(SUMMARY_ROW_VALUE_TEST_ID(CORRELATIONS_RELATED_CASES_TEST_ID));
|
||||
|
||||
/* Insights Prevalence */
|
||||
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_PREVALENCE_HEADER =
|
||||
getDataTestSubjectSelector(
|
||||
EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(INSIGHTS_PREVALENCE_TEST_ID)
|
||||
);
|
||||
getDataTestSubjectSelector(EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(PREVALENCE_TEST_ID));
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_PREVALENCE_CONTENT =
|
||||
getDataTestSubjectSelector(EXPANDABLE_PANEL_CONTENT_TEST_ID(INSIGHTS_PREVALENCE_TEST_ID));
|
||||
getDataTestSubjectSelector(EXPANDABLE_PANEL_CONTENT_TEST_ID(PREVALENCE_TEST_ID));
|
||||
export const DOCUMENT_DETAILS_FLYOUT_OVERVIEW_TAB_INSIGHTS_PREVALENCE_VALUES =
|
||||
getDataTestSubjectSelector(INSIGHTS_PREVALENCE_TEST_ID);
|
||||
getDataTestSubjectSelector(PREVALENCE_TEST_ID);
|
||||
|
||||
/* Visualization section */
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
import { EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID } from '@kbn/security-solution-plugin/public/flyout/shared/components/test_ids';
|
||||
import {
|
||||
INSIGHTS_CORRELATIONS_TEST_ID,
|
||||
CORRELATIONS_TEST_ID,
|
||||
INSIGHTS_ENTITIES_TEST_ID,
|
||||
INSIGHTS_PREVALENCE_TEST_ID,
|
||||
PREVALENCE_TEST_ID,
|
||||
INSIGHTS_THREAT_INTELLIGENCE_TEST_ID,
|
||||
} from '@kbn/security-solution-plugin/public/flyout/right/components/test_ids';
|
||||
import {
|
||||
|
@ -79,7 +79,7 @@ export const navigateToThreatIntelligenceDetails = () => {
|
|||
* Click on the header in the right section, Insights, Correlations
|
||||
*/
|
||||
export const navigateToCorrelationsDetails = () => {
|
||||
const TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(INSIGHTS_CORRELATIONS_TEST_ID);
|
||||
const TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(CORRELATIONS_TEST_ID);
|
||||
cy.get(TEST_ID).scrollIntoView();
|
||||
cy.get(TEST_ID).should('be.visible').click();
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ export const navigateToCorrelationsDetails = () => {
|
|||
* Click on the view all button under the right section, Insights, Prevalence
|
||||
*/
|
||||
export const navigateToPrevalenceDetails = () => {
|
||||
const TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(INSIGHTS_PREVALENCE_TEST_ID);
|
||||
const TEST_ID = EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID(PREVALENCE_TEST_ID);
|
||||
cy.get(TEST_ID).scrollIntoView();
|
||||
cy.get(TEST_ID).should('be.visible').click();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue