Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NP Migration: Rollup plugin #53503

Merged
merged 54 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
96c8004
Start shimming rollup plugin
flash1293 Dec 18, 2019
ab6d618
Merge remote-tracking branch 'upstream/master' into migration/rollup
flash1293 Dec 20, 2019
ce83531
continued shimming rollup ui
flash1293 Dec 20, 2019
0d6cdc9
Merge branch 'master' into migration/rollup
maryia-lapata Jan 8, 2020
6dba8d4
Remove unnecessarily return
maryia-lapata Jan 9, 2020
f257af1
Merge remote-tracking branch 'kibana/master' into migration/rollup
maryia-lapata Jan 9, 2020
937297c
Register management section
maryia-lapata Jan 9, 2020
bd7df05
Replace ui/chrome
maryia-lapata Jan 10, 2020
1dcc987
Merge remote-tracking branch 'kibana/master' into migration/rollup
maryia-lapata Jan 13, 2020
f698766
Replace ui/documentation_links
maryia-lapata Jan 13, 2020
9612ec7
Replace ui/kfetch and ui/courier
maryia-lapata Jan 15, 2020
4336dce
Start shimming rollup plugin
flash1293 Dec 18, 2019
ec8730a
continued shimming rollup ui
flash1293 Dec 20, 2019
339d013
Remove unnecessarily return
maryia-lapata Jan 9, 2020
c0dfed8
Register management section
maryia-lapata Jan 9, 2020
518d580
Replace ui/chrome
maryia-lapata Jan 10, 2020
d1233b4
Replace ui/documentation_links
maryia-lapata Jan 13, 2020
1e77e22
Replace ui/kfetch and ui/courier
maryia-lapata Jan 15, 2020
79ee7c6
Replace ui/notify
maryia-lapata Jan 16, 2020
b8c8dad
Move ui/ imports to legacy_imports.ts
maryia-lapata Jan 16, 2020
b6f1f9e
Update NP mock for management
maryia-lapata Jan 16, 2020
c3158ff
Merge branch 'master' into migration/rollup
elasticmachine Jan 16, 2020
522ebff
Refactoring
maryia-lapata Jan 16, 2020
50ccb07
Read body from error object
maryia-lapata Jan 16, 2020
3f400ec
Update setup_environment.js
maryia-lapata Jan 17, 2020
808b8cb
Merge branch 'master' into migration/rollup
maryia-lapata Jan 17, 2020
9bde52f
Merge branch 'migration/rollup' of https://github.com/flash1293/kiban…
maryia-lapata Jan 20, 2020
a4846a3
Merge remote-tracking branch 'kibana/master' into migration/rollup
maryia-lapata Jan 20, 2020
c05f723
Update unit tests
maryia-lapata Jan 20, 2020
9136fb7
Get rid of injectI18n
maryia-lapata Jan 20, 2020
fd47a1a
Merge remote-tracking branch 'kibana/master' into migration/rollup
maryia-lapata Jan 22, 2020
e815a97
Replace npStart and npSetup usage to services
maryia-lapata Jan 22, 2020
24ba489
Import search strategy stuff from the top level of the data plugin
maryia-lapata Jan 22, 2020
8225854
Update unit tests
maryia-lapata Jan 22, 2020
58be105
Do not prepend the url
maryia-lapata Jan 23, 2020
39c7801
Merge branch 'master' into migration/rollup
elasticmachine Jan 24, 2020
b8ee8f7
Merge branch 'master' into migration/rollup
elasticmachine Jan 27, 2020
ebe5e98
Merge branch 'master' into migration/rollup
maryia-lapata Jan 28, 2020
27400e9
Fix merge conflicts
maryia-lapata Jan 28, 2020
8c9163f
Refactoring
maryia-lapata Jan 28, 2020
07b58cd
Revert removal of setUserHasLeftApp
maryia-lapata Jan 28, 2020
32aa6fb
Export getSearchErrorType
maryia-lapata Jan 28, 2020
14ef013
Remove extra wrapper - Router
maryia-lapata Jan 28, 2020
8291fc4
Merge branch 'master' into migration/rollup
maryia-lapata Jan 29, 2020
7000b9d
Fix cause prop.
maryia-lapata Jan 29, 2020
6a2f72e
Leave just static imports in legacy_imports.js
maryia-lapata Jan 29, 2020
aead81b
Add TS
maryia-lapata Jan 29, 2020
cc80ce0
Pass statusCode instead of statusText
maryia-lapata Jan 29, 2020
09518e3
Move template in a separate file
maryia-lapata Jan 29, 2020
7d702a7
Move app register to setup
maryia-lapata Jan 29, 2020
6e85464
Merge remote-tracking branch 'kibana/master' into migration/rollup
maryia-lapata Jan 29, 2020
69675c0
Add karma mock for management setup
maryia-lapata Jan 29, 2020
763e01d
Add EditorConfigProviderRegistry export
maryia-lapata Jan 30, 2020
29663bc
Merge remote-tracking branch 'kibana/master' into migration/rollup
maryia-lapata Jan 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/legacy/ui/public/agg_types/filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export { aggTypeFilters } from './agg_type_filters';
export { aggTypeFilters, AggTypeFilters } from './agg_type_filters';
export { propFilter } from './prop_filter';
2 changes: 1 addition & 1 deletion src/legacy/ui/public/agg_types/param_types/filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export { aggTypeFieldFilters } from './field_filters';
export { aggTypeFieldFilters, AggTypeFieldFilters } from './field_filters';
12 changes: 12 additions & 0 deletions src/legacy/ui/public/new_platform/new_platform.karma_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ export const npSetup = {
useChartsTheme: sinon.fake(),
},
},
management: {
sections: {
getSection: () => ({
registerApp: sinon.fake(),
}),
},
},
},
};

