Skip to content

Commit

Permalink
Merge branch '7.x' into backport/7.x/pr-63558
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Apr 15, 2020
2 parents 7f577d5 + 720d07d commit 10c6b46
Show file tree
Hide file tree
Showing 115 changed files with 2,221 additions and 416 deletions.
27 changes: 27 additions & 0 deletions x-pack/legacy/plugins/siem/public/mock/test_providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ThemeProvider } from 'styled-components';
import { createStore, State } from '../store';
import { mockGlobalState } from './global_state';
import { createKibanaContextProviderMock } from './kibana_react';
import { FieldHook, useForm } from '../shared_imports';

jest.mock('ui/new_platform');

Expand Down Expand Up @@ -91,3 +92,29 @@ const TestProviderWithoutDragAndDropComponent: React.FC<Props> = ({
);

export const TestProviderWithoutDragAndDrop = React.memo(TestProviderWithoutDragAndDropComponent);

export const useFormFieldMock = (options?: Partial<FieldHook>): FieldHook => {
const { form } = useForm();

return {
path: 'path',
type: 'type',
value: [],
isPristine: false,
isValidating: false,
isValidated: false,
isChangingValue: false,
form,
errors: [],
isValid: true,
getErrorsMessages: jest.fn(),
onChange: jest.fn(),
setValue: jest.fn(),
setErrors: jest.fn(),
clearErrors: jest.fn(),
validate: jest.fn(),
reset: jest.fn(),
__serializeOutput: jest.fn(),
...options,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { ActivityMonitor } from './index';

describe('activity_monitor', () => {
it('renders correctly', () => {
const wrapper = shallow(<ActivityMonitor />);

expect(wrapper.find('[title="Activity monitor"]')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { DetectionEngineHeaderPage } from './index';

describe('detection_engine_header_page', () => {
it('renders correctly', () => {
const wrapper = shallow(<DetectionEngineHeaderPage title="Title" />);

expect(wrapper.find('[title="Title"]')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { NoApiIntegrationKeyCallOut } from './index';

describe('no_api_integration_callout', () => {
it('renders correctly', () => {
const wrapper = shallow(<NoApiIntegrationKeyCallOut />);

expect(wrapper.find('EuiCallOut')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { NoWriteSignalsCallOut } from './index';

describe('no_write_signals_callout', () => {
it('renders correctly', () => {
const wrapper = shallow(<NoWriteSignalsCallOut />);

expect(wrapper.find('EuiCallOut')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { SignalsTableComponent } from './index';

describe('SignalsTableComponent', () => {
it('renders correctly', () => {
const wrapper = shallow(
<SignalsTableComponent
canUserCRUD
hasIndexWrite
from={0}
loading
signalsIndex="index"
to={1}
globalQuery={{
query: 'query',
language: 'language',
}}
globalFilters={[]}
deletedEventIds={[]}
loadingEventIds={[]}
selectedEventIds={{}}
isSelectAllChecked={false}
clearSelected={jest.fn()}
setEventsLoading={jest.fn()}
clearEventsLoading={jest.fn()}
setEventsDeleted={jest.fn()}
clearEventsDeleted={jest.fn()}
updateTimelineIsLoading={jest.fn()}
updateTimeline={jest.fn()}
/>
);

expect(wrapper.find('[title="Signals"]')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface OwnProps {

type SignalsTableComponentProps = OwnProps & PropsFromRedux;

const SignalsTableComponent: React.FC<SignalsTableComponentProps> = ({
export const SignalsTableComponent: React.FC<SignalsTableComponentProps> = ({
canUserCRUD,
clearEventsDeleted,
clearEventsLoading,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { SignalsTableFilterGroup } from './index';

describe('SignalsTableFilterGroup', () => {
it('renders correctly', () => {
const wrapper = shallow(<SignalsTableFilterGroup onFilterGroupChanged={jest.fn()} />);

expect(wrapper.find('EuiFilterButton')).toBeTruthy();
});
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { SignalsUtilityBar } from './index';

jest.mock('../../../../../lib/kibana');

describe('SignalsUtilityBar', () => {
it('renders correctly', () => {
const wrapper = shallow(
<SignalsUtilityBar
canUserCRUD={true}
hasIndexWrite={true}
areEventsLoading={false}
clearSelection={jest.fn()}
totalCount={100}
selectedEventIds={{}}
isFilteredToOpen={false}
selectAll={jest.fn()}
showClearSelection={true}
updateSignalsStatus={jest.fn()}
/>
);

expect(wrapper.find('[dataTestSubj="openCloseSignal"]')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { SignalsHistogramPanel } from './index';

jest.mock('../../../../lib/kibana');
jest.mock('../../../../components/navigation/use_get_url_search');

describe('SignalsHistogramPanel', () => {
it('renders correctly', () => {
const wrapper = shallow(
<SignalsHistogramPanel
from={0}
signalIndexName="signalIndexName"
setQuery={jest.fn()}
to={1}
updateDateRange={jest.fn()}
/>
);

expect(wrapper.find('[id="detections-histogram"]')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 React from 'react';
import { shallow } from 'enzyme';

import { SignalsHistogram } from './signals_histogram';

jest.mock('../../../../lib/kibana');

describe('SignalsHistogram', () => {
it('renders correctly', () => {
const wrapper = shallow(
<SignalsHistogram loading={false} data={[]} from={0} to={1} updateDateRange={jest.fn()} />
);

expect(wrapper.find('Chart')).toBeTruthy();
});
});
Loading

0 comments on commit 10c6b46

Please sign in to comment.