Skip to content

Commit

Permalink
Revert pointing x-pack test import to OSS
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed May 21, 2020
1 parent a653f43 commit 516ecb7
Show file tree
Hide file tree
Showing 75 changed files with 850 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { getRandomString } from '../../../../../../test_utils';
import { AutoFollowPattern } from '../../../../common/types';

const { getRandomString } = TestUtils;

export const getAutoFollowPatternMock = ({
name = getRandomString(),
active = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
*/

import Chance from 'chance';
import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { getRandomString } from '../../../../../../test_utils';
import { FollowerIndex } from '../../../../common/types';

const chance = new Chance();
const { getRandomString } = TestUtils;

interface FollowerIndexMock {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from '../../../../../../../src/plugins/es_ui_shared/public';
import { registerTestBed } from '../../../../../../test_utils';
import { AutoFollowPatternAdd } from '../../../app/sections/auto_follow_pattern_add';
import { ccrStore } from '../../../app/store';
import { routing } from '../../../app/services/routing';

const { registerTestBed } = TestUtils;
const testBedConfig = {
store: ccrStore,
memoryRouter: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from '../../../../../../../src/plugins/es_ui_shared/public';
import { registerTestBed } from '../../../../../../test_utils';
import { AutoFollowPatternEdit } from '../../../app/sections/auto_follow_pattern_edit';
import { ccrStore } from '../../../app/store';
import { routing } from '../../../app/services/routing';

import { AUTO_FOLLOW_PATTERN_EDIT_NAME } from './constants';

const { registerTestBed } = TestUtils;

const testBedConfig = {
store: ccrStore,
memoryRouter: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from '../../../../../../../src/plugins/es_ui_shared/public';
import { registerTestBed, findTestSubject } from '../../../../../../test_utils';
import { AutoFollowPatternList } from '../../../app/sections/home/auto_follow_pattern_list';
import { ccrStore } from '../../../app/store';
import { routing } from '../../../app/services/routing';
Expand All @@ -16,7 +16,6 @@ const testBedConfig = {
},
};

const { registerTestBed, findTestSubject } = TestUtils;
const initTestBed = registerTestBed(AutoFollowPatternList, testBedConfig);

export const setup = props => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from '../../../../../../../src/plugins/es_ui_shared/public';
import { registerTestBed } from '../../../../../../test_utils';
import { FollowerIndexAdd } from '../../../app/sections/follower_index_add';
import { ccrStore } from '../../../app/store';
import { routing } from '../../../app/services/routing';
Expand All @@ -16,7 +16,6 @@ const testBedConfig = {
},
};

const { registerTestBed } = TestUtils;
const initTestBed = registerTestBed(FollowerIndexAdd, testBedConfig);

export const setup = props => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from '../../../../../../../src/plugins/es_ui_shared/public';
import { registerTestBed } from '../../../../../../test_utils';
import { FollowerIndexEdit } from '../../../app/sections/follower_index_edit';
import { ccrStore } from '../../../app/store';
import { routing } from '../../../app/services/routing';

import { FOLLOWER_INDEX_EDIT_NAME } from './constants';

const { registerTestBed } = TestUtils;

const testBedConfig = {
store: ccrStore,
memoryRouter: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from '../../../../../../../src/plugins/es_ui_shared/public';
import { registerTestBed, findTestSubject } from '../../../../../../test_utils';
import { FollowerIndicesList } from '../../../app/sections/home/follower_indices_list';
import { ccrStore } from '../../../app/store';
import { routing } from '../../../app/services/routing';

const { registerTestBed, findTestSubject } = TestUtils;
const testBedConfig = {
store: ccrStore,
memoryRouter: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from '../../../../../../../src/plugins/es_ui_shared/public';
import { registerTestBed } from '../../../../../../test_utils';
import { BASE_PATH } from '../../../../common/constants';
import { CrossClusterReplicationHome } from '../../../app/sections/home/home';
import { ccrStore } from '../../../app/store';
import { routing } from '../../../app/services/routing';

const { registerTestBed } = TestUtils;
const testBedConfig = {
store: ccrStore,
memoryRouter: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { TestUtils } from '../../../../../../../src/plugins/es_ui_shared/public';

import { setup as autoFollowPatternListSetup } from './auto_follow_pattern_list.helpers';
import { setup as autoFollowPatternAddSetup } from './auto_follow_pattern_add.helpers';
import { setup as autoFollowPatternEditSetup } from './auto_follow_pattern_edit.helpers';
Expand All @@ -12,9 +12,7 @@ import { setup as followerIndexAddSetup } from './follower_index_add.helpers';
import { setup as followerIndexEditSetup } from './follower_index_edit.helpers';
import { setup as homeSetup } from './home.helpers';

const { nextTick, getRandomString, findTestSubject } = TestUtils;

export { nextTick, getRandomString, findTestSubject };
export { nextTick, getRandomString, findTestSubject } from '../../../../../../test_utils';

export { setupEnvironment } from './setup_environment';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@

import { ReactWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { TestUtils } from 'src/plugins/es_ui_shared/public';

import {
registerTestBed,
TestBed,
TestBedConfig,
findTestSubject,
nextTick,
} from '../../../../../test_utils';
import { IndexManagementHome } from '../../../public/application/sections/home'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { BASE_PATH } from '../../../common/constants';
import { indexManagementStore } from '../../../public/application/store'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { TemplateDeserialized } from '../../../common';
import { WithAppDependencies, services } from './setup_environment';

const { registerTestBed, findTestSubject, nextTick } = TestUtils;

const testBedConfig: TestUtils.TestBedConfig = {
const testBedConfig: TestBedConfig = {
store: () => indexManagementStore(services as any),
memoryRouter: {
initialEntries: [`${BASE_PATH}indices`],
Expand All @@ -27,7 +30,7 @@ const testBedConfig: TestUtils.TestBedConfig = {

const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), testBedConfig);

export interface IdxMgmtHomeTestBed extends TestUtils.TestBed<IdxMgmtTestSubjects> {
export interface IdxMgmtHomeTestBed extends TestBed<IdxMgmtTestSubjects> {
findAction: (action: 'edit' | 'clone' | 'delete') => ReactWrapper;
actions: {
selectHomeTab: (tab: 'indicesTab' | 'templatesTab') => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { setup as homeSetup } from './home.helpers';
import { setup as templateCreateSetup } from './template_create.helpers';
import { setup as templateCloneSetup } from './template_clone.helpers';
import { setup as templateEditSetup } from './template_edit.helpers';

type TestBed<T> = TestUtils.TestBed<T>;
const { nextTick, getRandomString, findTestSubject } = TestUtils;

export { nextTick, getRandomString, findTestSubject, TestBed };
export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../test_utils';

export { setupEnvironment } from './setup_environment';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { registerTestBed, TestBedConfig } from '../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateClone } from '../../../public/application/sections/template_clone'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { formSetup } from './template_form.helpers';
import { TEMPLATE_NAME } from './constants';
import { WithAppDependencies } from './setup_environment';

const { registerTestBed } = TestUtils;

const testBedConfig: TestUtils.TestBedConfig = {
const testBedConfig: TestBedConfig = {
memoryRouter: {
initialEntries: [`${BASE_PATH}clone_template/${TEMPLATE_NAME}`],
componentRoutePath: `${BASE_PATH}clone_template/:name`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { registerTestBed, TestBedConfig } from '../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateCreate } from '../../../public/application/sections/template_create'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { formSetup, TestSubjects } from './template_form.helpers';
import { WithAppDependencies } from './setup_environment';

const { registerTestBed } = TestUtils;

const testBedConfig: TestUtils.TestBedConfig = {
const testBedConfig: TestBedConfig = {
memoryRouter: {
initialEntries: [`${BASE_PATH}create_template`],
componentRoutePath: `${BASE_PATH}create_template`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { registerTestBed, TestBedConfig } from '../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateEdit } from '../../../public/application/sections/template_edit'; // eslint-disable-line @kbn/eslint/no-restricted-paths
import { formSetup, TestSubjects } from './template_form.helpers';
import { TEMPLATE_NAME } from './constants';
import { WithAppDependencies } from './setup_environment';

const { registerTestBed } = TestUtils;

const testBedConfig: TestUtils.TestBedConfig = {
const testBedConfig: TestBedConfig = {
memoryRouter: {
initialEntries: [`${BASE_PATH}edit_template/${TEMPLATE_NAME}`],
componentRoutePath: `${BASE_PATH}edit_template/:name`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { TestBed, SetupFunc, UnwrapPromise } from '../../../../../test_utils';
import { TemplateDeserialized } from '../../../common';
import { nextTick } from './index';

Expand All @@ -14,10 +14,10 @@ interface MappingField {

// Look at the return type of formSetup and form a union between that type and the TestBed type.
// This way we an define the formSetup return object and use that to dynamically define our type.
export type TemplateFormTestBed = TestUtils.TestBed<TemplateFormTestSubjects> &
TestUtils.UnwrapPromise<ReturnType<typeof formSetup>>;
export type TemplateFormTestBed = TestBed<TemplateFormTestSubjects> &
UnwrapPromise<ReturnType<typeof formSetup>>;

export const formSetup = async (initTestBed: TestUtils.SetupFunc<TestSubjects>) => {
export const formSetup = async (initTestBed: SetupFunc<TestSubjects>) => {
const testBed = await initTestBed();

// User actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { MemoryRouter } from 'react-router-dom';
*/
import * as stubWebWorker from '../../../../test_utils/stub_web_worker'; // eslint-disable-line no-unused-vars

import { mountWithIntl } from '../../../../test_utils/enzyme_helpers';
import { AppWithoutRouter } from '../../public/application/app';
import { AppContextProvider } from '../../public/application/app_context';
import { Provider } from 'react-redux';
Expand All @@ -30,6 +29,7 @@ import { setUiMetricService } from '../../public/application/services/api';
import { indexManagementStore } from '../../public/application/store';
import { setExtensionsService } from '../../public/application/store/selectors';
import { BASE_PATH, API_BASE_PATH } from '../../common/constants';
import { mountWithIntl } from '../../../../test_utils/enzyme_helpers';
import { ExtensionsService } from '../../public/services';
import sinon from 'sinon';
import { findTestSubject } from '@elastic/eui/lib/test';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { TestUtils } from 'src/plugins/es_ui_shared/public';
import {
setup as mappingsEditorSetup,
MappingsEditorTestBed,
DomFields,
getMappingsEditorDataFactory,
} from './mappings_editor.helpers';

const { nextTick, getRandomString, findTestSubject } = TestUtils;

type TestBed<T> = TestUtils.TestBed<T>;

export { nextTick, getRandomString, findTestSubject, TestBed };
export {
nextTick,
getRandomString,
findTestSubject,
TestBed,
} from '../../../../../../../../../test_utils';

export const componentHelpers = {
mappingsEditor: { setup: mappingsEditorSetup, getMappingsEditorDataFactory },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import React from 'react';
import { act } from 'react-dom/test-utils';
import { ReactWrapper } from 'enzyme';

import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { registerTestBed, TestBed } from '../../../../../../../../../test_utils';
import { getChildFieldsName } from '../../../lib';
import { MappingsEditor } from '../../../mappings_editor';

const { registerTestBed } = TestUtils;

jest.mock('@elastic/eui', () => ({
...jest.requireActual('@elastic/eui'),
// Mocking EuiComboBox, as it utilizes "react-virtualized" for rendering search suggestions,
Expand Down Expand Up @@ -57,7 +55,7 @@ export interface DomFields {
};
}

const createActions = (testBed: TestUtils.TestBed<TestSubjects>) => {
const createActions = (testBed: TestBed<TestSubjects>) => {
const { find, form, component } = testBed;

const getFieldInfo = (testSubjectField: string): { name: string; type: string } => {
Expand Down Expand Up @@ -293,7 +291,7 @@ export const getMappingsEditorDataFactory = (onChangeHandler: jest.MockedFunctio
};
};

export type MappingsEditorTestBed = TestUtils.TestBed<TestSubjects> & {
export type MappingsEditorTestBed = TestBed<TestSubjects> & {
actions: ReturnType<typeof createActions>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jest.mock('lodash', () => ({
debounce: (fn: any) => fn,
}));

import { TestUtils } from 'src/plugins/es_ui_shared/public';
import { registerTestBed, TestBed } from '../../../../../../../../test_utils';
import { LoadMappingsProvider } from './load_mappings_provider';

const ComponentToTest = ({ onJson }: { onJson: () => void }) => (
Expand All @@ -37,15 +37,13 @@ const ComponentToTest = ({ onJson }: { onJson: () => void }) => (
</LoadMappingsProvider>
);

const { registerTestBed } = TestUtils;

const setup = (props: any) =>
registerTestBed(ComponentToTest, {
memoryRouter: { wrapComponent: false },
defaultProps: props,
})();

const openModalWithJsonContent = ({ component, find }: TestUtils.TestBed) => (json: any) => {
const openModalWithJsonContent = ({ component, find }: TestBed) => (json: any) => {
act(() => {
find('load-json-button').simulate('click');
});
Expand All @@ -71,7 +69,7 @@ describe('<LoadMappingsProvider />', () => {
};

const onJson = jest.fn();
const testBed = setup({ onJson }) as TestUtils.TestBed;
const testBed = setup({ onJson }) as TestBed;

// Open the modal and add the JSON
openModalWithJsonContent(testBed)(mappingsToLoad);
Expand Down
Loading

0 comments on commit 516ecb7

Please sign in to comment.