mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
## Summary The router refactor accidentally introduced a bug where anomalies is no longer filtering out entities within the host details and adds a unit test for it. Before: <img width="2002" alt="before_anomalies_mixing" src="https://user-images.githubusercontent.com/1151048/64457061-e4060f00-d0ae-11e9-9a2a-29a8bf9be3c4.png"> After: <img width="2005" alt="after_no_mixing" src="https://user-images.githubusercontent.com/1151048/64457062-e6686900-d0ae-11e9-81b9-88d19dffb3d2.png"> * https://github.com/elastic/kibana/issues/45038 ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. - [x] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md) - [x] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios - [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist) ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process) - [x] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)
This commit is contained in:
parent
49c13020ca
commit
d1b74dbd1e
3 changed files with 77 additions and 0 deletions
15
x-pack/legacy/plugins/siem/public/pages/hosts/details/__snapshots__/body.test.tsx.snap
generated
Normal file
15
x-pack/legacy/plugins/siem/public/pages/hosts/details/__snapshots__/body.test.tsx.snap
generated
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`body render snapshot 1`] = `
|
||||
<Component>
|
||||
<Connect(HostDetailsBodyComponent)
|
||||
detailName="host-1"
|
||||
from={0}
|
||||
isInitializing={false}
|
||||
setQuery={[Function]}
|
||||
to={0}
|
||||
>
|
||||
<Component />
|
||||
</Connect(HostDetailsBodyComponent)>
|
||||
</Component>
|
||||
`;
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { shallow, mount } from 'enzyme';
|
||||
import { HostDetailsBody } from './body';
|
||||
import React from 'react';
|
||||
|
||||
import '../../../mock/ui_settings';
|
||||
import { CommonChildren } from '../hosts';
|
||||
import toJson from 'enzyme-to-json';
|
||||
import { TestProviders } from '../../../mock/test_providers';
|
||||
|
||||
describe('body', () => {
|
||||
test('render snapshot', () => {
|
||||
const child: CommonChildren = () => <span>{'I am a child'}</span>;
|
||||
const wrapper = shallow(
|
||||
<TestProviders>
|
||||
<HostDetailsBody
|
||||
children={child}
|
||||
from={0}
|
||||
isInitializing={false}
|
||||
detailName={'host-1'}
|
||||
setQuery={() => {}}
|
||||
to={0}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
expect(toJson(wrapper)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('it should pass expected object properties to children', () => {
|
||||
const child = jest.fn();
|
||||
mount(
|
||||
<TestProviders>
|
||||
<HostDetailsBody
|
||||
children={child}
|
||||
from={0}
|
||||
isInitializing={false}
|
||||
detailName={'host-1'}
|
||||
setQuery={() => {}}
|
||||
to={0}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
// match against everything but the functions to ensure they are there as expected
|
||||
expect(child.mock.calls[0][0]).toMatchObject({
|
||||
endDate: 0,
|
||||
filterQuery: { term: { 'host.name': 'host-1' } },
|
||||
hostName: 'host-1',
|
||||
indexPattern: { fields: [], title: 'auditbeat-*,filebeat-*,packetbeat-*,winlogbeat-*' },
|
||||
kqlQueryExpression: 'host.name: "host-1"',
|
||||
skip: false,
|
||||
startDate: 0,
|
||||
type: 'details',
|
||||
});
|
||||
});
|
||||
});
|
|
@ -44,6 +44,7 @@ const HostDetailsBodyComponent = React.memo<HostDetailsBodyComponentProps>(
|
|||
startDate: from,
|
||||
type,
|
||||
indexPattern,
|
||||
hostName: detailName,
|
||||
narrowDateRange: (score: Anomaly, interval: string) => {
|
||||
const fromTo = scoreIntervalToDateTime(score, interval);
|
||||
setAbsoluteRangeDatePicker({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue