Skip to content

Commit

Permalink
Merge branch 'master' into fix_case_push_types
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 12, 2020
2 parents fab0ce6 + b125472 commit 0af5932
Show file tree
Hide file tree
Showing 60 changed files with 667 additions and 410 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export interface IInterpreterRenderHandlers
| [event](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.event.md) | <code>(event: any) =&gt; void</code> | |
| [onDestroy](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.ondestroy.md) | <code>(fn: () =&gt; void) =&gt; void</code> | |
| [reload](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.reload.md) | <code>() =&gt; void</code> | |
| [uiState](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.uistate.md) | <code>PersistedState</code> | |
| [update](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.update.md) | <code>(params: any) =&gt; void</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [IInterpreterRenderHandlers](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.md) &gt; [uiState](./kibana-plugin-plugins-expressions-public.iinterpreterrenderhandlers.uistate.md)

## IInterpreterRenderHandlers.uiState property

<b>Signature:</b>

```typescript
uiState?: PersistedState;
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export interface IInterpreterRenderHandlers
| [event](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.event.md) | <code>(event: any) =&gt; void</code> | |
| [onDestroy](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.ondestroy.md) | <code>(fn: () =&gt; void) =&gt; void</code> | |
| [reload](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.reload.md) | <code>() =&gt; void</code> | |
| [uiState](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.uistate.md) | <code>PersistedState</code> | |
| [update](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.update.md) | <code>(params: any) =&gt; void</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) &gt; [IInterpreterRenderHandlers](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.md) &gt; [uiState](./kibana-plugin-plugins-expressions-server.iinterpreterrenderhandlers.uistate.md)

## IInterpreterRenderHandlers.uiState property

<b>Signature:</b>

```typescript
uiState?: PersistedState;
```
5 changes: 5 additions & 0 deletions packages/kbn-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
22 changes: 22 additions & 0 deletions packages/kbn-test/src/jest/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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__'
),
},
],
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

it('fails', () => {
throw new Error('failure');
describe('JUnit Reporter', () => {
it('fails', () => {
throw new Error('failure');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand All @@ -57,6 +56,7 @@ it(
await expect(parseXml(readFileSync(XML_PATH, 'utf8'))).resolves.toEqual({
testsuites: {
$: {
failures: '1',
name: 'jest',
skipped: '0',
tests: '1',
Expand All @@ -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',
Expand All @@ -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)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, '../..');
}

/**
Expand All @@ -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<Test['context']>, results: AggregatedResult): void {
if (!process.env.CI || process.env.DISABLE_JUNIT_REPORTER || !results.testResults.length) {
return;
}
Expand All @@ -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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion src/dev/jest/config.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export default {
),
reporters: [
'default',
['<rootDir>/src/dev/jest/junit_reporter.js', { reportName: 'Jest Integration Tests' }],
[
'<rootDir>/packages/kbn-test/target/jest/junit_reporter',
{ reportName: 'Jest Integration Tests' },
],
],
setupFilesAfterEnv: ['<rootDir>/src/dev/jest/setup/after_env.integration.js'],
};
2 changes: 1 addition & 1 deletion src/dev/jest/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ export default {
'<rootDir>/src/plugins/kibana_react/public/util/test_helpers/react_mount_serializer.ts',
'<rootDir>/node_modules/enzyme-to-json/serializer',
],
reporters: ['default', '<rootDir>/src/dev/jest/junit_reporter.js'],
reporters: ['default', '<rootDir>/packages/kbn-test/target/jest/junit_reporter'],
};
14 changes: 0 additions & 14 deletions src/dev/jest/integration_tests/__fixtures__/package.json

This file was deleted.

3 changes: 3 additions & 0 deletions src/plugins/expressions/common/expression_renderers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import { PersistedState } from 'src/plugins/visualizations/public';

export interface ExpressionRenderDefinition<Config = unknown> {
/**
* Technical name of the renderer, used as ID to identify renderer in
Expand Down Expand Up @@ -68,4 +70,5 @@ export interface IInterpreterRenderHandlers {
reload: () => void;
update: (params: any) => void;
event: (event: any) => void;
uiState?: PersistedState;
}
3 changes: 3 additions & 0 deletions src/plugins/expressions/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -883,6 +884,8 @@ export interface IInterpreterRenderHandlers {
// (undocumented)
reload: () => void;
// (undocumented)
uiState?: PersistedState;
// (undocumented)
update: (params: any) => void;
}

Expand Down
3 changes: 3 additions & 0 deletions src/plugins/expressions/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -717,6 +718,8 @@ export interface IInterpreterRenderHandlers {
// (undocumented)
reload: () => void;
// (undocumented)
uiState?: PersistedState;
// (undocumented)
update: (params: any) => void;
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0af5932

Please sign in to comment.