diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.md
index 9dbd18ae687b46..ab0273be714022 100644
--- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.md
+++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.md
@@ -18,5 +18,6 @@ export interface IInterpreterRenderHandlers
| [event](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.event.md) | (event: any) => void
| |
| [onDestroy](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.ondestroy.md) | (fn: () => void) => void
| |
| [reload](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.reload.md) | () => void
| |
+| [uiState](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.uistate.md) | PersistedState
| |
| [update](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.update.md) | (params: any) => void
| |
diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.uistate.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.uistate.md
new file mode 100644
index 00000000000000..8d74c8e555fee6
--- /dev/null
+++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.uistate.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [IInterpreterRenderHandlers](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.md) > [uiState](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.uistate.md)
+
+## IInterpreterRenderHandlers.uiState property
+
+Signature:
+
+```typescript
+uiState?: PersistedState;
+```
diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.md
index cbaffa04bae8ff..ccf6271f712b94 100644
--- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.md
+++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.md
@@ -18,5 +18,6 @@ export interface IInterpreterRenderHandlers
| [event](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.event.md) | (event: any) => void
| |
| [onDestroy](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.ondestroy.md) | (fn: () => void) => void
| |
| [reload](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.reload.md) | () => void
| |
+| [uiState](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.uistate.md) | PersistedState
| |
| [update](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.update.md) | (params: any) => void
| |
diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.uistate.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.uistate.md
new file mode 100644
index 00000000000000..b09433c6454adb
--- /dev/null
+++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.uistate.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [IInterpreterRenderHandlers](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.md) > [uiState](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.uistate.md)
+
+## IInterpreterRenderHandlers.uiState property
+
+Signature:
+
+```typescript
+uiState?: PersistedState;
+```
diff --git a/packages/kbn-test/package.json b/packages/kbn-test/package.json
index 4e86ec4bd72e0e..8422c34c9ed08c 100644
--- a/packages/kbn-test/package.json
+++ b/packages/kbn-test/package.json
@@ -11,6 +11,7 @@
},
"devDependencies": {
"@babel/cli": "^7.10.5",
+ "@jest/types": "^26.5.2",
"@kbn/babel-preset": "1.0.0",
"@kbn/dev-utils": "1.0.0",
"@kbn/utils": "1.0.0",
@@ -22,14 +23,18 @@
"diff": "^4.0.1"
},
"dependencies": {
+ "@jest/reporters": "^26.5.2",
"chalk": "^4.1.0",
"dedent": "^0.7.0",
"del": "^5.1.0",
+ "execa": "^4.0.2",
"exit-hook": "^2.2.0",
"getopts": "^2.2.5",
"glob": "^7.1.2",
+ "globby": "^8.0.1",
"joi": "^13.5.2",
"lodash": "^4.17.20",
+ "mustache": "^2.3.2",
"parse-link-header": "^1.0.1",
"rxjs": "^6.5.5",
"strip-ansi": "^6.0.0",
diff --git a/packages/kbn-test/src/index.ts b/packages/kbn-test/src/index.ts
index 50ef521a2d8116..a57b92fbdde25b 100644
--- a/packages/kbn-test/src/index.ts
+++ b/packages/kbn-test/src/index.ts
@@ -55,8 +55,8 @@ export {
export { runFailedTestsReporterCli } from './failed_tests_reporter';
-export { makeJunitReportPath } from './junit_report_path';
-
export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';
export * from './functional_test_runner';
+
+export * from './jest';
diff --git a/packages/kbn-test/src/jest/index.ts b/packages/kbn-test/src/jest/index.ts
new file mode 100644
index 00000000000000..c6d680863d9c4e
--- /dev/null
+++ b/packages/kbn-test/src/jest/index.ts
@@ -0,0 +1,22 @@
+/*
+ * 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 './junit_reporter';
+
+export * from './report_path';
diff --git a/packages/kbn-test/src/jest/integration_tests/__fixtures__/jest.config.js b/packages/kbn-test/src/jest/integration_tests/__fixtures__/jest.config.js
new file mode 100644
index 00000000000000..50016c883d3781
--- /dev/null
+++ b/packages/kbn-test/src/jest/integration_tests/__fixtures__/jest.config.js
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+const { resolve } = require('path');
+const { REPO_ROOT } = require('@kbn/utils');
+
+module.exports = {
+ reporters: [
+ 'default',
+ [
+ `${REPO_ROOT}/packages/kbn-test/target/jest/junit_reporter`,
+ {
+ reportName: 'JUnit Reporter Integration Test',
+ rootDirectory: resolve(
+ REPO_ROOT,
+ 'packages/kbn-test/src/jest/integration_tests/__fixtures__'
+ ),
+ },
+ ],
+ ],
+};
diff --git a/src/dev/jest/integration_tests/__fixtures__/test.js b/packages/kbn-test/src/jest/integration_tests/__fixtures__/test.js
similarity index 89%
rename from src/dev/jest/integration_tests/__fixtures__/test.js
rename to packages/kbn-test/src/jest/integration_tests/__fixtures__/test.js
index fe0c65fd45b745..161012fb3a91c0 100644
--- a/src/dev/jest/integration_tests/__fixtures__/test.js
+++ b/packages/kbn-test/src/jest/integration_tests/__fixtures__/test.js
@@ -17,6 +17,8 @@
* under the License.
*/
-it('fails', () => {
- throw new Error('failure');
+describe('JUnit Reporter', () => {
+ it('fails', () => {
+ throw new Error('failure');
+ });
});
diff --git a/src/dev/jest/integration_tests/junit_reporter.test.js b/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts
similarity index 82%
rename from src/dev/jest/integration_tests/junit_reporter.test.js
rename to packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts
index 3280482a542031..1390c44d84a07d 100644
--- a/src/dev/jest/integration_tests/junit_reporter.test.js
+++ b/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts
@@ -25,27 +25,26 @@ import del from 'del';
import execa from 'execa';
import xml2js from 'xml2js';
import { makeJunitReportPath } from '@kbn/test';
+import { REPO_ROOT } from '@kbn/utils';
const MINUTE = 1000 * 60;
-const ROOT_DIR = resolve(__dirname, '../../../../');
const FIXTURE_DIR = resolve(__dirname, '__fixtures__');
const TARGET_DIR = resolve(FIXTURE_DIR, 'target');
-const XML_PATH = makeJunitReportPath(FIXTURE_DIR, 'Jest Tests');
+const XML_PATH = makeJunitReportPath(FIXTURE_DIR, 'JUnit Reporter Integration Test');
afterAll(async () => {
await del(TARGET_DIR);
});
const parseXml = promisify(xml2js.parseString);
-
it(
'produces a valid junit report for failures',
async () => {
const result = await execa(
- process.execPath,
- ['-r', require.resolve('../../../setup_node_env'), require.resolve('jest/bin/jest')],
+ './node_modules/.bin/jest',
+ ['--config', 'packages/kbn-test/src/jest/integration_tests/__fixtures__/jest.config.js'],
{
- cwd: FIXTURE_DIR,
+ cwd: REPO_ROOT,
env: {
CI: 'true',
},
@@ -57,6 +56,7 @@ it(
await expect(parseXml(readFileSync(XML_PATH, 'utf8'))).resolves.toEqual({
testsuites: {
$: {
+ failures: '1',
name: 'jest',
skipped: '0',
tests: '1',
@@ -67,7 +67,7 @@ it(
{
$: {
failures: '1',
- file: resolve(ROOT_DIR, 'src/dev/jest/integration_tests/__fixtures__/test.js'),
+ file: resolve(FIXTURE_DIR, './test.js'),
name: 'test.js',
skipped: '0',
tests: '1',
@@ -77,8 +77,8 @@ it(
testcase: [
{
$: {
- classname: 'Jest Tests.·',
- name: 'fails',
+ classname: 'JUnit Reporter Integration Test.·',
+ name: 'JUnit Reporter fails',
time: expect.anything(),
},
failure: [expect.stringMatching(/Error: failure\s+at /m)],
diff --git a/src/dev/jest/junit_reporter.js b/packages/kbn-test/src/jest/junit_reporter.ts
similarity index 74%
rename from src/dev/jest/junit_reporter.js
rename to packages/kbn-test/src/jest/junit_reporter.ts
index f33358c081a065..8deb6751bc2686 100644
--- a/src/dev/jest/junit_reporter.js
+++ b/packages/kbn-test/src/jest/junit_reporter.ts
@@ -22,20 +22,31 @@ import { writeFileSync, mkdirSync } from 'fs';
import xmlBuilder from 'xmlbuilder';
-import { escapeCdata, makeJunitReportPath } from '@kbn/test';
+import type { Config } from '@jest/types';
+import { AggregatedResult, Test, BaseReporter } from '@jest/reporters';
-const ROOT_DIR = dirname(require.resolve('../../../package.json'));
+import { escapeCdata } from '../mocha/xml';
+import { makeJunitReportPath } from './report_path';
+
+interface ReporterOptions {
+ reportName?: string;
+ rootDirectory?: string;
+}
/**
* Jest reporter that produces JUnit report when running on CI
* @class JestJUnitReporter
*/
-export default class JestJUnitReporter {
- constructor(globalConfig, options = {}) {
- const { reportName = 'Jest Tests', rootDirectory = ROOT_DIR } = options;
- this._reportName = reportName;
- this._rootDirectory = resolve(rootDirectory);
+// eslint-disable-next-line import/no-default-export
+export default class JestJUnitReporter extends BaseReporter {
+ private _reportName: string;
+ private _rootDirectory: string;
+
+ constructor(globalConfig: Config.GlobalConfig, { rootDirectory, reportName }: ReporterOptions) {
+ super();
+ this._reportName = reportName || 'Jest Tests';
+ this._rootDirectory = rootDirectory ? resolve(rootDirectory) : resolve(__dirname, '../..');
}
/**
@@ -44,7 +55,7 @@ export default class JestJUnitReporter {
* @param {JestResults} results see https://facebook.github.io/jest/docs/en/configuration.html#testresultsprocessor-string
* @return {undefined}
*/
- onRunComplete(contexts, results) {
+ onRunComplete(contexts: Set, results: AggregatedResult): void {
if (!process.env.CI || process.env.DISABLE_JUNIT_REPORTER || !results.testResults.length) {
return;
}
@@ -55,18 +66,19 @@ export default class JestJUnitReporter {
'testsuites',
{ encoding: 'utf-8' },
{},
- { skipNullAttributes: true }
+ { keepNullAttributes: false }
);
- const msToIso = (ms) => (ms ? new Date(ms).toISOString().slice(0, -5) : undefined);
- const msToSec = (ms) => (ms ? (ms / 1000).toFixed(3) : undefined);
+ const msToIso = (ms: number | null | undefined) =>
+ ms ? new Date(ms).toISOString().slice(0, -5) : undefined;
+ const msToSec = (ms: number | null | undefined) => (ms ? (ms / 1000).toFixed(3) : undefined);
root.att({
name: 'jest',
timestamp: msToIso(results.startTime),
time: msToSec(Date.now() - results.startTime),
tests: results.numTotalTests,
- failures: results.numFailingTests,
+ failures: results.numFailedTests,
skipped: results.numPendingTests,
});
diff --git a/packages/kbn-test/src/junit_report_path.ts b/packages/kbn-test/src/jest/report_path.ts
similarity index 93%
rename from packages/kbn-test/src/junit_report_path.ts
rename to packages/kbn-test/src/jest/report_path.ts
index 90405d7a89c024..fe122c349c1931 100644
--- a/packages/kbn-test/src/junit_report_path.ts
+++ b/packages/kbn-test/src/jest/report_path.ts
@@ -18,7 +18,7 @@
*/
import { resolve } from 'path';
-import { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';
+import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix';
export function makeJunitReportPath(rootDirectory: string, reportName: string) {
return resolve(
diff --git a/src/dev/jest/config.integration.js b/src/dev/jest/config.integration.js
index 2fd6bd120d553d..970c00bb68b98b 100644
--- a/src/dev/jest/config.integration.js
+++ b/src/dev/jest/config.integration.js
@@ -31,7 +31,10 @@ export default {
),
reporters: [
'default',
- ['/src/dev/jest/junit_reporter.js', { reportName: 'Jest Integration Tests' }],
+ [
+ '/packages/kbn-test/target/jest/junit_reporter',
+ { reportName: 'Jest Integration Tests' },
+ ],
],
setupFilesAfterEnv: ['/src/dev/jest/setup/after_env.integration.js'],
};
diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js
index 3c556a4f1ba3c1..f582a8f3d44104 100644
--- a/src/dev/jest/config.js
+++ b/src/dev/jest/config.js
@@ -99,5 +99,5 @@ export default {
'/src/plugins/kibana_react/public/util/test_helpers/react_mount_serializer.ts',
'/node_modules/enzyme-to-json/serializer',
],
- reporters: ['default', '/src/dev/jest/junit_reporter.js'],
+ reporters: ['default', '/packages/kbn-test/target/jest/junit_reporter'],
};
diff --git a/src/dev/jest/integration_tests/__fixtures__/package.json b/src/dev/jest/integration_tests/__fixtures__/package.json
deleted file mode 100644
index 1a9a446d524bc4..00000000000000
--- a/src/dev/jest/integration_tests/__fixtures__/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "fixture",
- "jest": {
- "testMatch": [
- "**/test.js"
- ],
- "transform": {
- "^.+\\.js$": "/../../babel_transform.js"
- },
- "reporters": [
- ["/../../junit_reporter.js", {"rootDirectory": "."}]
- ]
- }
-}
diff --git a/src/plugins/expressions/common/expression_renderers/types.ts b/src/plugins/expressions/common/expression_renderers/types.ts
index b760e7b32a7d2b..0ea3d72e756092 100644
--- a/src/plugins/expressions/common/expression_renderers/types.ts
+++ b/src/plugins/expressions/common/expression_renderers/types.ts
@@ -17,6 +17,8 @@
* under the License.
*/
+import { PersistedState } from 'src/plugins/visualizations/public';
+
export interface ExpressionRenderDefinition {
/**
* Technical name of the renderer, used as ID to identify renderer in
@@ -68,4 +70,5 @@ export interface IInterpreterRenderHandlers {
reload: () => void;
update: (params: any) => void;
event: (event: any) => void;
+ uiState?: PersistedState;
}
diff --git a/src/plugins/expressions/public/public.api.md b/src/plugins/expressions/public/public.api.md
index 5c0fd8ab1a5729..763147df6d922d 100644
--- a/src/plugins/expressions/public/public.api.md
+++ b/src/plugins/expressions/public/public.api.md
@@ -11,6 +11,7 @@ import { EnvironmentMode } from '@kbn/config';
import { EventEmitter } from 'events';
import { Observable } from 'rxjs';
import { PackageInfo } from '@kbn/config';
+import { PersistedState } from 'src/plugins/visualizations/public';
import { Plugin as Plugin_2 } from 'src/core/public';
import { PluginInitializerContext as PluginInitializerContext_2 } from 'src/core/public';
import React from 'react';
@@ -883,6 +884,8 @@ export interface IInterpreterRenderHandlers {
// (undocumented)
reload: () => void;
// (undocumented)
+ uiState?: PersistedState;
+ // (undocumented)
update: (params: any) => void;
}
diff --git a/src/plugins/expressions/server/server.api.md b/src/plugins/expressions/server/server.api.md
index d8872ee4160174..8266789664d444 100644
--- a/src/plugins/expressions/server/server.api.md
+++ b/src/plugins/expressions/server/server.api.md
@@ -9,6 +9,7 @@ import { CoreStart } from 'src/core/server';
import { Ensure } from '@kbn/utility-types';
import { EventEmitter } from 'events';
import { Observable } from 'rxjs';
+import { PersistedState } from 'src/plugins/visualizations/public';
import { Plugin as Plugin_2 } from 'src/core/server';
import { PluginInitializerContext } from 'src/core/server';
import { UnwrapPromiseOrReturn } from '@kbn/utility-types';
@@ -717,6 +718,8 @@ export interface IInterpreterRenderHandlers {
// (undocumented)
reload: () => void;
// (undocumented)
+ uiState?: PersistedState;
+ // (undocumented)
update: (params: any) => void;
}
diff --git a/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap b/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap
index dc6571de969f02..a32609c2e3d342 100644
--- a/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap
+++ b/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap
@@ -2,12 +2,9 @@
exports[`interpreter/functions#table returns an object with the correct structure 1`] = `
Object {
- "as": "visualization",
+ "as": "table_vis",
"type": "render",
"value": Object {
- "params": Object {
- "listenOnChange": true,
- },
"visConfig": Object {
"dimensions": Object {
"buckets": Array [],
diff --git a/src/plugins/vis_type_table/public/__snapshots__/to_ast.test.ts.snap b/src/plugins/vis_type_table/public/__snapshots__/to_ast.test.ts.snap
new file mode 100644
index 00000000000000..d2298e6fb3eb57
--- /dev/null
+++ b/src/plugins/vis_type_table/public/__snapshots__/to_ast.test.ts.snap
@@ -0,0 +1,74 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`table vis toExpressionAst function should match snapshot based on params & dimensions 1`] = `
+Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "aggConfigs": Array [
+ "[]",
+ ],
+ "includeFormatHints": Array [
+ false,
+ ],
+ "index": Array [
+ "123",
+ ],
+ "metricsAtAllLevels": Array [
+ false,
+ ],
+ "partialRows": Array [
+ true,
+ ],
+ },
+ "function": "esaggs",
+ "type": "function",
+ },
+ Object {
+ "arguments": Object {
+ "visConfig": Array [
+ "{\\"perPage\\":20,\\"percentageCol\\":\\"Count\\",\\"showMetricsAtAllLevels\\":true,\\"showPartialRows\\":true,\\"showTotal\\":true,\\"sort\\":{\\"columnIndex\\":null,\\"direction\\":null},\\"totalFunc\\":\\"sum\\",\\"dimensions\\":{\\"metrics\\":[{\\"accessor\\":1,\\"format\\":{\\"id\\":\\"number\\"},\\"params\\":{},\\"label\\":\\"Count\\",\\"aggType\\":\\"count\\"}],\\"buckets\\":[{\\"accessor\\":0,\\"format\\":{\\"id\\":\\"date\\",\\"params\\":{\\"pattern\\":\\"YYYY-MM-DD HH:mm\\"}},\\"params\\":{},\\"label\\":\\"order_date per 3 hours\\",\\"aggType\\":\\"date_histogram\\"}]}}",
+ ],
+ },
+ "function": "kibana_table",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+}
+`;
+
+exports[`table vis toExpressionAst function should match snapshot without params 1`] = `
+Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {
+ "aggConfigs": Array [
+ "[]",
+ ],
+ "includeFormatHints": Array [
+ false,
+ ],
+ "index": Array [
+ "123",
+ ],
+ "metricsAtAllLevels": Array [
+ false,
+ ],
+ },
+ "function": "esaggs",
+ "type": "function",
+ },
+ Object {
+ "arguments": Object {
+ "visConfig": Array [
+ "{\\"showLabel\\":false,\\"dimensions\\":{\\"metrics\\":[{\\"accessor\\":1,\\"format\\":{\\"id\\":\\"number\\"},\\"params\\":{},\\"label\\":\\"Count\\",\\"aggType\\":\\"count\\"}],\\"buckets\\":[{\\"accessor\\":0,\\"format\\":{\\"id\\":\\"date\\",\\"params\\":{\\"pattern\\":\\"YYYY-MM-DD HH:mm\\"}},\\"params\\":{},\\"label\\":\\"order_date per 3 hours\\",\\"aggType\\":\\"date_histogram\\"}]}}",
+ ],
+ },
+ "function": "kibana_table",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+}
+`;
diff --git a/src/plugins/vis_type_table/public/index.ts b/src/plugins/vis_type_table/public/index.ts
index 5621fdb0947724..6493c967165dbb 100644
--- a/src/plugins/vis_type_table/public/index.ts
+++ b/src/plugins/vis_type_table/public/index.ts
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-import './index.scss';
import { PluginInitializerContext } from 'kibana/public';
import { TableVisPlugin as Plugin } from './plugin';
diff --git a/src/plugins/vis_type_table/public/_table_vis.scss b/src/plugins/vis_type_table/public/legacy/_table_vis.scss
similarity index 91%
rename from src/plugins/vis_type_table/public/_table_vis.scss
rename to src/plugins/vis_type_table/public/legacy/_table_vis.scss
index 8a36b9818c2a3b..fa12ef9a1cf39e 100644
--- a/src/plugins/vis_type_table/public/_table_vis.scss
+++ b/src/plugins/vis_type_table/public/legacy/_table_vis.scss
@@ -4,8 +4,10 @@
.table-vis {
display: flex;
flex-direction: column;
- flex: 1 0 100%;
+ flex: 1 1 0;
overflow: auto;
+
+ @include euiScrollBar;
}
.table-vis-container {
diff --git a/src/plugins/vis_type_table/public/agg_table/_agg_table.scss b/src/plugins/vis_type_table/public/legacy/agg_table/_agg_table.scss
similarity index 100%
rename from src/plugins/vis_type_table/public/agg_table/_agg_table.scss
rename to src/plugins/vis_type_table/public/legacy/agg_table/_agg_table.scss
diff --git a/src/plugins/vis_type_table/public/agg_table/_index.scss b/src/plugins/vis_type_table/public/legacy/agg_table/_index.scss
similarity index 100%
rename from src/plugins/vis_type_table/public/agg_table/_index.scss
rename to src/plugins/vis_type_table/public/legacy/agg_table/_index.scss
diff --git a/src/plugins/vis_type_table/public/agg_table/agg_table.html b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table.html
similarity index 100%
rename from src/plugins/vis_type_table/public/agg_table/agg_table.html
rename to src/plugins/vis_type_table/public/legacy/agg_table/agg_table.html
diff --git a/src/plugins/vis_type_table/public/agg_table/agg_table.js b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table.js
similarity index 99%
rename from src/plugins/vis_type_table/public/agg_table/agg_table.js
rename to src/plugins/vis_type_table/public/legacy/agg_table/agg_table.js
index 1e98a06c2a6a99..a9ec431e9d940e 100644
--- a/src/plugins/vis_type_table/public/agg_table/agg_table.js
+++ b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table.js
@@ -17,9 +17,9 @@
* under the License.
*/
import _ from 'lodash';
-import { CSV_SEPARATOR_SETTING, CSV_QUOTE_VALUES_SETTING } from '../../../share/public';
+import { CSV_SEPARATOR_SETTING, CSV_QUOTE_VALUES_SETTING } from '../../../../share/public';
import aggTableTemplate from './agg_table.html';
-import { getFormatService } from '../services';
+import { getFormatService } from '../../services';
import { i18n } from '@kbn/i18n';
export function KbnAggTable(config, RecursionHelper) {
diff --git a/src/plugins/vis_type_table/public/agg_table/agg_table.test.js b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table.test.js
similarity index 97%
rename from src/plugins/vis_type_table/public/agg_table/agg_table.test.js
rename to src/plugins/vis_type_table/public/legacy/agg_table/agg_table.test.js
index 29a10151a9418b..c93fb4f8bd5684 100644
--- a/src/plugins/vis_type_table/public/agg_table/agg_table.test.js
+++ b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table.test.js
@@ -24,14 +24,14 @@ import 'angular-mocks';
import sinon from 'sinon';
import { round } from 'lodash';
-import { getFieldFormatsRegistry } from '../../../data/public/test_utils';
-import { coreMock } from '../../../../core/public/mocks';
-import { initAngularBootstrap } from '../../../kibana_legacy/public';
-import { setUiSettings } from '../../../data/public/services';
-import { UI_SETTINGS } from '../../../data/public/';
-import { CSV_SEPARATOR_SETTING, CSV_QUOTE_VALUES_SETTING } from '../../../share/public';
-
-import { setFormatService } from '../services';
+import { getFieldFormatsRegistry } from '../../../../data/public/test_utils';
+import { coreMock } from '../../../../../core/public/mocks';
+import { initAngularBootstrap } from '../../../../kibana_legacy/public';
+import { setUiSettings } from '../../../../data/public/services';
+import { UI_SETTINGS } from '../../../../data/public/';
+import { CSV_SEPARATOR_SETTING, CSV_QUOTE_VALUES_SETTING } from '../../../../share/public';
+
+import { setFormatService } from '../../services';
import { getInnerAngular } from '../get_inner_angular';
import { initTableVisLegacyModule } from '../table_vis_legacy_module';
import { tabifiedData } from './tabified_data';
diff --git a/src/plugins/vis_type_table/public/agg_table/agg_table_group.html b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table_group.html
similarity index 100%
rename from src/plugins/vis_type_table/public/agg_table/agg_table_group.html
rename to src/plugins/vis_type_table/public/legacy/agg_table/agg_table_group.html
diff --git a/src/plugins/vis_type_table/public/agg_table/agg_table_group.js b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table_group.js
similarity index 100%
rename from src/plugins/vis_type_table/public/agg_table/agg_table_group.js
rename to src/plugins/vis_type_table/public/legacy/agg_table/agg_table_group.js
diff --git a/src/plugins/vis_type_table/public/agg_table/agg_table_group.test.js b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table_group.test.js
similarity index 92%
rename from src/plugins/vis_type_table/public/agg_table/agg_table_group.test.js
rename to src/plugins/vis_type_table/public/legacy/agg_table/agg_table_group.test.js
index 04cf624331d819..833f51b446ac18 100644
--- a/src/plugins/vis_type_table/public/agg_table/agg_table_group.test.js
+++ b/src/plugins/vis_type_table/public/legacy/agg_table/agg_table_group.test.js
@@ -22,11 +22,11 @@ import angular from 'angular';
import 'angular-mocks';
import expect from '@kbn/expect';
-import { getFieldFormatsRegistry } from '../../../data/public/test_utils';
-import { coreMock } from '../../../../core/public/mocks';
-import { initAngularBootstrap } from '../../../kibana_legacy/public';
-import { setUiSettings } from '../../../data/public/services';
-import { setFormatService } from '../services';
+import { getFieldFormatsRegistry } from '../../../../data/public/test_utils';
+import { coreMock } from '../../../../../core/public/mocks';
+import { initAngularBootstrap } from '../../../../kibana_legacy/public';
+import { setUiSettings } from '../../../../data/public/services';
+import { setFormatService } from '../../services';
import { getInnerAngular } from '../get_inner_angular';
import { initTableVisLegacyModule } from '../table_vis_legacy_module';
import { tabifiedData } from './tabified_data';
diff --git a/src/plugins/vis_type_table/public/agg_table/tabified_data.js b/src/plugins/vis_type_table/public/legacy/agg_table/tabified_data.js
similarity index 100%
rename from src/plugins/vis_type_table/public/agg_table/tabified_data.js
rename to src/plugins/vis_type_table/public/legacy/agg_table/tabified_data.js
diff --git a/src/plugins/vis_type_table/public/get_inner_angular.ts b/src/plugins/vis_type_table/public/legacy/get_inner_angular.ts
similarity index 98%
rename from src/plugins/vis_type_table/public/get_inner_angular.ts
rename to src/plugins/vis_type_table/public/legacy/get_inner_angular.ts
index 4e4269a1f44f47..f3d88a2a217b3c 100644
--- a/src/plugins/vis_type_table/public/get_inner_angular.ts
+++ b/src/plugins/vis_type_table/public/legacy/get_inner_angular.ts
@@ -33,7 +33,7 @@ import {
PrivateProvider,
watchMultiDecorator,
KbnAccessibleClickProvider,
-} from '../../kibana_legacy/public';
+} from '../../../kibana_legacy/public';
initAngularBootstrap();
diff --git a/src/plugins/vis_type_table/public/index.scss b/src/plugins/vis_type_table/public/legacy/index.scss
similarity index 100%
rename from src/plugins/vis_type_table/public/index.scss
rename to src/plugins/vis_type_table/public/legacy/index.scss
diff --git a/src/plugins/vis_type_table/public/paginated_table/_index.scss b/src/plugins/vis_type_table/public/legacy/paginated_table/_index.scss
similarity index 100%
rename from src/plugins/vis_type_table/public/paginated_table/_index.scss
rename to src/plugins/vis_type_table/public/legacy/paginated_table/_index.scss
diff --git a/src/plugins/vis_type_table/public/paginated_table/_table_cell_filter.scss b/src/plugins/vis_type_table/public/legacy/paginated_table/_table_cell_filter.scss
similarity index 100%
rename from src/plugins/vis_type_table/public/paginated_table/_table_cell_filter.scss
rename to src/plugins/vis_type_table/public/legacy/paginated_table/_table_cell_filter.scss
diff --git a/src/plugins/vis_type_table/public/paginated_table/paginated_table.html b/src/plugins/vis_type_table/public/legacy/paginated_table/paginated_table.html
similarity index 100%
rename from src/plugins/vis_type_table/public/paginated_table/paginated_table.html
rename to src/plugins/vis_type_table/public/legacy/paginated_table/paginated_table.html
diff --git a/src/plugins/vis_type_table/public/paginated_table/paginated_table.js b/src/plugins/vis_type_table/public/legacy/paginated_table/paginated_table.js
similarity index 100%
rename from src/plugins/vis_type_table/public/paginated_table/paginated_table.js
rename to src/plugins/vis_type_table/public/legacy/paginated_table/paginated_table.js
diff --git a/src/plugins/vis_type_table/public/paginated_table/paginated_table.test.ts b/src/plugins/vis_type_table/public/legacy/paginated_table/paginated_table.test.ts
similarity index 98%
rename from src/plugins/vis_type_table/public/paginated_table/paginated_table.test.ts
rename to src/plugins/vis_type_table/public/legacy/paginated_table/paginated_table.test.ts
index de253f26ff9e71..3bc5f79557041a 100644
--- a/src/plugins/vis_type_table/public/paginated_table/paginated_table.test.ts
+++ b/src/plugins/vis_type_table/public/legacy/paginated_table/paginated_table.test.ts
@@ -25,11 +25,7 @@ import 'angular-mocks';
import { getAngularModule } from '../get_inner_angular';
import { initTableVisLegacyModule } from '../table_vis_legacy_module';
-import { coreMock } from '../../../../core/public/mocks';
-
-jest.mock('../../../kibana_legacy/public/angular/angular_config', () => ({
- configureAppAngularModule: () => {},
-}));
+import { coreMock } from '../../../../../core/public/mocks';
interface Sort {
columnIndex: number;
diff --git a/src/plugins/vis_type_table/public/paginated_table/rows.js b/src/plugins/vis_type_table/public/legacy/paginated_table/rows.js
similarity index 91%
rename from src/plugins/vis_type_table/public/paginated_table/rows.js
rename to src/plugins/vis_type_table/public/legacy/paginated_table/rows.js
index d8f01a10c63fa7..54e754adcc1708 100644
--- a/src/plugins/vis_type_table/public/paginated_table/rows.js
+++ b/src/plugins/vis_type_table/public/legacy/paginated_table/rows.js
@@ -44,15 +44,18 @@ export function KbnRows($compile) {
}
$scope.filter({
- data: [
- {
- table: $scope.table,
- row: $scope.rows.findIndex((r) => r === row),
- column: $scope.table.columns.findIndex((c) => c.id === column.id),
- value,
- },
- ],
- negate,
+ name: 'filterBucket',
+ data: {
+ data: [
+ {
+ table: $scope.table,
+ row: $scope.rows.findIndex((r) => r === row),
+ column: $scope.table.columns.findIndex((c) => c.id === column.id),
+ value,
+ },
+ ],
+ negate,
+ },
});
};
diff --git a/src/plugins/vis_type_table/public/paginated_table/table_cell_filter.html b/src/plugins/vis_type_table/public/legacy/paginated_table/table_cell_filter.html
similarity index 100%
rename from src/plugins/vis_type_table/public/paginated_table/table_cell_filter.html
rename to src/plugins/vis_type_table/public/legacy/paginated_table/table_cell_filter.html
diff --git a/src/plugins/vis_type_table/public/table_vis.html b/src/plugins/vis_type_table/public/legacy/table_vis.html
similarity index 96%
rename from src/plugins/vis_type_table/public/table_vis.html
rename to src/plugins/vis_type_table/public/legacy/table_vis.html
index f721b670400d66..c469cd250755cc 100644
--- a/src/plugins/vis_type_table/public/table_vis.html
+++ b/src/plugins/vis_type_table/public/legacy/table_vis.html
@@ -15,7 +15,7 @@
({
- configureAppAngularModule: () => {},
-}));
-
interface TableVisScope extends IScope {
[key: string]: any;
}
@@ -112,10 +107,6 @@ describe('Table Vis - Controller', () => {
coreMock.createSetup()
);
});
- const tableVisTypeDefinition = getTableVisTypeDefinition(
- coreMock.createSetup(),
- coreMock.createPluginInitializerContext()
- );
function getRangeVis(params?: object) {
return ({
diff --git a/src/plugins/vis_type_table/public/table_vis_legacy_module.ts b/src/plugins/vis_type_table/public/legacy/table_vis_legacy_module.ts
similarity index 100%
rename from src/plugins/vis_type_table/public/table_vis_legacy_module.ts
rename to src/plugins/vis_type_table/public/legacy/table_vis_legacy_module.ts
diff --git a/src/plugins/vis_type_table/public/legacy/table_vis_legacy_renderer.tsx b/src/plugins/vis_type_table/public/legacy/table_vis_legacy_renderer.tsx
new file mode 100644
index 00000000000000..ab633bd5137bae
--- /dev/null
+++ b/src/plugins/vis_type_table/public/legacy/table_vis_legacy_renderer.tsx
@@ -0,0 +1,53 @@
+/*
+ * 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 { CoreSetup, PluginInitializerContext } from 'kibana/public';
+import { ExpressionRenderDefinition } from 'src/plugins/expressions';
+import { TablePluginStartDependencies } from '../plugin';
+import { TableVisRenderValue } from '../table_vis_fn';
+import { TableVisLegacyController } from './vis_controller';
+
+const tableVisRegistry = new Map();
+
+export const getTableVisLegacyRenderer: (
+ core: CoreSetup,
+ context: PluginInitializerContext
+) => ExpressionRenderDefinition = (core, context) => ({
+ name: 'table_vis',
+ reuseDomNode: true,
+ render: async (domNode, config, handlers) => {
+ let registeredController = tableVisRegistry.get(domNode);
+
+ if (!registeredController) {
+ const { getTableVisualizationControllerClass } = await import('./vis_controller');
+
+ const Controller = getTableVisualizationControllerClass(core, context);
+ registeredController = new Controller(domNode);
+ tableVisRegistry.set(domNode, registeredController);
+
+ handlers.onDestroy(() => {
+ registeredController?.destroy();
+ tableVisRegistry.delete(domNode);
+ });
+ }
+
+ await registeredController.render(config.visData, config.visConfig, handlers);
+ handlers.done();
+ },
+});
diff --git a/src/plugins/vis_type_table/public/vis_controller.ts b/src/plugins/vis_type_table/public/legacy/vis_controller.ts
similarity index 68%
rename from src/plugins/vis_type_table/public/vis_controller.ts
rename to src/plugins/vis_type_table/public/legacy/vis_controller.ts
index 1781808660260e..eff8e34f3e7785 100644
--- a/src/plugins/vis_type_table/public/vis_controller.ts
+++ b/src/plugins/vis_type_table/public/legacy/vis_controller.ts
@@ -20,35 +20,43 @@ import { CoreSetup, PluginInitializerContext } from 'kibana/public';
import angular, { IModule, auto, IRootScopeService, IScope, ICompileService } from 'angular';
import $ from 'jquery';
-import { VisParams, ExprVis } from '../../visualizations/public';
+import './index.scss';
+
+import { IInterpreterRenderHandlers } from 'src/plugins/expressions';
import { getAngularModule } from './get_inner_angular';
-import { getKibanaLegacy } from './services';
import { initTableVisLegacyModule } from './table_vis_legacy_module';
+// @ts-ignore
+import tableVisTemplate from './table_vis.html';
+import { TablePluginStartDependencies } from '../plugin';
+import { TableVisConfig } from '../types';
+import { TableContext } from '../table_vis_response_handler';
const innerAngularName = 'kibana/table_vis';
+export type TableVisLegacyController = InstanceType<
+ ReturnType
+>;
+
export function getTableVisualizationControllerClass(
- core: CoreSetup,
+ core: CoreSetup,
context: PluginInitializerContext
) {
return class TableVisualizationController {
private tableVisModule: IModule | undefined;
private injector: auto.IInjectorService | undefined;
el: JQuery;
- vis: ExprVis;
$rootScope: IRootScopeService | null = null;
$scope: (IScope & { [key: string]: any }) | undefined;
$compile: ICompileService | undefined;
- constructor(domeElement: Element, vis: ExprVis) {
+ constructor(domeElement: Element) {
this.el = $(domeElement);
- this.vis = vis;
}
getInjector() {
if (!this.injector) {
const mountpoint = document.createElement('div');
- mountpoint.setAttribute('style', 'height: 100%; width: 100%;');
+ mountpoint.className = 'visualization';
this.injector = angular.bootstrap(mountpoint, [innerAngularName]);
this.el.append(mountpoint);
}
@@ -58,14 +66,18 @@ export function getTableVisualizationControllerClass(
async initLocalAngular() {
if (!this.tableVisModule) {
- const [coreStart] = await core.getStartServices();
+ const [coreStart, { kibanaLegacy }] = await core.getStartServices();
this.tableVisModule = getAngularModule(innerAngularName, coreStart, context);
initTableVisLegacyModule(this.tableVisModule);
+ kibanaLegacy.loadFontAwesome();
}
}
- async render(esResponse: object, visParams: VisParams): Promise {
- getKibanaLegacy().loadFontAwesome();
+ async render(
+ esResponse: TableContext,
+ visParams: TableVisConfig,
+ handlers: IInterpreterRenderHandlers
+ ): Promise {
await this.initLocalAngular();
return new Promise(async (resolve, reject) => {
@@ -79,16 +91,6 @@ export function getTableVisualizationControllerClass(
return;
}
- // How things get into this $scope?
- // To inject variables into this $scope there's the following pipeline of stuff to check:
- // - visualize_embeddable => that's what the editor creates to wrap this Angular component
- // - build_pipeline => it serialize all the params into an Angular template compiled on the fly
- // - table_vis_fn => unserialize the params and prepare them for the final React/Angular bridge
- // - visualization_renderer => creates the wrapper component for this controller and passes the params
- //
- // In case some prop is missing check into the top of the chain if they are available and check
- // the list above that it is passing through
- this.$scope.vis = this.vis;
this.$scope.visState = { params: visParams, title: visParams.title };
this.$scope.esResponse = esResponse;
@@ -101,11 +103,10 @@ export function getTableVisualizationControllerClass(
if (!this.$scope && this.$compile) {
this.$scope = this.$rootScope.$new();
- this.$scope.uiState = this.vis.getUiState();
+ this.$scope.uiState = handlers.uiState;
+ this.$scope.filter = handlers.event;
updateScope();
- this.el
- .find('div')
- .append(this.$compile(this.vis.type.visConfig?.template ?? '')(this.$scope));
+ this.el.find('div').append(this.$compile(tableVisTemplate)(this.$scope));
this.$scope.$apply();
} else {
updateScope();
diff --git a/src/plugins/vis_type_table/public/plugin.ts b/src/plugins/vis_type_table/public/plugin.ts
index 28f823df79d919..35ef5fc831cb78 100644
--- a/src/plugins/vis_type_table/public/plugin.ts
+++ b/src/plugins/vis_type_table/public/plugin.ts
@@ -21,10 +21,11 @@ import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public';
import { VisualizationsSetup } from '../../visualizations/public';
import { createTableVisFn } from './table_vis_fn';
-import { getTableVisTypeDefinition } from './table_vis_type';
+import { tableVisTypeDefinition } from './table_vis_type';
import { DataPublicPluginStart } from '../../data/public';
-import { setFormatService, setKibanaLegacy } from './services';
+import { setFormatService } from './services';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
+import { getTableVisLegacyRenderer } from './legacy/table_vis_legacy_renderer';
/** @internal */
export interface TablePluginSetupDependencies {
@@ -39,7 +40,9 @@ export interface TablePluginStartDependencies {
}
/** @internal */
-export class TableVisPlugin implements Plugin, void> {
+export class TableVisPlugin
+ implements
+ Plugin, void, TablePluginSetupDependencies, TablePluginStartDependencies> {
initializerContext: PluginInitializerContext;
createBaseVisualization: any;
@@ -48,17 +51,15 @@ export class TableVisPlugin implements Plugin, void> {
}
public async setup(
- core: CoreSetup,
+ core: CoreSetup,
{ expressions, visualizations }: TablePluginSetupDependencies
) {
expressions.registerFunction(createTableVisFn);
- visualizations.createBaseVisualization(
- getTableVisTypeDefinition(core, this.initializerContext)
- );
+ expressions.registerRenderer(getTableVisLegacyRenderer(core, this.initializerContext));
+ visualizations.createBaseVisualization(tableVisTypeDefinition);
}
- public start(core: CoreStart, { data, kibanaLegacy }: TablePluginStartDependencies) {
+ public start(core: CoreStart, { data }: TablePluginStartDependencies) {
setFormatService(data.fieldFormats);
- setKibanaLegacy(kibanaLegacy);
}
}
diff --git a/src/plugins/vis_type_table/public/services.ts b/src/plugins/vis_type_table/public/services.ts
index b4f996f078f6be..3aaffe75e27f14 100644
--- a/src/plugins/vis_type_table/public/services.ts
+++ b/src/plugins/vis_type_table/public/services.ts
@@ -19,12 +19,7 @@
import { createGetterSetter } from '../../kibana_utils/public';
import { DataPublicPluginStart } from '../../data/public';
-import { KibanaLegacyStart } from '../../kibana_legacy/public';
export const [getFormatService, setFormatService] = createGetterSetter<
DataPublicPluginStart['fieldFormats']
>('table data.fieldFormats');
-
-export const [getKibanaLegacy, setKibanaLegacy] = createGetterSetter(
- 'table kibanaLegacy'
-);
diff --git a/src/plugins/vis_type_table/public/table_vis_fn.ts b/src/plugins/vis_type_table/public/table_vis_fn.ts
index 9739a7a284e6cf..2e446ba4e4fcf0 100644
--- a/src/plugins/vis_type_table/public/table_vis_fn.ts
+++ b/src/plugins/vis_type_table/public/table_vis_fn.ts
@@ -20,6 +20,7 @@
import { i18n } from '@kbn/i18n';
import { tableVisResponseHandler, TableContext } from './table_vis_response_handler';
import { ExpressionFunctionDefinition, KibanaDatatable, Render } from '../../expressions/public';
+import { TableVisConfig } from './types';
export type Input = KibanaDatatable;
@@ -27,23 +28,20 @@ interface Arguments {
visConfig: string | null;
}
-type VisParams = Required;
-
-interface RenderValue {
+export interface TableVisRenderValue {
visData: TableContext;
visType: 'table';
- visConfig: VisParams;
- params: {
- listenOnChange: boolean;
- };
+ visConfig: TableVisConfig;
}
-export const createTableVisFn = (): ExpressionFunctionDefinition<
+export type TableExpressionFunctionDefinition = ExpressionFunctionDefinition<
'kibana_table',
Input,
Arguments,
- Render
-> => ({
+ Render
+>;
+
+export const createTableVisFn = (): TableExpressionFunctionDefinition => ({
name: 'kibana_table',
type: 'render',
inputTypes: ['kibana_datatable'],
@@ -63,14 +61,11 @@ export const createTableVisFn = (): ExpressionFunctionDefinition<
return {
type: 'render',
- as: 'visualization',
+ as: 'table_vis',
value: {
visData: convertedData,
visType: 'table',
visConfig,
- params: {
- listenOnChange: true,
- },
},
};
},
diff --git a/src/plugins/vis_type_table/public/table_vis_type.ts b/src/plugins/vis_type_table/public/table_vis_type.ts
index 95f4f06ee6111c..bfc7abac02895a 100644
--- a/src/plugins/vis_type_table/public/table_vis_type.ts
+++ b/src/plugins/vis_type_table/public/table_vis_type.ts
@@ -16,91 +16,82 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { CoreSetup, PluginInitializerContext } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { AggGroupNames } from '../../data/public';
import { Schemas } from '../../vis_default_editor/public';
import { BaseVisTypeOptions } from '../../visualizations/public';
-import { tableVisResponseHandler } from './table_vis_response_handler';
-// @ts-ignore
-import tableVisTemplate from './table_vis.html';
+
import { TableOptions } from './components/table_vis_options_lazy';
-import { getTableVisualizationControllerClass } from './vis_controller';
import { VIS_EVENT_TO_TRIGGER } from '../../../plugins/visualizations/public';
+import { toExpressionAst } from './to_ast';
+import { TableVisParams } from './types';
-export function getTableVisTypeDefinition(
- core: CoreSetup,
- context: PluginInitializerContext
-): BaseVisTypeOptions {
- return {
- name: 'table',
- title: i18n.translate('visTypeTable.tableVisTitle', {
- defaultMessage: 'Data Table',
- }),
- icon: 'visTable',
- description: i18n.translate('visTypeTable.tableVisDescription', {
- defaultMessage: 'Display values in a table',
- }),
- visualization: getTableVisualizationControllerClass(core, context),
- getSupportedTriggers: () => {
- return [VIS_EVENT_TO_TRIGGER.filter];
- },
- visConfig: {
- defaults: {
- perPage: 10,
- showPartialRows: false,
- showMetricsAtAllLevels: false,
- sort: {
- columnIndex: null,
- direction: null,
- },
- showTotal: false,
- totalFunc: 'sum',
- percentageCol: '',
+export const tableVisTypeDefinition: BaseVisTypeOptions = {
+ name: 'table',
+ title: i18n.translate('visTypeTable.tableVisTitle', {
+ defaultMessage: 'Data Table',
+ }),
+ icon: 'visTable',
+ description: i18n.translate('visTypeTable.tableVisDescription', {
+ defaultMessage: 'Display values in a table',
+ }),
+ getSupportedTriggers: () => {
+ return [VIS_EVENT_TO_TRIGGER.filter];
+ },
+ visConfig: {
+ defaults: {
+ perPage: 10,
+ showPartialRows: false,
+ showMetricsAtAllLevels: false,
+ sort: {
+ columnIndex: null,
+ direction: null,
},
- template: tableVisTemplate,
+ showTotal: false,
+ totalFunc: 'sum',
+ percentageCol: '',
},
- editorConfig: {
- optionsTemplate: TableOptions,
- schemas: new Schemas([
- {
- group: AggGroupNames.Metrics,
- name: 'metric',
- title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.metricTitle', {
- defaultMessage: 'Metric',
- }),
- aggFilter: ['!geo_centroid', '!geo_bounds'],
- aggSettings: {
- top_hits: {
- allowStrings: true,
- },
+ },
+ editorConfig: {
+ optionsTemplate: TableOptions,
+ schemas: new Schemas([
+ {
+ group: AggGroupNames.Metrics,
+ name: 'metric',
+ title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.metricTitle', {
+ defaultMessage: 'Metric',
+ }),
+ aggFilter: ['!geo_centroid', '!geo_bounds'],
+ aggSettings: {
+ top_hits: {
+ allowStrings: true,
},
- min: 1,
- defaults: [{ type: 'count', schema: 'metric' }],
- },
- {
- group: AggGroupNames.Buckets,
- name: 'bucket',
- title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.bucketTitle', {
- defaultMessage: 'Split rows',
- }),
- aggFilter: ['!filter'],
- },
- {
- group: AggGroupNames.Buckets,
- name: 'split',
- title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.splitTitle', {
- defaultMessage: 'Split table',
- }),
- min: 0,
- max: 1,
- aggFilter: ['!filter'],
},
- ]),
- },
- responseHandler: tableVisResponseHandler,
- hierarchicalData: (vis) => {
- return Boolean(vis.params.showPartialRows || vis.params.showMetricsAtAllLevels);
- },
- };
-}
+ min: 1,
+ defaults: [{ type: 'count', schema: 'metric' }],
+ },
+ {
+ group: AggGroupNames.Buckets,
+ name: 'bucket',
+ title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.bucketTitle', {
+ defaultMessage: 'Split rows',
+ }),
+ aggFilter: ['!filter'],
+ },
+ {
+ group: AggGroupNames.Buckets,
+ name: 'split',
+ title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.splitTitle', {
+ defaultMessage: 'Split table',
+ }),
+ min: 0,
+ max: 1,
+ aggFilter: ['!filter'],
+ },
+ ]),
+ },
+ toExpressionAst,
+ hierarchicalData: (vis) => {
+ return Boolean(vis.params.showPartialRows || vis.params.showMetricsAtAllLevels);
+ },
+};
diff --git a/src/plugins/vis_type_table/public/to_ast.test.ts b/src/plugins/vis_type_table/public/to_ast.test.ts
new file mode 100644
index 00000000000000..045b5814944b02
--- /dev/null
+++ b/src/plugins/vis_type_table/public/to_ast.test.ts
@@ -0,0 +1,79 @@
+/*
+ * 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 { Vis } from 'src/plugins/visualizations/public';
+import { toExpressionAst } from './to_ast';
+import { AggTypes, TableVisParams } from './types';
+
+const mockSchemas = {
+ metric: [{ accessor: 1, format: { id: 'number' }, params: {}, label: 'Count', aggType: 'count' }],
+ bucket: [
+ {
+ accessor: 0,
+ format: { id: 'date', params: { pattern: 'YYYY-MM-DD HH:mm' } },
+ params: {},
+ label: 'order_date per 3 hours',
+ aggType: 'date_histogram',
+ },
+ ],
+};
+
+jest.mock('../../visualizations/public', () => ({
+ getVisSchemas: () => mockSchemas,
+}));
+
+describe('table vis toExpressionAst function', () => {
+ let vis: Vis;
+
+ beforeEach(() => {
+ vis = {
+ isHierarchical: () => false,
+ type: {},
+ params: {
+ showLabel: false,
+ },
+ data: {
+ indexPattern: { id: '123' },
+ aggs: {
+ getResponseAggs: () => [],
+ aggs: [],
+ },
+ },
+ } as any;
+ });
+
+ it('should match snapshot without params', () => {
+ const actual = toExpressionAst(vis, {} as any);
+ expect(actual).toMatchSnapshot();
+ });
+
+ it('should match snapshot based on params & dimensions', () => {
+ vis.params = {
+ perPage: 20,
+ percentageCol: 'Count',
+ showMetricsAtAllLevels: true,
+ showPartialRows: true,
+ showTotal: true,
+ sort: { columnIndex: null, direction: null },
+ totalFunc: AggTypes.SUM,
+ };
+ const actual = toExpressionAst(vis, {} as any);
+ expect(actual).toMatchSnapshot();
+ });
+});
diff --git a/src/plugins/vis_type_table/public/to_ast.ts b/src/plugins/vis_type_table/public/to_ast.ts
new file mode 100644
index 00000000000000..449e2dde7f7c96
--- /dev/null
+++ b/src/plugins/vis_type_table/public/to_ast.ts
@@ -0,0 +1,74 @@
+/*
+ * 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 { EsaggsExpressionFunctionDefinition } from '../../data/common/search/expressions';
+import { buildExpression, buildExpressionFunction } from '../../expressions/public';
+import { getVisSchemas, Vis, BuildPipelineParams } from '../../visualizations/public';
+import { TableExpressionFunctionDefinition } from './table_vis_fn';
+import { TableVisConfig, TableVisParams } from './types';
+
+const buildTableVisConfig = (
+ schemas: ReturnType,
+ visParams: TableVisParams
+) => {
+ const visConfig = {} as any;
+ const metrics = schemas.metric;
+ const buckets = schemas.bucket || [];
+ visConfig.dimensions = {
+ metrics,
+ buckets,
+ splitRow: schemas.split_row,
+ splitColumn: schemas.split_column,
+ };
+
+ if (visParams.showPartialRows && !visParams.showMetricsAtAllLevels) {
+ // Handle case where user wants to see partial rows but not metrics at all levels.
+ // This requires calculating how many metrics will come back in the tabified response,
+ // and removing all metrics from the dimensions except the last set.
+ const metricsPerBucket = metrics.length / buckets.length;
+ visConfig.dimensions.metrics.splice(0, metricsPerBucket * buckets.length - metricsPerBucket);
+ }
+ return visConfig;
+};
+
+export const toExpressionAst = (vis: Vis, params: BuildPipelineParams) => {
+ const esaggs = buildExpressionFunction('esaggs', {
+ index: vis.data.indexPattern!.id!,
+ metricsAtAllLevels: vis.isHierarchical(),
+ partialRows: vis.params.showPartialRows,
+ aggConfigs: JSON.stringify(vis.data.aggs!.aggs),
+ includeFormatHints: false,
+ });
+
+ const schemas = getVisSchemas(vis, params);
+
+ const visConfig: TableVisConfig = {
+ ...vis.params,
+ ...buildTableVisConfig(schemas, vis.params),
+ title: vis.title,
+ };
+
+ const table = buildExpressionFunction('kibana_table', {
+ visConfig: JSON.stringify(visConfig),
+ });
+
+ const ast = buildExpression([esaggs, table]);
+
+ return ast.toAst();
+};
diff --git a/src/plugins/vis_type_table/public/types.ts b/src/plugins/vis_type_table/public/types.ts
index 39023d1305cb63..c0a995ad5da699 100644
--- a/src/plugins/vis_type_table/public/types.ts
+++ b/src/plugins/vis_type_table/public/types.ts
@@ -33,7 +33,6 @@ export interface Dimensions {
}
export interface TableVisParams {
- type: 'table';
perPage: number | '';
showPartialRows: boolean;
showMetricsAtAllLevels: boolean;
@@ -44,5 +43,9 @@ export interface TableVisParams {
showTotal: boolean;
totalFunc: AggTypes;
percentageCol: string;
+}
+
+export interface TableVisConfig extends TableVisParams {
+ title: string;
dimensions: Dimensions;
}
diff --git a/src/plugins/visualizations/public/legacy/__snapshots__/build_pipeline.test.ts.snap b/src/plugins/visualizations/public/legacy/__snapshots__/build_pipeline.test.ts.snap
index c0c37e2262f9c6..cbdecd4aac747a 100644
--- a/src/plugins/visualizations/public/legacy/__snapshots__/build_pipeline.test.ts.snap
+++ b/src/plugins/visualizations/public/legacy/__snapshots__/build_pipeline.test.ts.snap
@@ -12,16 +12,6 @@ exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunct
exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles region_map function without buckets 1`] = `"regionmap visConfig='{\\"metric\\":{\\"accessor\\":0,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"}}' "`;
-exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function with showPartialRows=true and showMetricsAtAllLevels=false 1`] = `"kibana_table visConfig='{\\"showMetricsAtAllLevels\\":false,\\"showPartialRows\\":true,\\"dimensions\\":{\\"metrics\\":[{\\"accessor\\":4,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"},{\\"accessor\\":5,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"}],\\"buckets\\":[0,3]}}' "`;
-
-exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function with showPartialRows=true and showMetricsAtAllLevels=true 1`] = `"kibana_table visConfig='{\\"showMetricsAtAllLevels\\":true,\\"showPartialRows\\":true,\\"dimensions\\":{\\"metrics\\":[{\\"accessor\\":1,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"},{\\"accessor\\":2,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"},{\\"accessor\\":4,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"},{\\"accessor\\":5,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"}],\\"buckets\\":[0,3]}}' "`;
-
-exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function with splits 1`] = `"kibana_table visConfig='{\\"foo\\":\\"bar\\",\\"dimensions\\":{\\"metrics\\":[{\\"accessor\\":0,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"}],\\"buckets\\":[],\\"splitRow\\":[1,2]}}' "`;
-
-exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function with splits and buckets 1`] = `"kibana_table visConfig='{\\"foo\\":\\"bar\\",\\"dimensions\\":{\\"metrics\\":[{\\"accessor\\":0,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"},{\\"accessor\\":1,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"}],\\"buckets\\":[3],\\"splitRow\\":[2,4]}}' "`;
-
-exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function without splits or buckets 1`] = `"kibana_table visConfig='{\\"foo\\":\\"bar\\",\\"dimensions\\":{\\"metrics\\":[{\\"accessor\\":0,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"},{\\"accessor\\":1,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"}],\\"buckets\\":[]}}' "`;
-
exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tile_map function 1`] = `"tilemap visConfig='{\\"metric\\":{},\\"dimensions\\":{\\"metric\\":{\\"accessor\\":0,\\"label\\":\\"\\",\\"format\\":{},\\"params\\":{},\\"aggType\\":\\"\\"},\\"geohash\\":1,\\"geocentroid\\":3}}' "`;
exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles vega function 1`] = `"vega spec='this is a test' "`;
diff --git a/src/plugins/visualizations/public/legacy/build_pipeline.test.ts b/src/plugins/visualizations/public/legacy/build_pipeline.test.ts
index a1fea45f517816..c744043ed155b0 100644
--- a/src/plugins/visualizations/public/legacy/build_pipeline.test.ts
+++ b/src/plugins/visualizations/public/legacy/build_pipeline.test.ts
@@ -117,84 +117,6 @@ describe('visualize loader pipeline helpers: build pipeline', () => {
expect(actual).toMatchSnapshot();
});
- describe('handles table function', () => {
- it('without splits or buckets', () => {
- const params = { foo: 'bar' };
- const schemas = {
- ...schemasDef,
- metric: [
- { ...schemaConfig, accessor: 0 },
- { ...schemaConfig, accessor: 1 },
- ],
- };
- const actual = buildPipelineVisFunction.table(params, schemas, uiState);
- expect(actual).toMatchSnapshot();
- });
-
- it('with splits', () => {
- const params = { foo: 'bar' };
- const schemas = {
- ...schemasDef,
- split_row: [1, 2],
- };
- const actual = buildPipelineVisFunction.table(params, schemas, uiState);
- expect(actual).toMatchSnapshot();
- });
-
- it('with splits and buckets', () => {
- const params = { foo: 'bar' };
- const schemas = {
- ...schemasDef,
- metric: [
- { ...schemaConfig, accessor: 0 },
- { ...schemaConfig, accessor: 1 },
- ],
- split_row: [2, 4],
- bucket: [3],
- };
- const actual = buildPipelineVisFunction.table(params, schemas, uiState);
- expect(actual).toMatchSnapshot();
- });
-
- it('with showPartialRows=true and showMetricsAtAllLevels=true', () => {
- const params = {
- showMetricsAtAllLevels: true,
- showPartialRows: true,
- };
- const schemas = {
- ...schemasDef,
- metric: [
- { ...schemaConfig, accessor: 1 },
- { ...schemaConfig, accessor: 2 },
- { ...schemaConfig, accessor: 4 },
- { ...schemaConfig, accessor: 5 },
- ],
- bucket: [0, 3],
- };
- const actual = buildPipelineVisFunction.table(params, schemas, uiState);
- expect(actual).toMatchSnapshot();
- });
-
- it('with showPartialRows=true and showMetricsAtAllLevels=false', () => {
- const params = {
- showMetricsAtAllLevels: false,
- showPartialRows: true,
- };
- const schemas = {
- ...schemasDef,
- metric: [
- { ...schemaConfig, accessor: 1 },
- { ...schemaConfig, accessor: 2 },
- { ...schemaConfig, accessor: 4 },
- { ...schemaConfig, accessor: 5 },
- ],
- bucket: [0, 3],
- };
- const actual = buildPipelineVisFunction.table(params, schemas, uiState);
- expect(actual).toMatchSnapshot();
- });
- });
-
describe('handles region_map function', () => {
it('without buckets', () => {
const params = { metric: {} };
diff --git a/src/plugins/visualizations/public/legacy/build_pipeline.ts b/src/plugins/visualizations/public/legacy/build_pipeline.ts
index 9f6a4d55532928..eb431212166a3a 100644
--- a/src/plugins/visualizations/public/legacy/build_pipeline.ts
+++ b/src/plugins/visualizations/public/legacy/build_pipeline.ts
@@ -39,14 +39,14 @@ export interface SchemaConfig {
export interface Schemas {
metric: SchemaConfig[];
- bucket?: any[];
+ bucket?: SchemaConfig[];
geo_centroid?: any[];
group?: any[];
params?: any[];
radius?: any[];
segment?: any[];
- split_column?: any[];
- split_row?: any[];
+ split_column?: SchemaConfig[];
+ split_row?: SchemaConfig[];
width?: any[];
// catch all for schema name
[key: string]: any[] | undefined;
@@ -267,13 +267,6 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = {
const paramsArray = [paramsJson, uiStateJson].filter((param) => Boolean(param));
return `tsvb ${paramsArray.join(' ')}`;
},
- table: (params, schemas) => {
- const visConfig = {
- ...params,
- ...buildVisConfig.table(schemas, params),
- };
- return `kibana_table ${prepareJson('visConfig', visConfig)}`;
- },
region_map: (params, schemas) => {
const visConfig = {
...params,
@@ -298,26 +291,6 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = {
};
const buildVisConfig: BuildVisConfigFunction = {
- table: (schemas, visParams = {}) => {
- const visConfig = {} as any;
- const metrics = schemas.metric;
- const buckets = schemas.bucket || [];
- visConfig.dimensions = {
- metrics,
- buckets,
- splitRow: schemas.split_row,
- splitColumn: schemas.split_column,
- };
-
- if (visParams.showMetricsAtAllLevels === false && visParams.showPartialRows === true) {
- // Handle case where user wants to see partial rows but not metrics at all levels.
- // This requires calculating how many metrics will come back in the tabified response,
- // and removing all metrics from the dimensions except the last set.
- const metricsPerBucket = metrics.length / buckets.length;
- visConfig.dimensions.metrics.splice(0, metricsPerBucket * buckets.length - metricsPerBucket);
- }
- return visConfig;
- },
region_map: (schemas) => {
const visConfig = {} as any;
visConfig.metric = schemas.metric[0];
diff --git a/x-pack/dev-tools/jest/create_jest_config.js b/x-pack/dev-tools/jest/create_jest_config.js
index eec7b0246d0268..1495d52fceae88 100644
--- a/x-pack/dev-tools/jest/create_jest_config.js
+++ b/x-pack/dev-tools/jest/create_jest_config.js
@@ -72,7 +72,7 @@ export function createJestConfig({ kibanaDirectory, rootDir, xPackKibanaDirector
reporters: [
'default',
[
- `${kibanaDirectory}/src/dev/jest/junit_reporter.js`,
+ `${kibanaDirectory}/packages/kbn-test/target/jest/junit_reporter`,
{
reportName: 'X-Pack Jest Tests',
},
diff --git a/x-pack/test_utils/jest/config.integration.js b/x-pack/test_utils/jest/config.integration.js
index 03917d34ab09ca..16e05ea46e3082 100644
--- a/x-pack/test_utils/jest/config.integration.js
+++ b/x-pack/test_utils/jest/config.integration.js
@@ -19,7 +19,10 @@ export default {
),
reporters: [
'default',
- ['/../src/dev/jest/junit_reporter.js', { reportName: 'Jest Integration Tests' }],
+ [
+ '/../packages/kbn-test/target/jest/junit_reporter',
+ { reportName: 'Jest Integration Tests' },
+ ],
],
setupFilesAfterEnv: ['/../src/dev/jest/setup/after_env.integration.js'],
};
diff --git a/x-pack/test_utils/jest/config.js b/x-pack/test_utils/jest/config.js
index c94fe02d2f4bdb..fcd50717d34419 100644
--- a/x-pack/test_utils/jest/config.js
+++ b/x-pack/test_utils/jest/config.js
@@ -45,5 +45,5 @@ export default {
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.js$', 'packages/kbn-pm/dist/index.js'],
snapshotSerializers: ['/../node_modules/enzyme-to-json/serializer'],
- reporters: ['default', '/../src/dev/jest/junit_reporter.js'],
+ reporters: ['default', '/../packages/kbn-test/target/jest/junit_reporter'],
};
diff --git a/yarn.lock b/yarn.lock
index a58c119ce8956c..eb12df7b50d72f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1567,16 +1567,16 @@
chalk "^2.0.1"
slash "^2.0.0"
-"@jest/console@^26.3.0":
- version "26.3.0"
- resolved "https://registry.yarnpkg.com/@jest/console/-/console-26.3.0.tgz#ed04063efb280c88ba87388b6f16427c0a85c856"
- integrity sha512-/5Pn6sJev0nPUcAdpJHMVIsA8sKizL2ZkcKPE5+dJrCccks7tcM7c9wbgHudBJbxXLoTbqsHkG1Dofoem4F09w==
+"@jest/console@^26.3.0", "@jest/console@^26.5.2":
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/@jest/console/-/console-26.5.2.tgz#94fc4865b1abed7c352b5e21e6c57be4b95604a6"
+ integrity sha512-lJELzKINpF1v74DXHbCRIkQ/+nUV1M+ntj+X1J8LxCgpmJZjfLmhFejiMSbjjD66fayxl5Z06tbs3HMyuik6rw==
dependencies:
- "@jest/types" "^26.3.0"
+ "@jest/types" "^26.5.2"
"@types/node" "*"
chalk "^4.0.0"
- jest-message-util "^26.3.0"
- jest-util "^26.3.0"
+ jest-message-util "^26.5.2"
+ jest-util "^26.5.2"
slash "^3.0.0"
"@jest/core@^26.4.2":
@@ -1653,16 +1653,16 @@
"@jest/types" "^26.3.0"
expect "^26.4.2"
-"@jest/reporters@^26.4.1":
- version "26.4.1"
- resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-26.4.1.tgz#3b4d6faf28650f3965f8b97bc3d114077fb71795"
- integrity sha512-aROTkCLU8++yiRGVxLsuDmZsQEKO6LprlrxtAuzvtpbIFl3eIjgIf3EUxDKgomkS25R9ZzwGEdB5weCcBZlrpQ==
+"@jest/reporters@^26.4.1", "@jest/reporters@^26.5.2":
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-26.5.2.tgz#0f1c900c6af712b46853d9d486c9c0382e4050f6"
+ integrity sha512-zvq6Wvy6MmJq/0QY0YfOPb49CXKSf42wkJbrBPkeypVa8I+XDxijvFuywo6TJBX/ILPrdrlE/FW9vJZh6Rf9vA==
dependencies:
"@bcoe/v8-coverage" "^0.2.3"
- "@jest/console" "^26.3.0"
- "@jest/test-result" "^26.3.0"
- "@jest/transform" "^26.3.0"
- "@jest/types" "^26.3.0"
+ "@jest/console" "^26.5.2"
+ "@jest/test-result" "^26.5.2"
+ "@jest/transform" "^26.5.2"
+ "@jest/types" "^26.5.2"
chalk "^4.0.0"
collect-v8-coverage "^1.0.0"
exit "^0.1.2"
@@ -1673,10 +1673,10 @@
istanbul-lib-report "^3.0.0"
istanbul-lib-source-maps "^4.0.0"
istanbul-reports "^3.0.2"
- jest-haste-map "^26.3.0"
- jest-resolve "^26.4.0"
- jest-util "^26.3.0"
- jest-worker "^26.3.0"
+ jest-haste-map "^26.5.2"
+ jest-resolve "^26.5.2"
+ jest-util "^26.5.2"
+ jest-worker "^26.5.0"
slash "^3.0.0"
source-map "^0.6.0"
string-length "^4.0.1"
@@ -1722,6 +1722,16 @@
"@types/istanbul-lib-coverage" "^2.0.0"
collect-v8-coverage "^1.0.0"
+"@jest/test-result@^26.5.2":
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-26.5.2.tgz#cc1a44cfd4db2ecee3fb0bc4e9fe087aa54b5230"
+ integrity sha512-E/Zp6LURJEGSCWpoMGmCFuuEI1OWuI3hmZwmULV0GsgJBh7u0rwqioxhRU95euUuviqBDN8ruX/vP/4bwYolXw==
+ dependencies:
+ "@jest/console" "^26.5.2"
+ "@jest/types" "^26.5.2"
+ "@types/istanbul-lib-coverage" "^2.0.0"
+ collect-v8-coverage "^1.0.0"
+
"@jest/test-sequencer@^26.4.2":
version "26.4.2"
resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-26.4.2.tgz#58a3760a61eec758a2ce6080201424580d97cbba"
@@ -1733,21 +1743,21 @@
jest-runner "^26.4.2"
jest-runtime "^26.4.2"
-"@jest/transform@^26.0.0", "@jest/transform@^26.3.0":
- version "26.3.0"
- resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-26.3.0.tgz#c393e0e01459da8a8bfc6d2a7c2ece1a13e8ba55"
- integrity sha512-Isj6NB68QorGoFWvcOjlUhpkT56PqNIsXKR7XfvoDlCANn/IANlh8DrKAA2l2JKC3yWSMH5wS0GwuQM20w3b2A==
+"@jest/transform@^26.0.0", "@jest/transform@^26.3.0", "@jest/transform@^26.5.2":
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-26.5.2.tgz#6a0033a1d24316a1c75184d010d864f2c681bef5"
+ integrity sha512-AUNjvexh+APhhmS8S+KboPz+D3pCxPvEAGduffaAJYxIFxGi/ytZQkrqcKDUU0ERBAo5R7087fyOYr2oms1seg==
dependencies:
"@babel/core" "^7.1.0"
- "@jest/types" "^26.3.0"
+ "@jest/types" "^26.5.2"
babel-plugin-istanbul "^6.0.0"
chalk "^4.0.0"
convert-source-map "^1.4.0"
fast-json-stable-stringify "^2.0.0"
graceful-fs "^4.2.4"
- jest-haste-map "^26.3.0"
+ jest-haste-map "^26.5.2"
jest-regex-util "^26.0.0"
- jest-util "^26.3.0"
+ jest-util "^26.5.2"
micromatch "^4.0.2"
pirates "^4.0.1"
slash "^3.0.0"
@@ -1773,10 +1783,10 @@
"@types/yargs" "^15.0.0"
chalk "^3.0.0"
-"@jest/types@^26.3.0":
- version "26.3.0"
- resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.3.0.tgz#97627bf4bdb72c55346eef98e3b3f7ddc4941f71"
- integrity sha512-BDPG23U0qDeAvU4f99haztXwdAg3hz4El95LkAM+tHAqqhiVzRpEGHHU8EDxT/AnxOrA65YjLBwDahdJ9pTLJQ==
+"@jest/types@^26.3.0", "@jest/types@^26.5.2":
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.5.2.tgz#44c24f30c8ee6c7f492ead9ec3f3c62a5289756d"
+ integrity sha512-QDs5d0gYiyetI8q+2xWdkixVQMklReZr4ltw7GFDtb4fuJIBCE6mzj2LnitGqCuAlLap6wPyb8fpoHgwZz5fdg==
dependencies:
"@types/istanbul-lib-coverage" "^2.0.0"
"@types/istanbul-reports" "^3.0.0"
@@ -4871,6 +4881,11 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==
+"@types/stack-utils@^2.0.0":
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff"
+ integrity sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw==
+
"@types/stats-lite@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@types/stats-lite/-/stats-lite-2.2.0.tgz#bc8190bf9dfa1e16b89eaa2b433c99dff0804de9"
@@ -16982,21 +16997,21 @@ jest-get-type@^26.3.0:
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-26.3.0.tgz#e97dc3c3f53c2b406ca7afaed4493b1d099199e0"
integrity sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig==
-jest-haste-map@^26.3.0:
- version "26.3.0"
- resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-26.3.0.tgz#c51a3b40100d53ab777bfdad382d2e7a00e5c726"
- integrity sha512-DHWBpTJgJhLLGwE5Z1ZaqLTYqeODQIZpby0zMBsCU9iRFHYyhklYqP4EiG73j5dkbaAdSZhgB938mL51Q5LeZA==
+jest-haste-map@^26.3.0, jest-haste-map@^26.5.2:
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-26.5.2.tgz#a15008abfc502c18aa56e4919ed8c96304ceb23d"
+ integrity sha512-lJIAVJN3gtO3k4xy+7i2Xjtwh8CfPcH08WYjZpe9xzveDaqGw9fVNCpkYu6M525wKFVkLmyi7ku+DxCAP1lyMA==
dependencies:
- "@jest/types" "^26.3.0"
+ "@jest/types" "^26.5.2"
"@types/graceful-fs" "^4.1.2"
"@types/node" "*"
anymatch "^3.0.3"
fb-watchman "^2.0.0"
graceful-fs "^4.2.4"
jest-regex-util "^26.0.0"
- jest-serializer "^26.3.0"
- jest-util "^26.3.0"
- jest-worker "^26.3.0"
+ jest-serializer "^26.5.0"
+ jest-util "^26.5.2"
+ jest-worker "^26.5.0"
micromatch "^4.0.2"
sane "^4.0.3"
walker "^1.0.7"
@@ -17069,14 +17084,14 @@ jest-message-util@^24.9.0:
slash "^2.0.0"
stack-utils "^1.0.1"
-jest-message-util@^26.3.0:
- version "26.3.0"
- resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-26.3.0.tgz#3bdb538af27bb417f2d4d16557606fd082d5841a"
- integrity sha512-xIavRYqr4/otGOiLxLZGj3ieMmjcNE73Ui+LdSW/Y790j5acqCsAdDiLIbzHCZMpN07JOENRWX5DcU+OQ+TjTA==
+jest-message-util@^26.3.0, jest-message-util@^26.5.2:
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-26.5.2.tgz#6c4c4c46dcfbabb47cd1ba2f6351559729bc11bb"
+ integrity sha512-Ocp9UYZ5Jl15C5PNsoDiGEk14A4NG0zZKknpWdZGoMzJuGAkVt10e97tnEVMYpk7LnQHZOfuK2j/izLBMcuCZw==
dependencies:
"@babel/code-frame" "^7.0.0"
- "@jest/types" "^26.3.0"
- "@types/stack-utils" "^1.0.1"
+ "@jest/types" "^26.5.2"
+ "@types/stack-utils" "^2.0.0"
chalk "^4.0.0"
graceful-fs "^4.2.4"
micromatch "^4.0.2"
@@ -17138,16 +17153,16 @@ jest-resolve@^24.9.0:
jest-pnp-resolver "^1.2.1"
realpath-native "^1.1.0"
-jest-resolve@^26.4.0:
- version "26.4.0"
- resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-26.4.0.tgz#6dc0af7fb93e65b73fec0368ca2b76f3eb59a6d7"
- integrity sha512-bn/JoZTEXRSlEx3+SfgZcJAVuTMOksYq9xe9O6s4Ekg84aKBObEaVXKOEilULRqviSLAYJldnoWV9c07kwtiCg==
+jest-resolve@^26.4.0, jest-resolve@^26.5.2:
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-26.5.2.tgz#0d719144f61944a428657b755a0e5c6af4fc8602"
+ integrity sha512-XsPxojXGRA0CoDD7Vis59ucz2p3cQFU5C+19tz3tLEAlhYKkK77IL0cjYjikY9wXnOaBeEdm1rOgSJjbZWpcZg==
dependencies:
- "@jest/types" "^26.3.0"
+ "@jest/types" "^26.5.2"
chalk "^4.0.0"
graceful-fs "^4.2.4"
jest-pnp-resolver "^1.2.2"
- jest-util "^26.3.0"
+ jest-util "^26.5.2"
read-pkg-up "^7.0.1"
resolve "^1.17.0"
slash "^3.0.0"
@@ -17210,10 +17225,10 @@ jest-runtime@^26.4.2:
strip-bom "^4.0.0"
yargs "^15.3.1"
-jest-serializer@^26.3.0:
- version "26.3.0"
- resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-26.3.0.tgz#1c9d5e1b74d6e5f7e7f9627080fa205d976c33ef"
- integrity sha512-IDRBQBLPlKa4flg77fqg0n/pH87tcRKwe8zxOVTWISxGpPHYkRZ1dXKyh04JOja7gppc60+soKVZ791mruVdow==
+jest-serializer@^26.5.0:
+ version "26.5.0"
+ resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-26.5.0.tgz#f5425cc4c5f6b4b355f854b5f0f23ec6b962bc13"
+ integrity sha512-+h3Gf5CDRlSLdgTv7y0vPIAoLgX/SI7T4v6hy+TEXMgYbv+ztzbg5PSN6mUXAT/hXYHvZRWm+MaObVfqkhCGxA==
dependencies:
"@types/node" "*"
graceful-fs "^4.2.4"
@@ -17297,12 +17312,12 @@ jest-util@^24.0.0:
slash "^2.0.0"
source-map "^0.6.0"
-jest-util@^26.3.0:
- version "26.3.0"
- resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.3.0.tgz#a8974b191df30e2bf523ebbfdbaeb8efca535b3e"
- integrity sha512-4zpn6bwV0+AMFN0IYhH/wnzIQzRaYVrz1A8sYnRnj4UXDXbOVtWmlaZkO9mipFqZ13okIfN87aDoJWB7VH6hcw==
+jest-util@^26.3.0, jest-util@^26.5.2:
+ version "26.5.2"
+ resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.5.2.tgz#8403f75677902cc52a1b2140f568e91f8ed4f4d7"
+ integrity sha512-WTL675bK+GSSAYgS8z9FWdCT2nccO1yTIplNLPlP0OD8tUk/H5IrWKMMRudIQQ0qp8bb4k+1Qa8CxGKq9qnYdg==
dependencies:
- "@jest/types" "^26.3.0"
+ "@jest/types" "^26.5.2"
"@types/node" "*"
chalk "^4.0.0"
graceful-fs "^4.2.4"
@@ -17350,10 +17365,10 @@ jest-worker@^25.4.0:
merge-stream "^2.0.0"
supports-color "^7.0.0"
-jest-worker@^26.2.1, jest-worker@^26.3.0:
- version "26.3.0"
- resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.3.0.tgz#7c8a97e4f4364b4f05ed8bca8ca0c24de091871f"
- integrity sha512-Vmpn2F6IASefL+DVBhPzI2J9/GJUsqzomdeN+P+dK8/jKxbh8R3BtFnx3FIta7wYlPU62cpJMJQo4kuOowcMnw==
+jest-worker@^26.2.1, jest-worker@^26.3.0, jest-worker@^26.5.0:
+ version "26.5.0"
+ resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.5.0.tgz#87deee86dbbc5f98d9919e0dadf2c40e3152fa30"
+ integrity sha512-kTw66Dn4ZX7WpjZ7T/SUDgRhapFRKWmisVAF0Rv4Fu8SLFD7eLbqpLvbxVqYhSgaWa7I+bW7pHnbyfNsH6stug==
dependencies:
"@types/node" "*"
merge-stream "^2.0.0"