-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Discuss] Functional tests for NP client side #52768
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { resolve } from 'path'; | ||
import { Legacy } from '../../../../kibana'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function CoreProviderPlugin(kibana: any) { | ||
const config: Legacy.PluginSpecOptions = { | ||
id: 'core-provider', | ||
require: [], | ||
publicDir: resolve(__dirname, 'public'), | ||
init: (server: Legacy.Server) => ({}), | ||
uiExports: { | ||
hacks: [resolve(__dirname, 'public/index')], | ||
}, | ||
}; | ||
|
||
return new kibana.Plugin(config); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "core_provider_plugin", | ||
"version": "1.0.0", | ||
"main": "target/test/plugin_functional/plugins/core_provider_plugin", | ||
"kibana": { | ||
"version": "kibana", | ||
"templateVersion": "1.0.0" | ||
}, | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"kbn": "node ../../../../scripts/kbn.js", | ||
"build": "rm -rf './target' && tsc" | ||
}, | ||
"devDependencies": { | ||
"typescript": "3.5.3" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": "../../../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./target", | ||
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"index.ts", | ||
"types.ts", | ||
"public/**/*.ts", | ||
"../../../../typings/**/*", | ||
], | ||
"exclude": [] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
"kibanaVersion": "kibana", | ||
"configPath": ["ui_settings_plugin"], | ||
"server": true, | ||
"ui": true | ||
"ui": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
import expect from '@kbn/expect'; | ||
import { PluginFunctionalProviderContext } from '../../services'; | ||
import '../../plugins/core_provider_plugin/types'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function({ getService, getPageObjects }: PluginFunctionalProviderContext) { | ||
|
@@ -31,23 +32,23 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider | |
await PageObjects.common.navigateToApp('settings'); | ||
}); | ||
|
||
it('should attach string to window.corePluginB', async () => { | ||
const corePluginB = await browser.execute('return window.corePluginB'); | ||
expect(corePluginB).to.equal(`Plugin A said: Hello from Plugin A!`); | ||
}); | ||
}); | ||
describe('have injectedMetadata service provided', function describeIndexTests() { | ||
before(async () => { | ||
await PageObjects.common.navigateToApp('bar'); | ||
it('should run the new platform plugins', async () => { | ||
expect( | ||
await browser.execute(() => { | ||
return window.np.setup.plugins.core_plugin_b.sayHi(); | ||
}) | ||
).to.be('Plugin A said: Hello from Plugin A!'); | ||
}); | ||
|
||
it('should attach string to window.corePluginB', async () => { | ||
const hasAccessToInjectedMetadata = await browser.execute( | ||
'return window.hasAccessToInjectedMetadata' | ||
); | ||
expect(hasAccessToInjectedMetadata).to.equal(true); | ||
expect( | ||
await browser.execute(() => { | ||
return window.np.setup.core.injectedMetadata.getKibanaBuildNumber(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. won't work on a NP app page, because we don't run LP |
||
}) | ||
).to.be.a('number'); | ||
}); | ||
}); | ||
|
||
describe('have env data provided', function describeIndexTests() { | ||
before(async () => { | ||
await PageObjects.common.navigateToApp('bar'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
import expect from '@kbn/expect'; | ||
import { PluginFunctionalProviderContext } from '../../services'; | ||
import '../../plugins/core_provider_plugin/types'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function({ getService, getPageObjects }: PluginFunctionalProviderContext) { | ||
|
@@ -31,15 +32,31 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider | |
}); | ||
|
||
it('client plugins have access to registered settings', async () => { | ||
const settings = await browser.execute('return window.uiSettingsPlugin'); | ||
const settings = await browser.execute( | ||
() => window.np.setup.core.uiSettings.getAll().ui_settings_plugin | ||
); | ||
|
||
expect(settings).to.eql({ | ||
category: ['any'], | ||
description: 'just for testing', | ||
name: 'from_ui_settings_plugin', | ||
value: '2', | ||
}); | ||
const settingsValue = await browser.execute('return window.uiSettingsPluginValue'); | ||
|
||
const settingsValue = await browser.execute(() => | ||
window.np.setup.core.uiSettings.get('ui_settings_plugin') | ||
); | ||
|
||
expect(settingsValue).to.be('2'); | ||
|
||
const settingsValueViaObservables = await browser.executeAsync((callback: Function) => { | ||
let value; | ||
window.np.setup.core.uiSettings.get$('ui_settings_plugin').subscribe(v => (value = v)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we cannot |
||
callback(value); | ||
return Promise.resolve(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is here just to mute TS error. I didn't manage to make it work with a promise. @dmlemeshko FYI There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the node-browser communications are, per nature, limited. To my knowledge There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like there is a wrong type on the our side
|
||
}); | ||
|
||
expect(settingsValueViaObservables).to.be('2'); | ||
}); | ||
|
||
it('server plugins have access to registered settings', async () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this will be sufficient or if we will need to find a way to expose some more internal core APIs for our tests.