Skip to content

Commit

Permalink
Migrate test plugins ⇒ NP (kbn_tp_run_pipeline) (#64780)
Browse files Browse the repository at this point in the history
* Migrated kbn_tp_run_pipeline to the new Platform

* Updated config.

* Added tsconfig.

* Updated index.ts for tests

* updated tsconfig

* Updated typescript task

* fixed tests

* Fixed tests

* updated comment

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
VladLasitsa and elasticmachine committed May 7, 2020
1 parent 4a6ecc8 commit c5d4d9e
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 125 deletions.
3 changes: 3 additions & 0 deletions src/dev/typescript/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export const PROJECTS = [
...glob
.sync('test/plugin_functional/plugins/*/tsconfig.json', { cwd: REPO_ROOT })
.map(path => new Project(resolve(REPO_ROOT, path))),
...glob
.sync('test/interpreter_functional/plugins/*/tsconfig.json', { cwd: REPO_ROOT })
.map(path => new Project(resolve(REPO_ROOT, path))),
];

export function filterProjectsByFlag(projectFlag?: string) {
Expand Down
3 changes: 3 additions & 0 deletions test/interpreter_functional/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) {
...functionalConfig.get('kbnTestServer'),
serverArgs: [
...functionalConfig.get('kbnTestServer.serverArgs'),

// Required to load new platform plugins via `--plugin-path` flag.
'--env.name=development',
...plugins.map(
pluginDir => `--plugin-path=${path.resolve(__dirname, 'plugins', pluginDir)}`
),
Expand Down
49 changes: 0 additions & 49 deletions test/interpreter_functional/plugins/kbn_tp_run_pipeline/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"id": "kbn_tp_run_pipeline",
"version": "0.0.1",
"kibanaVersion": "kibana",
"requiredPlugins": [
"data",
"savedObjects",
"kibanaUtils",
"expressions"
],
"server": false,
"ui": true
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "kbn_tp_run_pipeline",
"version": "1.0.0",
"main": "target/test/interpreter_functional/plugins/kbn_tp_run_pipeline",
"kibana": {
"version": "kibana",
"templateVersion": "1.0.0"
Expand All @@ -10,5 +11,13 @@
"@elastic/eui": "22.3.1",
"react": "^16.12.0",
"react-dom": "^16.12.0"
},
"scripts": {
"kbn": "node ../../../../scripts/kbn.js",
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"@kbn/plugin-helpers": "9.0.2",
"typescript": "3.7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';
import { EuiPage, EuiPageBody, EuiPageContent, EuiPageContentHeader } from '@elastic/eui';
import { first } from 'rxjs/operators';
import { IInterpreterRenderHandlers, ExpressionValue } from 'src/plugins/expressions';
import { RequestAdapter, DataAdapter } from '../../../../../../../../src/plugins/inspector';
import { RequestAdapter, DataAdapter } from '../../../../../../../src/plugins/inspector';
import { Adapters, ExpressionRenderHandler } from '../../types';
import { getExpressions } from '../../services';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@
* under the License.
*/

export * from './np_ready';
import { PluginInitializer, PluginInitializerContext } from 'src/core/public';
import { Plugin, StartDeps } from './plugin';
export { StartDeps };

export const plugin: PluginInitializer<void, void, {}, StartDeps> = (
initializerContext: PluginInitializerContext
) => {
return new Plugin(initializerContext);
};

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { createGetterSetter } from '../../../../../../src/plugins/kibana_utils/public';
import { createGetterSetter } from '../../../../../src/plugins/kibana_utils/public';
import { ExpressionsStart } from './types';

export const [getExpressions, setExpressions] = createGetterSetter<ExpressionsStart>('Expressions');
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",
"public/**/*.ts",
"public/**/*.tsx",
"../../../../typings/**/*",
],
"exclude": []
}
9 changes: 5 additions & 4 deletions test/interpreter_functional/test_suites/run_pipeline/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ export default function({
await expectExpression('partial_test_2', metricExpr, context).toMatchSnapshot()
).toMatchScreenshot();

const regionMapExpr = `regionmap visConfig='{"metric":{"accessor":1,"format":{"id":"number"}},"bucket":{"accessor":0}}'`;
await (
await expectExpression('partial_test_3', regionMapExpr, context).toMatchSnapshot()
).toMatchScreenshot();
// TODO: should be uncommented when the region map is migrated to the new platform
// const regionMapExpr = `regionmap visConfig='{"metric":{"accessor":1,"format":{"id":"number"}},"bucket":{"accessor":0}}'`;
// await (
// await expectExpression('partial_test_3', regionMapExpr, context).toMatchSnapshot()
// ).toMatchScreenshot();
});
});
});
Expand Down
13 changes: 12 additions & 1 deletion test/interpreter_functional/test_suites/run_pipeline/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ import expect from '@kbn/expect';
import { ExpressionValue } from 'src/plugins/expressions';
import { FtrProviderContext } from '../../../functional/ftr_provider_context';

declare global {
interface Window {
runPipeline: (
expressions: string,
context?: ExpressionValue,
initialContext?: ExpressionValue
) => any;
renderPipelineResponse: (context?: ExpressionValue) => Promise<any>;
}
}

export type ExpressionResult = any;

export type ExpectExpression = (
Expand Down Expand Up @@ -165,7 +176,7 @@ export function expectExpressionProvider({
log.debug('starting to render');
const result = await browser.executeAsync<any>(
(_context: ExpressionResult, done: (renderResult: any) => void) =>
window.renderPipelineResponse(_context).then(renderResult => {
window.renderPipelineResponse(_context).then((renderResult: any) => {
done(renderResult);
return renderResult;
}),
Expand Down
1 change: 1 addition & 0 deletions test/scripts/jenkins_build_kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ echo " -> building kibana platform plugins"
node scripts/build_kibana_platform_plugins \
--oss \
--scan-dir "$KIBANA_DIR/test/plugin_functional/plugins" \
--scan-dir "$KIBANA_DIR/test/interpreter_functional/plugins" \
--verbose;

# doesn't persist, also set in kibanaPipeline.groovy
Expand Down
3 changes: 2 additions & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"typings/**/*"
],
"exclude": [
"plugin_functional/plugins/**/*"
"plugin_functional/plugins/**/*",
"interpreter_functional/plugins/**/*"
]
}

0 comments on commit c5d4d9e

Please sign in to comment.