Skip to content

Commit d796e51

Browse files
Merge branch '7.x' into backport/7.x/pr-53287
2 parents 41b0ca0 + fc6786c commit d796e51

26 files changed

Lines changed: 241 additions & 581 deletions

File tree

test/plugin_functional/config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ 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',
6360
...plugins.map(
6461
pluginDir => `--plugin-path=${path.resolve(__dirname, 'plugins', pluginDir)}`
6562
),
63+
// Required to load new platform plugins via `--plugin-path` flag.
64+
'--env.name=development',
6665
],
6766
},
6867
};

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

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

2323
declare global {
2424
interface Window {
25+
corePluginB?: string;
26+
hasAccessToInjectedMetadata?: boolean;
27+
receivedStartServices?: boolean;
2528
env?: PluginInitializerContext['env'];
2629
}
2730
}
@@ -36,6 +39,12 @@ export class CorePluginBPlugin
3639
window.env = pluginContext.env;
3740
}
3841
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+
3948
core.application.register({
4049
id: 'bar',
4150
title: 'Bar',
@@ -44,12 +53,6 @@ export class CorePluginBPlugin
4453
return renderApp(context, params);
4554
},
4655
});
47-
48-
return {
49-
sayHi() {
50-
return `Plugin A said: ${deps.core_plugin_a.getGreeting()}`;
51-
},
52-
};
5356
}
5457

5558
public start() {}

test/plugin_functional/plugins/core_provider_plugin/index.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

test/plugin_functional/plugins/core_provider_plugin/package.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/plugin_functional/plugins/core_provider_plugin/tsconfig.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/plugin_functional/plugins/ui_settings_plugin/kibana.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"kibanaVersion": "kibana",
55
"configPath": ["ui_settings_plugin"],
66
"server": true,
7-
"ui": false
7+
"ui": true
88
}

test/plugin_functional/plugins/core_provider_plugin/public/index.ts renamed to test/plugin_functional/plugins/ui_settings_plugin/public/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import { npSetup, npStart } from 'ui/new_platform';
20-
import '../types';
19+
import { UiSettingsPlugin } from './plugin';
2120

22-
window.__coreProvider = {
23-
setup: npSetup,
24-
start: npStart,
25-
testUtils: {
26-
delay: (ms: number) => new Promise(res => setTimeout(res, ms)),
27-
},
28-
};
21+
export const plugin = () => new UiSettingsPlugin();

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

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-
import { LegacyCoreSetup, LegacyCoreStart } from 'kibana/public';
19+
20+
import { CoreSetup, Plugin } from 'kibana/public';
2021

2122
declare global {
2223
interface Window {
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-
};
24+
uiSettingsPlugin?: Record<string, any>;
25+
uiSettingsPluginValue?: string;
3626
}
3727
}
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+
}

test/plugin_functional/plugins/ui_settings_plugin/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"skipLibCheck": true
66
},
77
"include": [
8+
"index.ts",
9+
"public/**/*.ts",
10+
"public/**/*.tsx",
811
"server/**/*.ts",
912
"../../../../typings/**/*",
1013
],

test/plugin_functional/test_suites/core_plugins/ui_plugins.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import expect from '@kbn/expect';
2121
import { PluginFunctionalProviderContext } from '../../services';
22-
import '../../../../test/plugin_functional/plugins/core_provider_plugin/types';
2322

2423
// eslint-disable-next-line import/no-default-export
2524
export default function({ getService, getPageObjects }: PluginFunctionalProviderContext) {
@@ -32,35 +31,22 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider
3231
await PageObjects.common.navigateToApp('settings');
3332
});
3433

35-
it('should run the new platform plugins', async () => {
36-
expect(
37-
await browser.execute(() => {
38-
return window.__coreProvider.setup.plugins.core_plugin_b.sayHi();
39-
})
40-
).to.be('Plugin A said: Hello from Plugin A!');
34+
it('should attach string to window.corePluginB', async () => {
35+
const corePluginB = await browser.execute('return window.corePluginB');
36+
expect(corePluginB).to.equal(`Plugin A said: Hello from Plugin A!`);
4137
});
4238
});
4339

44-
describe('should have access to the core services', function describeIndexTests() {
40+
describe('have injectedMetadata service provided', function describeIndexTests() {
4541
before(async () => {
46-
await PageObjects.common.navigateToApp('settings');
47-
});
48-
49-
it('to injectedMetadata service', async () => {
50-
expect(
51-
await browser.execute(() => {
52-
return window.__coreProvider.setup.core.injectedMetadata.getKibanaBuildNumber();
53-
})
54-
).to.be.a('number');
42+
await PageObjects.common.navigateToApp('bar');
5543
});
5644

57-
it('to start services via coreSetup.getStartServices', async () => {
58-
expect(
59-
await browser.executeAsync(async cb => {
60-
const [coreStart] = await window.__coreProvider.setup.core.getStartServices();
61-
cb(Boolean(coreStart.overlays));
62-
})
63-
).to.be(true);
45+
it('should attach boolean to window.hasAccessToInjectedMetadata', async () => {
46+
const hasAccessToInjectedMetadata = await browser.execute(
47+
'return window.hasAccessToInjectedMetadata'
48+
);
49+
expect(hasAccessToInjectedMetadata).to.equal(true);
6450
});
6551
});
6652

@@ -75,5 +61,16 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider
7561
expect(envData.packageInfo.version).to.be.a('string');
7662
});
7763
});
64+
65+
describe('have access to start services via coreSetup.getStartServices', function describeIndexTests() {
66+
before(async () => {
67+
await PageObjects.common.navigateToApp('bar');
68+
});
69+
70+
it('should attach boolean to window.receivedStartServices', async () => {
71+
const receivedStartServices = await browser.execute('return window.receivedStartServices');
72+
expect(receivedStartServices).to.equal(true);
73+
});
74+
});
7875
});
7976
}

0 commit comments

Comments
 (0)