Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ require('@kbn/test').runTestsCli([
require.resolve('../test/functional/config.js'),
require.resolve('../test/api_integration/config.js'),
require.resolve('../test/plugin_functional/config.js'),
require.resolve('../test/interpreter_functional/config.js'),
require.resolve('../test/interpreter_functional/config.ts'),
require.resolve('../test/ui_capabilities/newsfeed_err/config.ts'),
]);
11 changes: 7 additions & 4 deletions src/plugins/expressions/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
import { PluginInitializerContext } from '../../../core/public';
import { ExpressionsPublicPlugin } from './plugin';

export function plugin(initializerContext: PluginInitializerContext) {
return new ExpressionsPublicPlugin(initializerContext);
}

export { ExpressionsPublicPlugin as Plugin };

export * from './plugin';
export * from './types';
export * from '../common';
export { interpreterProvider, ExpressionInterpret } from './interpreter_provider';
export { ExpressionRenderer, ExpressionRendererProps } from './expression_renderer';
export { ExpressionDataHandler } from './execute';

export { RenderResult, ExpressionRenderHandler } from './render';

export function plugin(initializerContext: PluginInitializerContext) {
return new ExpressionsPublicPlugin(initializerContext);
}
10 changes: 6 additions & 4 deletions src/plugins/expressions/public/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ interface RenderError {

export type IExpressionRendererExtraHandlers = Record<string, any>;

export type RenderResult = RenderId | RenderError;

export class ExpressionRenderHandler {
render$: Observable<RenderId | RenderError>;
render$: Observable<RenderResult>;
update$: Observable<any>;
events$: Observable<event>;

private element: HTMLElement;
private destroyFn?: any;
private renderCount: number = 0;
private renderSubject: Rx.BehaviorSubject<RenderId | RenderError | null>;
private renderSubject: Rx.BehaviorSubject<RenderResult | null>;
private eventsSubject: Rx.Subject<unknown>;
private updateSubject: Rx.Subject<unknown>;
private handlers: IInterpreterRenderHandlers;
Expand All @@ -49,11 +51,11 @@ export class ExpressionRenderHandler {
this.eventsSubject = new Rx.Subject();
this.events$ = this.eventsSubject.asObservable().pipe(share());

this.renderSubject = new Rx.BehaviorSubject(null as RenderId | RenderError | null);
this.renderSubject = new Rx.BehaviorSubject(null as RenderResult | null);
this.render$ = this.renderSubject.asObservable().pipe(
share(),
filter(_ => _ !== null)
) as Observable<RenderId | RenderError>;
) as Observable<RenderResult>;

this.updateSubject = new Rx.Subject();
this.update$ = this.updateSubject.asObservable().pipe(share());
Expand Down
2 changes: 1 addition & 1 deletion tasks/config/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ module.exports = function (grunt) {
cmd: NODE,
args: [
'scripts/functional_tests',
'--config', 'test/interpreter_functional/config.js',
'--config', 'test/interpreter_functional/config.ts',
'--bail',
'--debug',
'--kibana-install-dir', KIBANA_INSTALL_DIR,
Expand Down
5 changes: 4 additions & 1 deletion test/functional/services/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
);
}

public async executeAsync<R>(fn: string | ((...args: any[]) => R), ...args: any[]): Promise<R> {
public async executeAsync<R>(
fn: string | ((...args: any[]) => Promise<R>),
...args: any[]
): Promise<R> {
return await driver.executeAsyncScript(
fn,
...cloneDeep<any>(args, arg => {
Expand Down
10 changes: 5 additions & 5 deletions test/interpreter_functional/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
This folder contains interpreter functional tests.

Add new test suites into the `test_suites` folder and reference them from the
`config.js` file. These test suites work the same as regular functional test.
`config.ts` file. These test suites work the same as regular functional test.

## Run the test

To run these tests during development you can use the following commands:

```
# Start the test server (can continue running)
node scripts/functional_tests_server.js --config test/interpreter_functional/config.js
node scripts/functional_tests_server.js --config test/interpreter_functional/config.ts

# Start a test run
node scripts/functional_test_runner.js --config test/interpreter_functional/config.js
node scripts/functional_test_runner.js --config test/interpreter_functional/config.ts
```

# Writing tests

Look into test_suites/run_pipeline/basic.js for examples
Look into test_suites/run_pipeline/basic.ts for examples

to update baseline screenshots and snapshots run with:
```
node scripts/functional_test_runner.js --config test/interpreter_functional/config.js --updateBaselines
node scripts/functional_test_runner.js --config test/interpreter_functional/config.ts --updateBaselines
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,26 @@

import path from 'path';
import fs from 'fs';
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';

export default async function ({ readConfigFile }) {
export default async function({ readConfigFile }: FtrConfigProviderContext) {
const functionalConfig = await readConfigFile(require.resolve('../functional/config'));

// Find all folders in ./plugins since we treat all them as plugin folder
const allFiles = fs.readdirSync(path.resolve(__dirname, 'plugins'));
const plugins = allFiles.filter(file => fs.statSync(path.resolve(__dirname, 'plugins', file)).isDirectory());
const plugins = allFiles.filter(file =>
fs.statSync(path.resolve(__dirname, 'plugins', file)).isDirectory()
);

return {
testFiles: [
require.resolve('./test_suites/run_pipeline'),
],
testFiles: [require.resolve('./test_suites/run_pipeline')],
services: functionalConfig.get('services'),
pageObjects: functionalConfig.get('pageObjects'),
servers: functionalConfig.get('servers'),
esTestCluster: functionalConfig.get('esTestCluster'),
apps: functionalConfig.get('apps'),
esArchiver: {
directory: path.resolve(__dirname, '../es_archives')
directory: path.resolve(__dirname, '../es_archives'),
},
snapshots: {
directory: path.resolve(__dirname, 'snapshots'),
Expand All @@ -49,7 +50,9 @@ export default async function ({ readConfigFile }) {
...functionalConfig.get('kbnTestServer'),
serverArgs: [
...functionalConfig.get('kbnTestServer.serverArgs'),
...plugins.map(pluginDir => `--plugin-path=${path.resolve(__dirname, 'plugins', pluginDir)}`),
...plugins.map(
pluginDir => `--plugin-path=${path.resolve(__dirname, 'plugins', pluginDir)}`
),
],
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,34 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Legacy } from 'kibana';
import {
ArrayOrItem,
LegacyPluginApi,
LegacyPluginSpec,
LegacyPluginOptions,
} from 'src/legacy/plugin_discovery/types';

export default function (kibana) {
return new kibana.Plugin({
// eslint-disable-next-line import/no-default-export
export default function(kibana: LegacyPluginApi): ArrayOrItem<LegacyPluginSpec> {
const pluginSpec: Partial<LegacyPluginOptions> = {
id: 'kbn_tp_run_pipeline',
uiExports: {
app: {
title: 'Run Pipeline',
description: 'This is a sample plugin to test running pipeline expressions',
main: 'plugins/kbn_tp_run_pipeline/app',
}
main: 'plugins/kbn_tp_run_pipeline/legacy',
},
},

init(server) {
init(server: Legacy.Server) {
// The following lines copy over some configuration variables from Kibana
// to this plugin. This will be needed when embedding visualizations, so that e.g.
// region map is able to get its configuration.
server.injectUiAppVars('kbn_tp_run_pipeline', async () => {
return await server.getInjectedUiAppVars('kibana');
return server.getInjectedUiAppVars('kibana');
});
}
});
},
};
return new kibana.Plugin(pluginSpec);
}

This file was deleted.

This file was deleted.

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

export * from './np_ready';
Loading