Skip to content

Commit 53be78a

Browse files
Merge branch 'master' into maps/hide_legend_when_invisible
2 parents 48b2866 + 22b8335 commit 53be78a

File tree

39 files changed

+799
-289
lines changed

39 files changed

+799
-289
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import { UiSettingsPlugin } from './plugin';
2019

21-
export const plugin = () => new UiSettingsPlugin();
20+
import Fs from 'fs';
21+
import { promisify } from 'util';
22+
23+
export const readFile = promisify(Fs.readFile);
24+
export const writeFile = promisify(Fs.writeFile);

src/core/server/uuid/resolve_uuid.test.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,22 @@
1717
* under the License.
1818
*/
1919

20-
import { promises } from 'fs';
2120
import { join } from 'path';
21+
import { readFile, writeFile } from './fs';
2222
import { resolveInstanceUuid } from './resolve_uuid';
2323
import { configServiceMock } from '../config/config_service.mock';
2424
import { loggingServiceMock } from '../logging/logging_service.mock';
2525
import { BehaviorSubject } from 'rxjs';
2626
import { Logger } from '../logging';
2727

28-
const { readFile, writeFile } = promises;
29-
3028
jest.mock('uuid', () => ({
3129
v4: () => 'NEW_UUID',
3230
}));
3331

34-
jest.mock('fs', () => {
35-
const actual = jest.requireActual('fs');
36-
return {
37-
...actual,
38-
promises: {
39-
...actual.promises,
40-
readFile: jest.fn(() => Promise.resolve('')),
41-
writeFile: jest.fn(() => Promise.resolve('')),
42-
},
43-
};
44-
});
32+
jest.mock('./fs', () => ({
33+
readFile: jest.fn(() => Promise.resolve('')),
34+
writeFile: jest.fn(() => Promise.resolve('')),
35+
}));
4536

4637
const DEFAULT_FILE_UUID = 'FILE_UUID';
4738
const DEFAULT_CONFIG_UUID = 'CONFIG_UUID';

src/core/server/uuid/resolve_uuid.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
*/
1919

2020
import uuid from 'uuid';
21-
import { promises } from 'fs';
2221
import { join } from 'path';
2322
import { take } from 'rxjs/operators';
23+
import { readFile, writeFile } from './fs';
2424
import { IConfigService } from '../config';
2525
import { PathConfigType, config as pathConfigDef } from '../path';
2626
import { HttpConfigType, config as httpConfigDef } from '../http';
2727
import { Logger } from '../logging';
2828

29-
const { readFile, writeFile } = promises;
30-
3129
const FILE_ENCODING = 'utf8';
3230
const FILE_NAME = 'uuid';
3331

test/plugin_functional/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ export default async function({ readConfigFile }) {
5757
...functionalConfig.get('kbnTestServer'),
5858
serverArgs: [
5959
...functionalConfig.get('kbnTestServer.serverArgs'),
60+
61+
// Required to load new platform plugins via `--plugin-path` flag.
62+
'--env.name=development',
6063
...plugins.map(
6164
pluginDir => `--plugin-path=${path.resolve(__dirname, 'plugins', pluginDir)}`
6265
),
63-
// Required to load new platform plugins via `--plugin-path` flag.
64-
'--env.name=development',
6566
],
6667
},
6768
};

test/plugin_functional/plugins/core_plugin_b/public/plugin.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import { CorePluginAPluginSetup } from '../../core_plugin_a/public/plugin';
2222

2323
declare global {
2424
interface Window {
25-
corePluginB?: string;
26-
hasAccessToInjectedMetadata?: boolean;
27-
receivedStartServices?: boolean;
2825
env?: PluginInitializerContext['env'];
2926
}
3027
}
@@ -39,12 +36,6 @@ export class CorePluginBPlugin
3936
window.env = pluginContext.env;
4037
}
4138
public setup(core: CoreSetup, deps: CorePluginBDeps) {
42-
window.corePluginB = `Plugin A said: ${deps.core_plugin_a.getGreeting()}`;
43-
window.hasAccessToInjectedMetadata = 'getInjectedVar' in core.injectedMetadata;
44-
core.getStartServices().then(([coreStart, plugins]) => {
45-
window.receivedStartServices = 'overlays' in coreStart;
46-
});
47-
4839
core.application.register({
4940
id: 'bar',
5041
title: 'Bar',
@@ -53,6 +44,12 @@ export class CorePluginBPlugin
5344
return renderApp(context, params);
5445
},
5546
});
47+
48+
return {
49+
sayHi() {
50+
return `Plugin A said: ${deps.core_plugin_a.getGreeting()}`;
51+
},
52+
};
5653
}
5754

5855
public start() {}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { resolve } from 'path';
21+
import { Legacy } from '../../../../kibana';
22+
23+
// eslint-disable-next-line import/no-default-export
24+
export default function CoreProviderPlugin(kibana: any) {
25+
const config: Legacy.PluginSpecOptions = {
26+
id: 'core-provider',
27+
require: [],
28+
publicDir: resolve(__dirname, 'public'),
29+
init: (server: Legacy.Server) => ({}),
30+
uiExports: {
31+
hacks: [resolve(__dirname, 'public/index')],
32+
},
33+
};
34+
35+
return new kibana.Plugin(config);
36+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "core_provider_plugin",
3+
"version": "1.0.0",
4+
"main": "target/test/plugin_functional/plugins/core_provider_plugin",
5+
"kibana": {
6+
"version": "kibana",
7+
"templateVersion": "1.0.0"
8+
},
9+
"license": "Apache-2.0",
10+
"scripts": {
11+
"kbn": "node ../../../../scripts/kbn.js",
12+
"build": "rm -rf './target' && tsc"
13+
},
14+
"devDependencies": {
15+
"typescript": "3.5.3"
16+
}
17+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
import { npSetup, npStart } from 'ui/new_platform';
20+
import '../types';
21+
22+
window.__coreProvider = {
23+
setup: npSetup,
24+
start: npStart,
25+
testUtils: {
26+
delay: (ms: number) => new Promise(res => setTimeout(res, ms)),
27+
},
28+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../../../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./target",
5+
"skipLibCheck": true
6+
},
7+
"include": [
8+
"index.ts",
9+
"types.ts",
10+
"public/**/*.ts",
11+
"../../../../typings/**/*",
12+
],
13+
"exclude": []
14+
}

test/plugin_functional/plugins/ui_settings_plugin/public/plugin.tsx renamed to test/plugin_functional/plugins/core_provider_plugin/types.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
20-
import { CoreSetup, Plugin } from 'kibana/public';
19+
import { LegacyCoreSetup, LegacyCoreStart } from 'kibana/public';
2120

2221
declare global {
2322
interface Window {
24-
uiSettingsPlugin?: Record<string, any>;
25-
uiSettingsPluginValue?: string;
23+
__coreProvider: {
24+
setup: {
25+
core: LegacyCoreSetup;
26+
plugins: Record<string, any>;
27+
};
28+
start: {
29+
core: LegacyCoreStart;
30+
plugins: Record<string, any>;
31+
};
32+
testUtils: {
33+
delay: (ms: number) => Promise<void>;
34+
};
35+
};
2636
}
2737
}
28-
29-
export class UiSettingsPlugin implements Plugin {
30-
public setup(core: CoreSetup) {
31-
window.uiSettingsPlugin = core.uiSettings.getAll().ui_settings_plugin;
32-
window.uiSettingsPluginValue = core.uiSettings.get('ui_settings_plugin');
33-
}
34-
35-
public start() {}
36-
public stop() {}
37-
}

0 commit comments

Comments
 (0)