Expand All @@ -167,6 +174,11 @@ export const npStart = {
hasItem: sinon.fake(),
}),
},
sections: {
getSection: () => ({
registerApp: sinon.fake(),
}),
},
},
embeddable: {
getEmbeddableFactory: sinon.fake(),
Expand Down
3 changes: 2 additions & 1 deletion src/legacy/ui/public/new_platform/new_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { DevToolsSetup, DevToolsStart } from '../../../../plugins/dev_tools/publ
import { KibanaLegacySetup, KibanaLegacyStart } from '../../../../plugins/kibana_legacy/public';
import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../plugins/home/public';
import { SharePluginSetup, SharePluginStart } from '../../../../plugins/share/public';
import { ManagementStart } from '../../../../plugins/management/public';
import { ManagementSetup, ManagementStart } from '../../../../plugins/management/public';
import { BfetchPublicSetup, BfetchPublicStart } from '../../../../plugins/bfetch/public';
import { UsageCollectionSetup } from '../../../../plugins/usage_collection/public';
import {
Expand All @@ -54,6 +54,7 @@ export interface PluginsSetup {
kibana_legacy: KibanaLegacySetup;
share: SharePluginSetup;
usageCollection: UsageCollectionSetup;
management: ManagementSetup;
}

export interface PluginsStart {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/vis/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export { editorConfigProviders } from './editor_config_providers';
export { editorConfigProviders, EditorConfigProviderRegistry } from './editor_config_providers';
export * from './types';
2 changes: 2 additions & 0 deletions src/plugins/data/public/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export {
hasSearchStategyForIndexPattern,
defaultSearchStrategy,
SearchError,
SearchStrategyProvider,
getSearchErrorType,
} from './search_strategy';

export {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { setup as jobCloneSetup } from './job_clone.helpers';

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

export { setupEnvironment } from './setup_environment';
export { mockHttpRequest } from './setup_environment';

export { wrapComponent } from './setup_context';

export const pageHelpers = {
jobCreate: { setup: jobCreateSetup },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { JobCreate } from '../../../public/crud_app/sections';
import { JOB_TO_CLONE } from './constants';
import { deserializeJob } from '../../../public/crud_app/services';

import { wrapComponent } from './setup_context';

export const setup = props => {
const initTestBed = registerTestBed(JobCreate, {
const initTestBed = registerTestBed(wrapComponent(JobCreate), {
store: createRollupJobsStore({
cloneJob: { job: deserializeJob(JOB_TO_CLONE.jobs[0]) },
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { JobCreate } from '../../../public/crud_app/sections';

import { JOB_TO_CREATE } from './constants';

const initTestBed = registerTestBed(JobCreate, { store: rollupJobsStore });
import { wrapComponent } from './setup_context';

const initTestBed = registerTestBed(wrapComponent(JobCreate), { store: rollupJobsStore });

export const setup = props => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { registerRouter } from '../../../public/crud_app/services';
import { createRollupJobsStore } from '../../../public/crud_app/store';
import { JobList } from '../../../public/crud_app/sections/job_list';

import { wrapComponent } from './setup_context';

const testBedConfig = {
store: createRollupJobsStore,
memoryRouter: {
Expand All @@ -19,4 +21,4 @@ const testBedConfig = {
},
};

export const setup = registerTestBed(JobList, testBedConfig);
export const setup = registerTestBed(wrapComponent(JobList), testBedConfig);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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, { FunctionComponent } from 'react';

import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public';
import { coreMock } from '../../../../../../../src/core/public/mocks';
const startMock = coreMock.createStart();

const services = {
setBreadcrumbs: startMock.chrome.setBreadcrumbs,
};

const wrapComponent = (Component: FunctionComponent) => (props: any) => (
<KibanaContextProvider services={services}>
<Component {...props} />
</KibanaContextProvider>
);

export { wrapComponent };

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.
*/

interface RequestMocks {
jobs?: object;
createdJob?: object;
indxPatternVldtResp?: object;
[key: string]: any;
}

const mockHttpRequest = (
http: any,
{ jobs = {}, createdJob = {}, indxPatternVldtResp = {} }: RequestMocks = {}
) => {
http.get.mockImplementation(async (url: string) => {
if (url === '/api/rollup/jobs') {
return jobs;
}

if (url.startsWith('/api/rollup/index_pattern_validity')) {
return {
doesMatchIndices: true,
doesMatchRollupIndices: false,
dateFields: ['foo', 'bar'],
numericFields: [],
keywordFields: [],
...indxPatternVldtResp,
};
}

return {};
});

// mock '/api/rollup/start'
http.post.mockImplementation(async (url: string) => ({}));

// mock '/api/rollup/create
http.put.mockImplementation(async (url: string) => createdJob);
};

export { mockHttpRequest };
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { setupEnvironment, pageHelpers, nextTick } from './helpers';
import { setHttp } from '../../public/crud_app/services';
import { mockHttpRequest, pageHelpers, nextTick } from './helpers';
import { JOB_TO_CLONE, JOB_CLONE_INDEX_PATTERN_CHECK } from './helpers/constants';

jest.mock('ui/new_platform');
Expand All @@ -17,26 +18,28 @@ const {
} = JOB_TO_CLONE;

describe('Cloning a rollup job through create job wizard', () => {
let httpRequestsMockHelpers;
let server;
let find;
let exists;
let form;
let table;
let actions;
let npStart;

beforeAll(() => {
({ server, httpRequestsMockHelpers } = setupEnvironment());
npStart = require('ui/new_platform').npStart; // eslint-disable-line
setHttp(npStart.core.http);
});

beforeEach(() => {
httpRequestsMockHelpers.setIndexPatternValidityResponse(JOB_CLONE_INDEX_PATTERN_CHECK);
mockHttpRequest(npStart.core.http, { indxPatternVldtResp: JOB_CLONE_INDEX_PATTERN_CHECK });

({ exists, find, form, actions, table } = setup());
});

afterAll(() => {
server.restore();
afterEach(() => {
npStart.core.http.get.mockClear();
npStart.core.http.post.mockClear();
npStart.core.http.put.mockClear();
});

it('should have fields correctly pre-populated', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import moment from 'moment-timezone';

import { setupEnvironment, pageHelpers } from './helpers';
import { setHttp } from '../../public/crud_app/services';
import { mockHttpRequest, pageHelpers } from './helpers';

jest.mock('ui/new_platform');

Expand All @@ -15,30 +16,31 @@ jest.mock('lodash/function/debounce', () => fn => fn);
const { setup } = pageHelpers.jobCreate;

describe('Create Rollup Job, step 2: Date histogram', () => {
let server;
let httpRequestsMockHelpers;
let find;
let exists;
let actions;
let goToStep;
let form;
let getEuiStepsHorizontalActive;
let npStart;

beforeAll(() => {
({ server, httpRequestsMockHelpers } = setupEnvironment());
npStart = require('ui/new_platform').npStart; // eslint-disable-line
setHttp(npStart.core.http);
});

afterAll(() => {
server.restore();
});

beforeEach(() => {
// Set "default" mock responses by not providing any arguments
httpRequestsMockHelpers.setIndexPatternValidityResponse();
mockHttpRequest(npStart.core.http);

({ find, exists, actions, form, getEuiStepsHorizontalActive, goToStep } = setup());
});

afterEach(() => {
npStart.core.http.get.mockClear();
npStart.core.http.post.mockClear();
npStart.core.http.put.mockClear();
});

describe('layout', () => {
beforeEach(async () => {
await goToStep(2);
Expand Down Expand Up @@ -71,7 +73,7 @@ describe('Create Rollup Job, step 2: Date histogram', () => {
describe('Date field select', () => {
it('should set the options value from the index pattern', async () => {
const dateFields = ['field1', 'field2', 'field3'];
httpRequestsMockHelpers.setIndexPatternValidityResponse({ dateFields });
mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { dateFields } });

await goToStep(2);

Expand All @@ -83,7 +85,7 @@ describe('Create Rollup Job, step 2: Date histogram', () => {

it('should sort the options in ascending order', async () => {
const dateFields = ['field3', 'field2', 'field1'];
httpRequestsMockHelpers.setIndexPatternValidityResponse({ dateFields });
mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { dateFields } });

await goToStep(2);

Expand Down
Loading