* chore(NA): merge and solve conflicts with 7.x branch * docs(NA): fix docs build with page headers.
This commit is contained in:
parent
7bbc916fa3
commit
4213441df7
|
@ -15,4 +15,6 @@ include::core/development-modules.asciidoc[]
|
||||||
|
|
||||||
include::core/development-elasticsearch.asciidoc[]
|
include::core/development-elasticsearch.asciidoc[]
|
||||||
|
|
||||||
|
include::core/development-unit-tests.asciidoc[]
|
||||||
|
|
||||||
include::core/development-functional-tests.asciidoc[]
|
include::core/development-functional-tests.asciidoc[]
|
||||||
|
|
82
docs/development/core/development-unit-tests.asciidoc
Normal file
82
docs/development/core/development-unit-tests.asciidoc
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
[[development-unit-tests]]
|
||||||
|
=== Unit Testing
|
||||||
|
|
||||||
|
We use unit tests to make sure that individual software units of {kib} perform as they were designed to.
|
||||||
|
|
||||||
|
[float]
|
||||||
|
=== Current Frameworks
|
||||||
|
|
||||||
|
{kib} is migrating unit testing from `Mocha` to `Jest`. Legacy unit tests still exist in `Mocha` but all new unit tests should be written in `Jest`.
|
||||||
|
|
||||||
|
[float]
|
||||||
|
==== Mocha (legacy)
|
||||||
|
|
||||||
|
Mocha tests are contained in `__tests__` directories.
|
||||||
|
|
||||||
|
*Running Mocha Unit Tests*
|
||||||
|
|
||||||
|
["source","shell"]
|
||||||
|
-----------
|
||||||
|
yarn test:mocha
|
||||||
|
-----------
|
||||||
|
|
||||||
|
[float]
|
||||||
|
==== Jest
|
||||||
|
Jest tests are stored in the same directory as source code files with the `.test.{js,ts,tsx}` suffix.
|
||||||
|
|
||||||
|
*Running Jest Unit Tests*
|
||||||
|
|
||||||
|
["source","shell"]
|
||||||
|
-----------
|
||||||
|
yarn test:jest
|
||||||
|
-----------
|
||||||
|
|
||||||
|
[float]
|
||||||
|
===== Writing Jest Unit Tests
|
||||||
|
|
||||||
|
In order to write those tests there are two main things you need to be aware of.
|
||||||
|
The first one is the different between `jest.mock` and `jest.doMock`
|
||||||
|
and the second one our `jest mocks file pattern`. As we are running `js` and `ts`
|
||||||
|
test files with `babel-jest` both techniques are needed
|
||||||
|
specially for the tests implemented on Typescript in order to benefit from the
|
||||||
|
auto-inference types feature.
|
||||||
|
|
||||||
|
[float]
|
||||||
|
===== Jest.mock vs Jest.doMock
|
||||||
|
|
||||||
|
Both methods are essentially the same on their roots however the `jest.mock`
|
||||||
|
calls will get hoisted to the top of the file and can only reference variables
|
||||||
|
prefixed with `mock`. On the other hand, `jest.doMock` won't be hoisted and can
|
||||||
|
reference pretty much any variable we want, however we have to assure those referenced
|
||||||
|
variables are instantiated at the time we need them which lead us to the next
|
||||||
|
section where we'll talk about our jest mock files pattern.
|
||||||
|
|
||||||
|
[float]
|
||||||
|
===== Jest Mock Files Pattern
|
||||||
|
|
||||||
|
Specially on typescript it is pretty common to have in unit tests
|
||||||
|
`jest.doMock` calls which reference for example imported types. Any error
|
||||||
|
will thrown from doing that however the test will fail. The reason behind that
|
||||||
|
is because despite the `jest.doMock` isn't being hoisted by `babel-jest` the
|
||||||
|
import with the types we are referencing will be hoisted to the top and at the
|
||||||
|
time we'll call the function that variable would not be defined.
|
||||||
|
|
||||||
|
In order to prevent that we develop a protocol that should be followed:
|
||||||
|
|
||||||
|
- Each module could provide a standard mock in `mymodule.mock.ts` in case
|
||||||
|
there are other tests that could benefit from using definitions here.
|
||||||
|
This file would not have any `jest.mock` calls, just dummy objects.
|
||||||
|
|
||||||
|
- Each test defines its mocks in `mymodule.test.mocks.ts`. This file
|
||||||
|
could import relevant mocks from the generalised module's mocks
|
||||||
|
file `(*.mock.ts)` and call `jest.mock` for each of them. If there is
|
||||||
|
any relevant dummy mock objects to generalise (and to be used by
|
||||||
|
other tests), the dummy objects could be defined directly on this file.
|
||||||
|
|
||||||
|
- Each test would import its mocks from the test mocks
|
||||||
|
file mymodule.test.mocks.ts. `mymodule.test.ts` has an import
|
||||||
|
like: `import * as Mocks from './mymodule.test.mocks'`,
|
||||||
|
`import { mockX } from './mymodule.test.mocks'`
|
||||||
|
or just `import './mymodule.test.mocks'` if there isn't anything
|
||||||
|
exported to be used.
|
||||||
|
|
39
package.json
39
package.json
|
@ -93,6 +93,9 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@babel/core": "^7.3.4",
|
||||||
|
"@babel/polyfill": "^7.2.5",
|
||||||
|
"@babel/register": "^7.0.0",
|
||||||
"@elastic/datemath": "5.0.2",
|
"@elastic/datemath": "5.0.2",
|
||||||
"@elastic/eui": "9.4.2",
|
"@elastic/eui": "9.4.2",
|
||||||
"@elastic/filesaver": "1.1.2",
|
"@elastic/filesaver": "1.1.2",
|
||||||
|
@ -120,10 +123,7 @@
|
||||||
"angular-sanitize": "1.6.5",
|
"angular-sanitize": "1.6.5",
|
||||||
"angular-sortable-view": "0.0.15",
|
"angular-sortable-view": "0.0.15",
|
||||||
"autoprefixer": "^9.1.0",
|
"autoprefixer": "^9.1.0",
|
||||||
"babel-core": "6.26.3",
|
"babel-loader": "8.0.5",
|
||||||
"babel-loader": "7.1.5",
|
|
||||||
"babel-polyfill": "6.26.0",
|
|
||||||
"babel-register": "6.26.0",
|
|
||||||
"bluebird": "3.5.3",
|
"bluebird": "3.5.3",
|
||||||
"boom": "^7.2.0",
|
"boom": "^7.2.0",
|
||||||
"brace": "0.11.1",
|
"brace": "0.11.1",
|
||||||
|
@ -260,7 +260,7 @@
|
||||||
"@octokit/rest": "^15.10.0",
|
"@octokit/rest": "^15.10.0",
|
||||||
"@types/angular": "1.6.50",
|
"@types/angular": "1.6.50",
|
||||||
"@types/angular-mocks": "^1.7.0",
|
"@types/angular-mocks": "^1.7.0",
|
||||||
"@types/babel-core": "^6.25.5",
|
"@types/babel__core": "^7.1.0",
|
||||||
"@types/bluebird": "^3.1.1",
|
"@types/bluebird": "^3.1.1",
|
||||||
"@types/boom": "^7.2.0",
|
"@types/boom": "^7.2.0",
|
||||||
"@types/chance": "^1.0.0",
|
"@types/chance": "^1.0.0",
|
||||||
|
@ -272,7 +272,7 @@
|
||||||
"@types/delete-empty": "^2.0.0",
|
"@types/delete-empty": "^2.0.0",
|
||||||
"@types/elasticsearch": "^5.0.30",
|
"@types/elasticsearch": "^5.0.30",
|
||||||
"@types/enzyme": "^3.1.12",
|
"@types/enzyme": "^3.1.12",
|
||||||
"@types/eslint": "^4.16.2",
|
"@types/eslint": "^4.16.6",
|
||||||
"@types/execa": "^0.9.0",
|
"@types/execa": "^0.9.0",
|
||||||
"@types/fetch-mock": "7.2.1",
|
"@types/fetch-mock": "7.2.1",
|
||||||
"@types/getopts": "^2.0.0",
|
"@types/getopts": "^2.0.0",
|
||||||
|
@ -317,8 +317,8 @@
|
||||||
"@types/zen-observable": "^0.8.0",
|
"@types/zen-observable": "^0.8.0",
|
||||||
"angular-mocks": "1.4.7",
|
"angular-mocks": "1.4.7",
|
||||||
"archiver": "^3.0.0",
|
"archiver": "^3.0.0",
|
||||||
"babel-eslint": "^9.0.0",
|
"babel-eslint": "^10.0.1",
|
||||||
"babel-jest": "^23.6.0",
|
"babel-jest": "^24.1.0",
|
||||||
"backport": "4.4.1",
|
"backport": "4.4.1",
|
||||||
"chai": "3.5.0",
|
"chai": "3.5.0",
|
||||||
"chance": "1.0.10",
|
"chance": "1.0.10",
|
||||||
|
@ -332,17 +332,17 @@
|
||||||
"enzyme-adapter-react-16": "^1.9.0",
|
"enzyme-adapter-react-16": "^1.9.0",
|
||||||
"enzyme-adapter-utils": "^1.10.0",
|
"enzyme-adapter-utils": "^1.10.0",
|
||||||
"enzyme-to-json": "^3.3.4",
|
"enzyme-to-json": "^3.3.4",
|
||||||
"eslint": "^5.6.0",
|
"eslint": "^5.15.1",
|
||||||
"eslint-config-prettier": "^3.1.0",
|
"eslint-config-prettier": "^4.1.0",
|
||||||
"eslint-plugin-babel": "^5.2.0",
|
"eslint-plugin-babel": "^5.3.0",
|
||||||
"eslint-plugin-import": "^2.14.0",
|
"eslint-plugin-import": "^2.16.0",
|
||||||
"eslint-plugin-jest": "^21.26.2",
|
"eslint-plugin-jest": "^22.3.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.1.2",
|
"eslint-plugin-jsx-a11y": "^6.2.1",
|
||||||
"eslint-plugin-mocha": "^5.2.0",
|
"eslint-plugin-mocha": "^5.3.0",
|
||||||
"eslint-plugin-no-unsanitized": "^3.0.2",
|
"eslint-plugin-no-unsanitized": "^3.0.2",
|
||||||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||||
"eslint-plugin-prettier": "^2.6.2",
|
"eslint-plugin-prettier": "^3.0.1",
|
||||||
"eslint-plugin-react": "^7.11.1",
|
"eslint-plugin-react": "^7.12.4",
|
||||||
"faker": "1.1.0",
|
"faker": "1.1.0",
|
||||||
"fetch-mock": "7.3.0",
|
"fetch-mock": "7.3.0",
|
||||||
"geckodriver": "1.12.2",
|
"geckodriver": "1.12.2",
|
||||||
|
@ -353,7 +353,7 @@
|
||||||
"grunt-karma": "2.0.0",
|
"grunt-karma": "2.0.0",
|
||||||
"grunt-peg": "^2.0.1",
|
"grunt-peg": "^2.0.1",
|
||||||
"grunt-run": "0.7.0",
|
"grunt-run": "0.7.0",
|
||||||
"gulp-babel": "^7.0.1",
|
"gulp-babel": "^8.0.0",
|
||||||
"gulp-sourcemaps": "2.6.4",
|
"gulp-sourcemaps": "2.6.4",
|
||||||
"has-ansi": "^3.0.0",
|
"has-ansi": "^3.0.0",
|
||||||
"image-diff": "1.6.0",
|
"image-diff": "1.6.0",
|
||||||
|
@ -399,9 +399,6 @@
|
||||||
"supertest": "^3.1.0",
|
"supertest": "^3.1.0",
|
||||||
"supertest-as-promised": "^4.0.2",
|
"supertest-as-promised": "^4.0.2",
|
||||||
"tree-kill": "^1.1.0",
|
"tree-kill": "^1.1.0",
|
||||||
"ts-jest": "^23.1.4",
|
|
||||||
"ts-loader": "^5.2.2",
|
|
||||||
"ts-node": "^7.0.1",
|
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"tslint-config-prettier": "^1.15.0",
|
"tslint-config-prettier": "^1.15.0",
|
||||||
"tslint-microsoft-contrib": "^6.0.0",
|
"tslint-microsoft-contrib": "^6.0.0",
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
{
|
{
|
||||||
"presets": [["env", {
|
"presets": [
|
||||||
"targets": {
|
["@babel/preset-env", {
|
||||||
"node": "current",
|
"targets": {
|
||||||
"browsers": [
|
"node": "current",
|
||||||
"last 2 versions",
|
"browsers": [
|
||||||
"> 5%",
|
"last 2 versions",
|
||||||
"Safari 7",
|
"> 5%",
|
||||||
]
|
"Safari 7"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}]],
|
]
|
||||||
|
],
|
||||||
"plugins": ["add-module-exports"]
|
"plugins": ["add-module-exports"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
"kbn:watch": "yarn build --watch"
|
"kbn:watch": "yarn build --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.26.0",
|
"@babel/cli": "^7.2.3",
|
||||||
"babel-plugin-add-module-exports": "^0.2.1",
|
"@babel/preset-env": "^7.3.4",
|
||||||
"babel-preset-env": "^1.7.0",
|
"babel-plugin-add-module-exports": "^1.0.0",
|
||||||
"moment": "^2.13.0"
|
"moment": "^2.13.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/elastic/eslint-config-kibana#readme",
|
"homepage": "https://github.com/elastic/eslint-config-kibana#readme",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"babel-eslint": "^9.0.0",
|
"babel-eslint": "^10.0.1",
|
||||||
"eslint": "^5.6.0",
|
"eslint": "^5.14.1",
|
||||||
"eslint-plugin-babel": "^5.2.0",
|
"eslint-plugin-babel": "^5.3.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.1.2",
|
"eslint-plugin-jsx-a11y": "^6.2.1",
|
||||||
"eslint-plugin-import": "^2.14.0",
|
"eslint-plugin-import": "^2.16.0",
|
||||||
"eslint-plugin-jest": "^21.22.1",
|
"eslint-plugin-jest": "^22.3.0",
|
||||||
"eslint-plugin-mocha": "^5.2.0",
|
"eslint-plugin-mocha": "^5.3.0",
|
||||||
"eslint-plugin-no-unsanitized": "^3.0.2",
|
"eslint-plugin-no-unsanitized": "^3.0.2",
|
||||||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||||
"eslint-plugin-react": "^7.11.1"
|
"eslint-plugin-react": "^7.12.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"kbn:watch": "yarn build --watch"
|
"kbn:watch": "yarn build --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.26.0"
|
"@babel/cli": "^7.2.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kbn/babel-preset": "1.0.0",
|
"@kbn/babel-preset": "1.0.0",
|
||||||
|
|
|
@ -19,20 +19,33 @@
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
presets: [
|
presets: [
|
||||||
require.resolve('babel-preset-react'),
|
require.resolve('@babel/preset-typescript'),
|
||||||
|
require.resolve('@babel/preset-react')
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
require.resolve('babel-plugin-add-module-exports'),
|
require.resolve('babel-plugin-add-module-exports'),
|
||||||
// stage 3
|
|
||||||
require.resolve('babel-plugin-transform-async-generator-functions'),
|
|
||||||
require.resolve('babel-plugin-transform-object-rest-spread'),
|
|
||||||
|
|
||||||
// the class properties proposal was merged with the private fields proposal
|
// The class properties proposal was merged with the private fields proposal
|
||||||
// into the "class fields" proposal. Babel doesn't support this combined
|
// into the "class fields" proposal. Babel doesn't support this combined
|
||||||
// proposal yet, which includes private field, so this transform is
|
// proposal yet, which includes private field, so this transform is
|
||||||
// TECHNICALLY stage 2, but for all intents and purposes it's stage 3
|
// TECHNICALLY stage 2, but for all intents and purposes it's stage 3
|
||||||
//
|
//
|
||||||
// See https://github.com/babel/proposals/issues/12 for progress
|
// See https://github.com/babel/proposals/issues/12 for progress
|
||||||
require.resolve('babel-plugin-transform-class-properties'),
|
require.resolve('@babel/plugin-proposal-class-properties'),
|
||||||
],
|
],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
// Babel 7 don't support the namespace feature on typescript code.
|
||||||
|
// With namespaces only used for type declarations, we can securely
|
||||||
|
// strip them off for babel on x-pack infra plugin
|
||||||
|
//
|
||||||
|
// See https://github.com/babel/babel/issues/8244#issuecomment-466548733
|
||||||
|
test: /x-pack[\/\\]plugins[\/\\]infra[\/\\].*[\/\\]graphql/,
|
||||||
|
plugins: [
|
||||||
|
[
|
||||||
|
require.resolve('babel-plugin-typescript-strip-namespaces'),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
presets: [
|
|
||||||
require.resolve('@babel/preset-react'),
|
|
||||||
require.resolve('@babel/preset-typescript'),
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
require.resolve('babel7-plugin-add-module-exports'),
|
|
||||||
// stage 3
|
|
||||||
require.resolve('@babel/plugin-proposal-async-generator-functions'),
|
|
||||||
require.resolve('@babel/plugin-proposal-object-rest-spread'),
|
|
||||||
|
|
||||||
// the class properties proposal was merged with the private fields proposal
|
|
||||||
// into the "class fields" proposal. Babel doesn't support this combined
|
|
||||||
// proposal yet, which includes private field, so this transform is
|
|
||||||
// TECHNICALLY stage 2, but for all intents and purposes it's stage 3
|
|
||||||
//
|
|
||||||
// See https://github.com/babel/proposals/issues/12 for progress
|
|
||||||
require.resolve('@babel/plugin-proposal-class-properties'),
|
|
||||||
],
|
|
||||||
};
|
|
|
@ -17,34 +17,37 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = () => {
|
||||||
presets: [
|
return {
|
||||||
[
|
presets: [
|
||||||
require.resolve('babel-preset-env'),
|
[
|
||||||
{
|
require.resolve('@babel/preset-env'),
|
||||||
targets: {
|
{
|
||||||
// only applies the necessary transformations based on the
|
targets: {
|
||||||
// current node.js processes version. For example: running
|
// only applies the necessary transformations based on the
|
||||||
// `nvm install 8 && node ./src/cli` will run kibana in node
|
// current node.js processes version. For example: running
|
||||||
// version 8 and babel will stop transpiling async/await
|
// `nvm install 8 && node ./src/cli` will run kibana in node
|
||||||
// because they are supported in the "current" version of node
|
// version 8 and babel will stop transpiling async/await
|
||||||
node: 'current',
|
// because they are supported in the "current" version of node
|
||||||
},
|
node: 'current',
|
||||||
|
},
|
||||||
|
|
||||||
// replaces `import "babel-polyfill"` with a list of require statements
|
// replaces `import "@babel/polyfill"` with a list of require statements
|
||||||
// for just the polyfills that the target versions don't already supply
|
// for just the polyfills that the target versions don't already supply
|
||||||
// on their own
|
// on their own
|
||||||
useBuiltIns: true,
|
useBuiltIns: 'entry',
|
||||||
},
|
modules: 'cjs'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
require('./common_preset'),
|
||||||
],
|
],
|
||||||
require('./common_preset'),
|
plugins: [
|
||||||
],
|
[
|
||||||
plugins: [
|
require.resolve('babel-plugin-transform-define'),
|
||||||
[
|
{
|
||||||
require.resolve('babel-plugin-transform-define'),
|
'global.__BUILT_WITH_BABEL__': 'true'
|
||||||
{
|
}
|
||||||
'global.__BUILT_WITH_BABEL__': 'true'
|
]
|
||||||
}
|
|
||||||
]
|
]
|
||||||
]
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = () => ({
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
require.resolve('@babel/preset-env'),
|
|
||||||
{
|
|
||||||
targets: {
|
|
||||||
// only applies the necessary transformations based on the
|
|
||||||
// current node.js processes version. For example: running
|
|
||||||
// `nvm install 8 && node ./src/cli` will run kibana in node
|
|
||||||
// version 8 and babel will stop transpiling async/await
|
|
||||||
// because they are supported in the "current" version of node
|
|
||||||
node: 'current',
|
|
||||||
},
|
|
||||||
|
|
||||||
// replaces `import "babel-polyfill"` with a list of require statements
|
|
||||||
// for just the polyfills that the target versions don't already supply
|
|
||||||
// on their own
|
|
||||||
useBuiltIns: 'entry',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
require('./common_preset_7'),
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
[
|
|
||||||
require.resolve('babel-plugin-transform-define'),
|
|
||||||
{
|
|
||||||
'global.__BUILT_WITH_BABEL__': 'true'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
});
|
|
|
@ -4,20 +4,12 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.3.4",
|
|
||||||
"@babel/plugin-proposal-async-generator-functions": "^7.2.0",
|
|
||||||
"@babel/plugin-proposal-class-properties": "^7.3.4",
|
"@babel/plugin-proposal-class-properties": "^7.3.4",
|
||||||
"@babel/plugin-proposal-object-rest-spread": "^7.3.4",
|
"@babel/preset-react":"^7.0.0",
|
||||||
"@babel/preset-env": "^7.3.4",
|
"@babel/preset-env": "^7.3.4",
|
||||||
"@babel/preset-react": "^7.0.0",
|
|
||||||
"@babel/preset-typescript": "^7.3.3",
|
"@babel/preset-typescript": "^7.3.3",
|
||||||
"babel-plugin-add-module-exports": "^0.2.1",
|
"babel-plugin-add-module-exports": "^1.0.0",
|
||||||
"babel-plugin-transform-async-generator-functions": "^6.24.1",
|
|
||||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
||||||
"babel-plugin-transform-define": "^1.3.1",
|
"babel-plugin-transform-define": "^1.3.1",
|
||||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
"babel-plugin-typescript-strip-namespaces": "^1.1.1"
|
||||||
"babel-preset-env": "^1.7.0",
|
|
||||||
"babel-preset-react": "^6.24.1",
|
|
||||||
"babel7-plugin-add-module-exports": "npm:babel-plugin-add-module-exports@^1.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,21 +17,24 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = () => {
|
||||||
presets: [
|
return {
|
||||||
[
|
presets: [
|
||||||
require.resolve('babel-preset-env'),
|
[
|
||||||
{
|
require.resolve('@babel/preset-env'),
|
||||||
targets: {
|
{
|
||||||
browsers: [
|
targets: {
|
||||||
'last 2 versions',
|
browsers: [
|
||||||
'> 5%',
|
'last 2 versions',
|
||||||
'Safari 7', // for PhantomJS support: https://github.com/elastic/kibana/issues/27136
|
'> 5%',
|
||||||
],
|
'Safari 7', // for PhantomJS support: https://github.com/elastic/kibana/issues/27136
|
||||||
|
],
|
||||||
|
},
|
||||||
|
useBuiltIns: 'entry',
|
||||||
|
modules: 'cjs'
|
||||||
},
|
},
|
||||||
useBuiltIns: true,
|
],
|
||||||
},
|
require('./common_preset'),
|
||||||
],
|
]
|
||||||
require('./common_preset'),
|
};
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
"tslib": "^1.9.3"
|
"tslib": "^1.9.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/cli": "^7.2.3",
|
||||||
"@kbn/babel-preset": "1.0.0",
|
"@kbn/babel-preset": "1.0.0",
|
||||||
"@kbn/expect": "1.0.0",
|
"@kbn/expect": "1.0.0",
|
||||||
"babel-cli": "^6.26.0",
|
|
||||||
"chance": "1.0.6"
|
"chance": "1.0.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^5.6.0",
|
"eslint": "^5.14.1",
|
||||||
"babel-eslint": "^9.0.0"
|
"babel-eslint": "^10.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dedent": "^0.7.0"
|
"dedent": "^0.7.0"
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.json",
|
"extends": "../../tsconfig.json",
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts",
|
"src/**/*.ts",
|
||||||
"src/**/*.tsx",
|
"src/**/*.tsx",
|
||||||
"types/intl_format_cache.d.ts",
|
"types/intl_format_cache.d.ts",
|
||||||
"types/intl_relativeformat.d.ts"
|
"types/intl_relativeformat.d.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"target"
|
"target"
|
||||||
],
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationDir": "./target/types",
|
"declarationDir": "./target/types",
|
||||||
"types": [
|
"types": [
|
||||||
"jest",
|
"jest",
|
||||||
"node"
|
"node"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
{
|
{
|
||||||
"presets": ["@kbn/babel-preset/webpack_preset"],
|
"presets": ["@kbn/babel-preset/webpack_preset"],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
["babel-plugin-transform-runtime", {
|
["@babel/plugin-transform-runtime", {
|
||||||
"polyfill": false,
|
|
||||||
"regenerator": true
|
"regenerator": true
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
|
|
|
@ -9,19 +9,20 @@
|
||||||
"kbn:watch": "node scripts/build --dev --watch"
|
"kbn:watch": "node scripts/build --dev --watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.3.4",
|
||||||
"@kbn/i18n": "1.0.0",
|
"@kbn/i18n": "1.0.0",
|
||||||
"lodash": "npm:@elastic/lodash@3.10.1-kibana1",
|
"lodash": "npm:@elastic/lodash@3.10.1-kibana1",
|
||||||
"lodash.clone": "^4.5.0",
|
"lodash.clone": "^4.5.0",
|
||||||
"uuid": "3.0.1"
|
"uuid": "3.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/cli": "^7.2.3",
|
||||||
|
"@babel/core": "7.3.4",
|
||||||
|
"@babel/plugin-transform-runtime": "^7.3.4",
|
||||||
|
"@babel/polyfill": "7.2.5",
|
||||||
"@kbn/babel-preset": "1.0.0",
|
"@kbn/babel-preset": "1.0.0",
|
||||||
"@kbn/dev-utils": "1.0.0",
|
"@kbn/dev-utils": "1.0.0",
|
||||||
"babel-cli": "^6.26.0",
|
"babel-loader": "8.0.5",
|
||||||
"babel-core": "6.26.3",
|
|
||||||
"babel-loader": "7.1.5",
|
|
||||||
"babel-plugin-transform-runtime": "^6.23.0",
|
|
||||||
"babel-polyfill": "6.20.0",
|
|
||||||
"copy-webpack-plugin": "^4.6.0",
|
"copy-webpack-plugin": "^4.6.0",
|
||||||
"css-loader": "1.0.0",
|
"css-loader": "1.0.0",
|
||||||
"del": "^3.0.0",
|
"del": "^3.0.0",
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
const { extname } = require('path');
|
const { extname } = require('path');
|
||||||
|
|
||||||
const { transform } = require('babel-core');
|
const { transform } = require('@babel/core');
|
||||||
|
|
||||||
exports.createServerCodeTransformer = (sourceMaps) => {
|
exports.createServerCodeTransformer = (sourceMaps) => {
|
||||||
return (content, path) => {
|
return (content, path) => {
|
||||||
|
|
|
@ -28,15 +28,14 @@ describe('js support', () => {
|
||||||
it('transpiles js file', () => {
|
it('transpiles js file', () => {
|
||||||
const transformer = createServerCodeTransformer();
|
const transformer = createServerCodeTransformer();
|
||||||
expect(transformer(JS_FIXTURE, JS_FIXTURE_PATH)).toMatchInlineSnapshot(`
|
expect(transformer(JS_FIXTURE, JS_FIXTURE_PATH)).toMatchInlineSnapshot(`
|
||||||
"'use strict';
|
"\\"use strict\\";
|
||||||
|
|
||||||
var _util = require('util');
|
var _util = _interopRequireDefault(require(\\"util\\"));
|
||||||
|
|
||||||
var _util2 = _interopRequireDefault(_util);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
console.log(_util2.default.format('hello world')); /* eslint-disable */"
|
/* eslint-disable */
|
||||||
|
console.log(_util.default.format('hello world'));"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -27,15 +27,15 @@
|
||||||
"@elastic/eslint-import-resolver-kibana": "link:../../kibana/packages/kbn-eslint-import-resolver-kibana",
|
"@elastic/eslint-import-resolver-kibana": "link:../../kibana/packages/kbn-eslint-import-resolver-kibana",
|
||||||
"@kbn/expect": "1.0.0",
|
"@kbn/expect": "1.0.0",
|
||||||
"@kbn/plugin-helpers": "link:../../kibana/packages/kbn-plugin-helpers",
|
"@kbn/plugin-helpers": "link:../../kibana/packages/kbn-plugin-helpers",
|
||||||
"babel-eslint": "^9.0.0",
|
"babel-eslint": "^10.0.1",
|
||||||
"eslint": "^5.6.0",
|
"eslint": "^5.14.1",
|
||||||
"eslint-plugin-babel": "^5.2.0",
|
"eslint-plugin-babel": "^5.3.0",
|
||||||
"eslint-plugin-import": "^2.14.0",
|
"eslint-plugin-import": "^2.16.0",
|
||||||
"eslint-plugin-jest": "^21.26.2",
|
"eslint-plugin-jest": "^22.3.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.1.2",
|
"eslint-plugin-jsx-a11y": "^6.2.1",
|
||||||
"eslint-plugin-mocha": "^5.2.0",
|
"eslint-plugin-mocha": "^5.3.0",
|
||||||
"eslint-plugin-no-unsanitized": "^3.0.2",
|
"eslint-plugin-no-unsanitized": "^3.0.2",
|
||||||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||||
"eslint-plugin-react": "^7.11.1"
|
"eslint-plugin-react": "^7.12.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ function babelRegister() {
|
||||||
const plugin = pluginConfig();
|
const plugin = pluginConfig();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// add support for moved babel-register source: https://github.com/elastic/kibana/pull/13973
|
// add support for moved @babel/register source: https://github.com/elastic/kibana/pull/13973
|
||||||
require(resolve(plugin.kibanaRoot, 'src/setup_node_env/babel_register')); // eslint-disable-line import/no-dynamic-require
|
require(resolve(plugin.kibanaRoot, 'src/setup_node_env/babel_register')); // eslint-disable-line import/no-dynamic-require
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 'MODULE_NOT_FOUND') {
|
if (error.code === 'MODULE_NOT_FOUND') {
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
{
|
{
|
||||||
"presets": [
|
"presets": [
|
||||||
"stage-3",
|
"@babel/typescript",
|
||||||
["env", {
|
["@babel/preset-env", {
|
||||||
"targets": {
|
"targets": {
|
||||||
"node": "current"
|
"node": "current"
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"@babel/proposal-class-properties",
|
||||||
|
"@babel/proposal-object-rest-spread"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
3584
packages/kbn-pm/dist/index.js
vendored
3584
packages/kbn-pm/dist/index.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -10,6 +10,11 @@
|
||||||
"prettier": "prettier --write './src/**/*.ts'"
|
"prettier": "prettier --write './src/**/*.ts'"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.3.4",
|
||||||
|
"@babel/plugin-proposal-class-properties": "^7.3.4",
|
||||||
|
"@babel/plugin-proposal-object-rest-spread": "^7.3.4",
|
||||||
|
"@babel/preset-env": "^7.3.4",
|
||||||
|
"@babel/preset-typescript": "^7.3.3",
|
||||||
"@types/cmd-shim": "^2.0.0",
|
"@types/cmd-shim": "^2.0.0",
|
||||||
"@types/cpy": "^5.1.0",
|
"@types/cpy": "^5.1.0",
|
||||||
"@types/dedent": "^0.7.0",
|
"@types/dedent": "^0.7.0",
|
||||||
|
@ -32,10 +37,7 @@
|
||||||
"@types/tempy": "^0.1.0",
|
"@types/tempy": "^0.1.0",
|
||||||
"@types/wrap-ansi": "^2.0.14",
|
"@types/wrap-ansi": "^2.0.14",
|
||||||
"@types/write-pkg": "^3.1.0",
|
"@types/write-pkg": "^3.1.0",
|
||||||
"babel-core": "^6.26.3",
|
"babel-loader": "^8.0.5",
|
||||||
"babel-loader": "^7.1.5",
|
|
||||||
"babel-preset-env": "^1.7.0",
|
|
||||||
"babel-preset-stage-3": "^6.24.1",
|
|
||||||
"chalk": "^2.4.1",
|
"chalk": "^2.4.1",
|
||||||
"cmd-shim": "^2.0.2",
|
"cmd-shim": "^2.0.2",
|
||||||
"cpy": "^7.0.1",
|
"cpy": "^7.0.1",
|
||||||
|
@ -60,7 +62,6 @@
|
||||||
"strip-ansi": "^4.0.0",
|
"strip-ansi": "^4.0.0",
|
||||||
"strong-log-transformer": "^2.1.0",
|
"strong-log-transformer": "^2.1.0",
|
||||||
"tempy": "^0.2.1",
|
"tempy": "^0.2.1",
|
||||||
"ts-loader": "^5.2.2",
|
|
||||||
"typescript": "^3.3.3333",
|
"typescript": "^3.3.3333",
|
||||||
"unlazy-loader": "^0.1.3",
|
"unlazy-loader": "^0.1.3",
|
||||||
"webpack": "^4.23.1",
|
"webpack": "^4.23.1",
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "./target/index.js",
|
"main": "./target/index.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.26.0",
|
"@babel/cli": "^7.2.3",
|
||||||
"babel-preset-env": "^1.6.1"
|
"@babel/core": "^7.3.4",
|
||||||
|
"@babel/preset-env": "^7.3.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel --presets env --out-dir target src"
|
"build": "babel --presets=@babel/preset-env --out-dir target src"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
"@elastic/bar": "link:../bar"
|
"@elastic/bar": "link:../bar"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.26.0",
|
"@babel/core": "^7.3.4",
|
||||||
"babel-preset-env": "^1.6.1",
|
"@babel/cli": "^7.2.3",
|
||||||
|
"@babel/preset-env": "^7.3.4",
|
||||||
"moment": "2.20.1"
|
"moment": "2.20.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel --presets env --out-dir target src"
|
"build": "babel --presets=@babel/preset-env --out-dir target src"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,15 @@ Array [
|
||||||
exports[`kbn-pm production builds and copies projects for production: packages/bar/package.json 1`] = `
|
exports[`kbn-pm production builds and copies projects for production: packages/bar/package.json 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"devDependencies": Object {
|
"devDependencies": Object {
|
||||||
"babel-cli": "^6.26.0",
|
"@babel/cli": "^7.2.3",
|
||||||
"babel-preset-env": "^1.6.1",
|
"@babel/core": "^7.3.4",
|
||||||
|
"@babel/preset-env": "^7.3.4",
|
||||||
},
|
},
|
||||||
"main": "./target/index.js",
|
"main": "./target/index.js",
|
||||||
"name": "@elastic/bar",
|
"name": "@elastic/bar",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": Object {
|
"scripts": Object {
|
||||||
"build": "babel --presets env --out-dir target src",
|
"build": "babel --presets=@babel/preset-env --out-dir target src",
|
||||||
},
|
},
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
}
|
}
|
||||||
|
@ -47,15 +48,16 @@ Object {
|
||||||
"@elastic/bar": "link:../bar",
|
"@elastic/bar": "link:../bar",
|
||||||
},
|
},
|
||||||
"devDependencies": Object {
|
"devDependencies": Object {
|
||||||
"babel-cli": "^6.26.0",
|
"@babel/cli": "^7.2.3",
|
||||||
"babel-preset-env": "^1.6.1",
|
"@babel/core": "^7.3.4",
|
||||||
|
"@babel/preset-env": "^7.3.4",
|
||||||
"moment": "2.20.1",
|
"moment": "2.20.1",
|
||||||
},
|
},
|
||||||
"main": "./target/index.js",
|
"main": "./target/index.js",
|
||||||
"name": "@elastic/foo",
|
"name": "@elastic/foo",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": Object {
|
"scripts": Object {
|
||||||
"build": "babel --presets env --out-dir target src",
|
"build": "babel --presets=@babel/preset-env --out-dir target src",
|
||||||
},
|
},
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"include": [
|
"include": [
|
||||||
"./src/**/*.ts"
|
"./src/**/*.ts",
|
||||||
],
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"types": [
|
"types": [
|
||||||
|
|
|
@ -44,15 +44,6 @@ module.exports = {
|
||||||
{
|
{
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
loader: 'ts-loader',
|
|
||||||
options: {
|
|
||||||
compilerOptions: {
|
|
||||||
// enable esnext modules so webpack can do its thing better
|
|
||||||
module: 'esnext',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
},
|
},
|
||||||
|
|
|
@ -18,6 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
presets: ['@kbn/babel-preset/node_preset_7'],
|
presets: ['@kbn/babel-preset/node_preset'],
|
||||||
ignore: ['**/*.test.js'],
|
ignore: ['**/*.test.js'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
"kbn:watch": "yarn build --watch"
|
"kbn:watch": "yarn build --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/cli": "^7.2.3",
|
||||||
"@kbn/babel-preset": "1.0.0",
|
"@kbn/babel-preset": "1.0.0",
|
||||||
"@kbn/dev-utils": "1.0.0",
|
"@kbn/dev-utils": "1.0.0"
|
||||||
"@babel/cli": "^7.2.3"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^2.4.1",
|
"chalk": "^2.4.1",
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
require('./main.scss');
|
require('./main.scss');
|
||||||
|
|
||||||
import 'babel-polyfill';
|
import '@babel/polyfill';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
|
|
|
@ -26,16 +26,16 @@
|
||||||
"uuid": "3.0.1"
|
"uuid": "3.0.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"enzyme": "3.2.0",
|
"enzyme": "^3.8.0",
|
||||||
"enzyme-adapter-react-16": "^1.1.1"
|
"enzyme-adapter-react-16": "^1.9.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.3.4",
|
||||||
|
"@babel/polyfill": "^7.2.5",
|
||||||
"@elastic/eui": "0.0.23",
|
"@elastic/eui": "0.0.23",
|
||||||
"@kbn/babel-preset": "1.0.0",
|
"@kbn/babel-preset": "1.0.0",
|
||||||
"autoprefixer": "6.5.4",
|
"autoprefixer": "6.5.4",
|
||||||
"babel-core": "^6.26.3",
|
"babel-loader": "^8.0.5",
|
||||||
"babel-loader": "^7.1.5",
|
|
||||||
"babel-polyfill": "^6.26.0",
|
|
||||||
"brace": "0.10.0",
|
"brace": "0.10.0",
|
||||||
"chalk": "^2.4.1",
|
"chalk": "^2.4.1",
|
||||||
"chokidar": "1.6.0",
|
"chokidar": "1.6.0",
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
"expose-loader": "^0.7.5",
|
"expose-loader": "^0.7.5",
|
||||||
"file-loader": "^2.0.0",
|
"file-loader": "^2.0.0",
|
||||||
"grunt": "1.0.3",
|
"grunt": "1.0.3",
|
||||||
"grunt-babel": "^7.0.0",
|
"grunt-babel": "^8.0.0",
|
||||||
"grunt-contrib-clean": "^1.1.0",
|
"grunt-contrib-clean": "^1.1.0",
|
||||||
"grunt-contrib-copy": "^1.0.0",
|
"grunt-contrib-copy": "^1.0.0",
|
||||||
"highlight.js": "9.0.0",
|
"highlight.js": "9.0.0",
|
||||||
|
|
92
src/core/public/core_system.test.mocks.ts
Normal file
92
src/core/public/core_system.test.mocks.ts
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* 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 { basePathServiceMock } from './base_path/base_path_service.mock';
|
||||||
|
import { chromeServiceMock } from './chrome/chrome_service.mock';
|
||||||
|
import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock';
|
||||||
|
import { httpServiceMock } from './http/http_service.mock';
|
||||||
|
import { i18nServiceMock } from './i18n/i18n_service.mock';
|
||||||
|
import { injectedMetadataServiceMock } from './injected_metadata/injected_metadata_service.mock';
|
||||||
|
import { legacyPlatformServiceMock } from './legacy/legacy_service.mock';
|
||||||
|
import { notificationServiceMock } from './notifications/notifications_service.mock';
|
||||||
|
import { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
|
||||||
|
|
||||||
|
export const MockLegacyPlatformService = legacyPlatformServiceMock.create();
|
||||||
|
export const LegacyPlatformServiceConstructor = jest
|
||||||
|
.fn()
|
||||||
|
.mockImplementation(() => MockLegacyPlatformService);
|
||||||
|
jest.doMock('./legacy', () => ({
|
||||||
|
LegacyPlatformService: LegacyPlatformServiceConstructor,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockInjectedMetadataService = injectedMetadataServiceMock.create();
|
||||||
|
export const InjectedMetadataServiceConstructor = jest
|
||||||
|
.fn()
|
||||||
|
.mockImplementation(() => MockInjectedMetadataService);
|
||||||
|
jest.doMock('./injected_metadata', () => ({
|
||||||
|
InjectedMetadataService: InjectedMetadataServiceConstructor,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockFatalErrorsService = fatalErrorsServiceMock.create();
|
||||||
|
export const FatalErrorsServiceConstructor = jest
|
||||||
|
.fn()
|
||||||
|
.mockImplementation(() => MockFatalErrorsService);
|
||||||
|
jest.doMock('./fatal_errors', () => ({
|
||||||
|
FatalErrorsService: FatalErrorsServiceConstructor,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockI18nService = i18nServiceMock.create();
|
||||||
|
export const I18nServiceConstructor = jest.fn().mockImplementation(() => MockI18nService);
|
||||||
|
jest.doMock('./i18n', () => ({
|
||||||
|
I18nService: I18nServiceConstructor,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockNotificationsService = notificationServiceMock.create();
|
||||||
|
export const NotificationServiceConstructor = jest
|
||||||
|
.fn()
|
||||||
|
.mockImplementation(() => MockNotificationsService);
|
||||||
|
jest.doMock('./notifications', () => ({
|
||||||
|
NotificationsService: NotificationServiceConstructor,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockHttpService = httpServiceMock.create();
|
||||||
|
export const HttpServiceConstructor = jest.fn().mockImplementation(() => MockHttpService);
|
||||||
|
jest.doMock('./http', () => ({
|
||||||
|
HttpService: HttpServiceConstructor,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockBasePathService = basePathServiceMock.create();
|
||||||
|
export const BasePathServiceConstructor = jest.fn().mockImplementation(() => MockBasePathService);
|
||||||
|
jest.doMock('./base_path', () => ({
|
||||||
|
BasePathService: BasePathServiceConstructor,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockUiSettingsService = uiSettingsServiceMock.create();
|
||||||
|
export const UiSettingsServiceConstructor = jest
|
||||||
|
.fn()
|
||||||
|
.mockImplementation(() => MockUiSettingsService);
|
||||||
|
jest.doMock('./ui_settings', () => ({
|
||||||
|
UiSettingsService: UiSettingsServiceConstructor,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockChromeService = chromeServiceMock.create();
|
||||||
|
export const ChromeServiceConstructor = jest.fn().mockImplementation(() => MockChromeService);
|
||||||
|
jest.doMock('./chrome', () => ({
|
||||||
|
ChromeService: ChromeServiceConstructor,
|
||||||
|
}));
|
|
@ -17,73 +17,26 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { basePathServiceMock } from './base_path/base_path_service.mock';
|
import {
|
||||||
import { chromeServiceMock } from './chrome/chrome_service.mock';
|
BasePathServiceConstructor,
|
||||||
import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock';
|
ChromeServiceConstructor,
|
||||||
import { httpServiceMock } from './http/http_service.mock';
|
FatalErrorsServiceConstructor,
|
||||||
import { i18nServiceMock } from './i18n/i18n_service.mock';
|
HttpServiceConstructor,
|
||||||
import { injectedMetadataServiceMock } from './injected_metadata/injected_metadata_service.mock';
|
I18nServiceConstructor,
|
||||||
import { legacyPlatformServiceMock } from './legacy/legacy_service.mock';
|
InjectedMetadataServiceConstructor,
|
||||||
import { notificationServiceMock } from './notifications/notifications_service.mock';
|
LegacyPlatformServiceConstructor,
|
||||||
import { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
|
MockBasePathService,
|
||||||
|
MockChromeService,
|
||||||
const MockLegacyPlatformService = legacyPlatformServiceMock.create();
|
MockFatalErrorsService,
|
||||||
const LegacyPlatformServiceConstructor = jest
|
MockHttpService,
|
||||||
.fn()
|
MockI18nService,
|
||||||
.mockImplementation(() => MockLegacyPlatformService);
|
MockInjectedMetadataService,
|
||||||
jest.mock('./legacy', () => ({
|
MockLegacyPlatformService,
|
||||||
LegacyPlatformService: LegacyPlatformServiceConstructor,
|
MockNotificationsService,
|
||||||
}));
|
MockUiSettingsService,
|
||||||
|
NotificationServiceConstructor,
|
||||||
const MockInjectedMetadataService = injectedMetadataServiceMock.create();
|
UiSettingsServiceConstructor,
|
||||||
const InjectedMetadataServiceConstructor = jest
|
} from './core_system.test.mocks';
|
||||||
.fn()
|
|
||||||
.mockImplementation(() => MockInjectedMetadataService);
|
|
||||||
jest.mock('./injected_metadata', () => ({
|
|
||||||
InjectedMetadataService: InjectedMetadataServiceConstructor,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const MockFatalErrorsService = fatalErrorsServiceMock.create();
|
|
||||||
const FatalErrorsServiceConstructor = jest.fn().mockImplementation(() => MockFatalErrorsService);
|
|
||||||
jest.mock('./fatal_errors', () => ({
|
|
||||||
FatalErrorsService: FatalErrorsServiceConstructor,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const MockI18nService = i18nServiceMock.create();
|
|
||||||
const I18nServiceConstructor = jest.fn().mockImplementation(() => MockI18nService);
|
|
||||||
jest.mock('./i18n', () => ({
|
|
||||||
I18nService: I18nServiceConstructor,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const MockNotificationsService = notificationServiceMock.create();
|
|
||||||
const NotificationServiceConstructor = jest.fn().mockImplementation(() => MockNotificationsService);
|
|
||||||
jest.mock('./notifications', () => ({
|
|
||||||
NotificationsService: NotificationServiceConstructor,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const MockHttpService = httpServiceMock.create();
|
|
||||||
const HttpServiceConstructor = jest.fn().mockImplementation(() => MockHttpService);
|
|
||||||
jest.mock('./http', () => ({
|
|
||||||
HttpService: HttpServiceConstructor,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const MockBasePathService = basePathServiceMock.create();
|
|
||||||
const BasePathServiceConstructor = jest.fn().mockImplementation(() => MockBasePathService);
|
|
||||||
jest.mock('./base_path', () => ({
|
|
||||||
BasePathService: BasePathServiceConstructor,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const MockUiSettingsService = uiSettingsServiceMock.create();
|
|
||||||
const UiSettingsServiceConstructor = jest.fn().mockImplementation(() => MockUiSettingsService);
|
|
||||||
jest.mock('./ui_settings', () => ({
|
|
||||||
UiSettingsService: UiSettingsServiceConstructor,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const MockChromeService = chromeServiceMock.create();
|
|
||||||
const ChromeServiceConstructor = jest.fn().mockImplementation(() => MockChromeService);
|
|
||||||
jest.mock('./chrome', () => ({
|
|
||||||
ChromeService: ChromeServiceConstructor,
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { CoreSystem } from './core_system';
|
import { CoreSystem } from './core_system';
|
||||||
jest.spyOn(CoreSystem.prototype, 'stop');
|
jest.spyOn(CoreSystem.prototype, 'stop');
|
||||||
|
|
|
@ -52,8 +52,7 @@ exports[`rendering render matches snapshot 1`] = `
|
||||||
body={
|
body={
|
||||||
<p>
|
<p>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Try refreshing the page. If that doesn't work, go back to the previous page or
|
defaultMessage="Try refreshing the page. If that doesn't work, go back to the previous page or clear your session data."
|
||||||
clear your session data."
|
|
||||||
id="core.fatalErrors.tryRefreshingPageDescription"
|
id="core.fatalErrors.tryRefreshingPageDescription"
|
||||||
values={Object {}}
|
values={Object {}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockRender = jest.fn();
|
||||||
|
jest.mock('react-dom', () => {
|
||||||
|
return {
|
||||||
|
render: mockRender,
|
||||||
|
};
|
||||||
|
});
|
|
@ -24,12 +24,7 @@ expect.addSnapshotSerializer({
|
||||||
print: () => `Rx.Observable`,
|
print: () => `Rx.Observable`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockRender = jest.fn();
|
import { mockRender } from './fatal_errors_service.test.mocks';
|
||||||
jest.mock('react-dom', () => {
|
|
||||||
return {
|
|
||||||
render: mockRender,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
import { FatalErrorsService } from './fatal_errors_service';
|
import { FatalErrorsService } from './fatal_errors_service';
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockReactDomRender = jest.fn();
|
||||||
|
export const mockReactDomUnmount = jest.fn();
|
||||||
|
jest.mock('react-dom', () => ({
|
||||||
|
render: mockReactDomRender,
|
||||||
|
unmountComponentAtNode: mockReactDomUnmount,
|
||||||
|
}));
|
|
@ -17,12 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mockReactDomRender = jest.fn();
|
import { mockReactDomRender, mockReactDomUnmount } from './toasts_service.test.mocks';
|
||||||
const mockReactDomUnmount = jest.fn();
|
|
||||||
jest.mock('react-dom', () => ({
|
|
||||||
render: mockReactDomRender,
|
|
||||||
unmountComponentAtNode: mockReactDomUnmount,
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { ToastsService } from './toasts_service';
|
import { ToastsService } from './toasts_service';
|
||||||
import { ToastsSetup } from './toasts_start';
|
import { ToastsSetup } from './toasts_start';
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function mockClass<T>(
|
||||||
|
module: string,
|
||||||
|
Class: { new (...args: any[]): T },
|
||||||
|
setup: (instance: any, args: any[]) => void
|
||||||
|
) {
|
||||||
|
const MockClass = jest.fn(function(this: any, ...args: any[]) {
|
||||||
|
setup(this, args);
|
||||||
|
});
|
||||||
|
|
||||||
|
// define the mock name which is used in some snapshots
|
||||||
|
MockClass.mockName(`Mock${Class.name}`);
|
||||||
|
|
||||||
|
// define the class name for the MockClass which is used in other snapshots
|
||||||
|
Object.defineProperty(MockClass, 'name', {
|
||||||
|
value: `Mock${Class.name}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
jest.doMock(module, () => ({
|
||||||
|
[Class.name]: MockClass,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return MockClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock the UiSettingsApi class
|
||||||
|
import { UiSettingsApi } from './ui_settings_api';
|
||||||
|
export const MockUiSettingsApi = mockClass('./ui_settings_api', UiSettingsApi, inst => {
|
||||||
|
inst.stop = jest.fn();
|
||||||
|
inst.getLoadingCount$ = jest.fn().mockReturnValue({
|
||||||
|
loadingCountObservable: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mock the UiSettingsClient class
|
||||||
|
import { UiSettingsClient } from './ui_settings_client';
|
||||||
|
export const MockUiSettingsClient = mockClass('./ui_settings_client', UiSettingsClient, inst => {
|
||||||
|
inst.stop = jest.fn();
|
||||||
|
});
|
|
@ -17,44 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function mockClass<T>(
|
import { MockUiSettingsApi, MockUiSettingsClient } from './ui_settings_service.test.mocks';
|
||||||
module: string,
|
|
||||||
Class: { new (...args: any[]): T },
|
|
||||||
setup: (instance: any, args: any[]) => void
|
|
||||||
) {
|
|
||||||
const MockClass = jest.fn(function(this: any, ...args: any[]) {
|
|
||||||
setup(this, args);
|
|
||||||
});
|
|
||||||
|
|
||||||
// define the mock name which is used in some snapshots
|
|
||||||
MockClass.mockName(`Mock${Class.name}`);
|
|
||||||
|
|
||||||
// define the class name for the MockClass which is used in other snapshots
|
|
||||||
Object.defineProperty(MockClass, 'name', {
|
|
||||||
value: `Mock${Class.name}`,
|
|
||||||
});
|
|
||||||
|
|
||||||
jest.mock(module, () => ({
|
|
||||||
[Class.name]: MockClass,
|
|
||||||
}));
|
|
||||||
|
|
||||||
return MockClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mock the UiSettingsApi class
|
|
||||||
import { UiSettingsApi } from './ui_settings_api';
|
|
||||||
const MockUiSettingsApi = mockClass('./ui_settings_api', UiSettingsApi, inst => {
|
|
||||||
inst.stop = jest.fn();
|
|
||||||
inst.getLoadingCount$ = jest.fn().mockReturnValue({
|
|
||||||
loadingCountObservable: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Mock the UiSettingsClient class
|
|
||||||
import { UiSettingsClient } from './ui_settings_client';
|
|
||||||
const MockUiSettingsClient = mockClass('./ui_settings_client', UiSettingsClient, inst => {
|
|
||||||
inst.stop = jest.fn();
|
|
||||||
});
|
|
||||||
|
|
||||||
import { basePathServiceMock } from '../base_path/base_path_service.mock';
|
import { basePathServiceMock } from '../base_path/base_path_service.mock';
|
||||||
import { httpServiceMock } from '../http/http_service.mock';
|
import { httpServiceMock } from '../http/http_service.mock';
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { ObjectToConfigAdapter } from './object_to_config_adapter';
|
import { ObjectToConfigAdapter } from './object_to_config_adapter';
|
||||||
|
|
||||||
|
|
21
src/core/server/config/config_service.test.mocks.ts
Normal file
21
src/core/server/config/config_service.test.mocks.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
||||||
|
jest.mock('../../../../package.json', () => mockPackage);
|
|
@ -22,8 +22,7 @@
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { first } from 'rxjs/operators';
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
import { mockPackage } from './config_service.test.mocks';
|
||||||
jest.mock('../../../../package.json', () => mockPackage);
|
|
||||||
|
|
||||||
import { schema, Type, TypeOf } from '@kbn/config-schema';
|
import { schema, Type, TypeOf } from '@kbn/config-schema';
|
||||||
|
|
||||||
|
|
33
src/core/server/config/env.test.mocks.ts
Normal file
33
src/core/server/config/env.test.mocks.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
jest.mock('process', () => ({
|
||||||
|
cwd() {
|
||||||
|
return '/test/cwd';
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock('path', () => ({
|
||||||
|
resolve(...pathSegments: string[]) {
|
||||||
|
return pathSegments.join('/');
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
||||||
|
jest.mock('../../../../package.json', () => mockPackage);
|
|
@ -17,20 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jest.mock('process', () => ({
|
import { mockPackage } from './env.test.mocks';
|
||||||
cwd() {
|
|
||||||
return '/test/cwd';
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('path', () => ({
|
|
||||||
resolve(...pathSegments: string[]) {
|
|
||||||
return pathSegments.join('/');
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
|
||||||
jest.mock('../../../../package.json', () => mockPackage);
|
|
||||||
|
|
||||||
import { Env } from '.';
|
import { Env } from '.';
|
||||||
import { getEnvOptions } from './__mocks__/env';
|
import { getEnvOptions } from './__mocks__/env';
|
||||||
|
|
24
src/core/server/config/raw_config_service.test.mocks.ts
Normal file
24
src/core/server/config/raw_config_service.test.mocks.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockGetConfigFromFiles = jest.fn();
|
||||||
|
|
||||||
|
jest.mock('./read_config', () => ({
|
||||||
|
getConfigFromFiles: mockGetConfigFromFiles,
|
||||||
|
}));
|
|
@ -17,11 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mockGetConfigFromFiles = jest.fn();
|
import { mockGetConfigFromFiles } from './raw_config_service.test.mocks';
|
||||||
|
|
||||||
jest.mock('./read_config', () => ({
|
|
||||||
getConfigFromFiles: mockGetConfigFromFiles,
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { first } from 'rxjs/operators';
|
import { first } from 'rxjs/operators';
|
||||||
import { RawConfigService } from '.';
|
import { RawConfigService } from '.';
|
||||||
|
|
35
src/core/server/elasticsearch/cluster_client.test.mocks.ts
Normal file
35
src/core/server/elasticsearch/cluster_client.test.mocks.ts
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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 const MockClient = jest.fn();
|
||||||
|
jest.mock('elasticsearch', () => ({
|
||||||
|
// Jest types don't include `requireActual` right now.
|
||||||
|
...jest.requireActual('elasticsearch'),
|
||||||
|
Client: MockClient,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const MockScopedClusterClient = jest.fn();
|
||||||
|
jest.mock('./scoped_cluster_client', () => ({
|
||||||
|
ScopedClusterClient: MockScopedClusterClient,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const mockParseElasticsearchClientConfig = jest.fn();
|
||||||
|
jest.mock('./elasticsearch_client_config', () => ({
|
||||||
|
parseElasticsearchClientConfig: mockParseElasticsearchClientConfig,
|
||||||
|
}));
|
|
@ -19,22 +19,11 @@
|
||||||
|
|
||||||
import { ElasticsearchConfig } from './elasticsearch_config';
|
import { ElasticsearchConfig } from './elasticsearch_config';
|
||||||
|
|
||||||
const MockClient = jest.fn();
|
import {
|
||||||
jest.mock('elasticsearch', () => ({
|
MockClient,
|
||||||
// Jest types don't include `requireActual` right now.
|
mockParseElasticsearchClientConfig,
|
||||||
...(jest as any).requireActual('elasticsearch'),
|
MockScopedClusterClient,
|
||||||
Client: MockClient,
|
} from './cluster_client.test.mocks';
|
||||||
}));
|
|
||||||
|
|
||||||
const MockScopedClusterClient = jest.fn();
|
|
||||||
jest.mock('./scoped_cluster_client', () => ({
|
|
||||||
ScopedClusterClient: MockScopedClusterClient,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mockParseElasticsearchClientConfig = jest.fn();
|
|
||||||
jest.mock('./elasticsearch_client_config', () => ({
|
|
||||||
parseElasticsearchClientConfig: mockParseElasticsearchClientConfig,
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { errors } from 'elasticsearch';
|
import { errors } from 'elasticsearch';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
|
|
|
@ -17,5 +17,5 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require('../../setup_node_env');
|
export const mockReadFileSync = jest.fn();
|
||||||
module.exports = require('./ts_transform.ts');
|
jest.mock('fs', () => ({ readFileSync: mockReadFileSync }));
|
|
@ -17,8 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mockReadFileSync = jest.fn();
|
import { mockReadFileSync } from './elasticsearch_client_config.test.mocks';
|
||||||
jest.mock('fs', () => ({ readFileSync: mockReadFileSync }));
|
|
||||||
|
|
||||||
import { duration } from 'moment';
|
import { duration } from 'moment';
|
||||||
import { loggingServiceMock } from '../logging/logging_service.mock';
|
import { loggingServiceMock } from '../logging/logging_service.mock';
|
||||||
|
@ -67,7 +66,7 @@ Object {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('parses fully specified config', () => {
|
test('parses fully specified config', () => {
|
||||||
mockReadFileSync.mockImplementation(path => `content-of-${path}`);
|
mockReadFileSync.mockImplementation((path: string) => `content-of-${path}`);
|
||||||
|
|
||||||
const elasticsearchConfig: ElasticsearchClientConfig = {
|
const elasticsearchConfig: ElasticsearchClientConfig = {
|
||||||
apiVersion: 'v7.0.0',
|
apiVersion: 'v7.0.0',
|
||||||
|
@ -607,7 +606,7 @@ Object {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('#ignoreCertAndKey = true', () => {
|
test('#ignoreCertAndKey = true', () => {
|
||||||
mockReadFileSync.mockImplementation(path => `content-of-${path}`);
|
mockReadFileSync.mockImplementation((path: string) => `content-of-${path}`);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
parseElasticsearchClientConfig(
|
parseElasticsearchClientConfig(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { ClusterClient } from './cluster_client';
|
import { ClusterClient } from './cluster_client';
|
||||||
import { ElasticsearchConfig } from './elasticsearch_config';
|
import { ElasticsearchConfig } from './elasticsearch_config';
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* 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 const MockClusterClient = jest.fn();
|
||||||
|
jest.mock('./cluster_client', () => ({ ClusterClient: MockClusterClient }));
|
|
@ -19,8 +19,7 @@
|
||||||
|
|
||||||
import { first } from 'rxjs/operators';
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
const MockClusterClient = jest.fn();
|
import { MockClusterClient } from './elasticsearch_service.test.mocks';
|
||||||
jest.mock('./cluster_client', () => ({ ClusterClient: MockClusterClient }));
|
|
||||||
|
|
||||||
import { BehaviorSubject, combineLatest } from 'rxjs';
|
import { BehaviorSubject, combineLatest } from 'rxjs';
|
||||||
import { Config, ConfigService, Env, ObjectToConfigAdapter } from '../config';
|
import { Config, ConfigService, Env, ObjectToConfigAdapter } from '../config';
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Server, ServerOptions } from 'hapi';
|
import { Server, ServerOptions } from 'hapi';
|
||||||
import { HttpService } from './http_service';
|
import { HttpService } from './http_service';
|
||||||
|
|
||||||
|
|
24
src/core/server/http/http_service.test.mocks.ts
Normal file
24
src/core/server/http/http_service.test.mocks.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockHttpServer = jest.fn();
|
||||||
|
|
||||||
|
jest.mock('./http_server', () => ({
|
||||||
|
HttpServer: mockHttpServer,
|
||||||
|
}));
|
|
@ -17,11 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mockHttpServer = jest.fn();
|
import { mockHttpServer } from './http_service.test.mocks';
|
||||||
|
|
||||||
jest.mock('./http_server', () => ({
|
|
||||||
HttpServer: mockHttpServer,
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { noop } from 'lodash';
|
import { noop } from 'lodash';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
|
40
src/core/server/index.test.mocks.ts
Normal file
40
src/core/server/index.test.mocks.ts
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* 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 { httpServiceMock } from './http/http_service.mock';
|
||||||
|
export const httpService = httpServiceMock.create();
|
||||||
|
jest.doMock('./http/http_service', () => ({
|
||||||
|
HttpService: jest.fn(() => httpService),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const mockPluginsService = { setup: jest.fn(), stop: jest.fn() };
|
||||||
|
jest.doMock('./plugins/plugins_service', () => ({
|
||||||
|
PluginsService: jest.fn(() => mockPluginsService),
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { elasticsearchServiceMock } from './elasticsearch/elasticsearch_service.mock';
|
||||||
|
export const elasticsearchService = elasticsearchServiceMock.create();
|
||||||
|
jest.doMock('./elasticsearch/elasticsearch_service', () => ({
|
||||||
|
ElasticsearchService: jest.fn(() => elasticsearchService),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const mockLegacyService = { setup: jest.fn(), stop: jest.fn() };
|
||||||
|
jest.mock('./legacy/legacy_service', () => ({
|
||||||
|
LegacyService: jest.fn(() => mockLegacyService),
|
||||||
|
}));
|
|
@ -28,6 +28,7 @@ Array [
|
||||||
"valueInBytes": 1073741824,
|
"valueInBytes": 1073741824,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"httpsAgent": undefined,
|
||||||
"log": Object {
|
"log": Object {
|
||||||
"context": Array [
|
"context": Array [
|
||||||
"server",
|
"server",
|
||||||
|
@ -52,6 +53,7 @@ Array [
|
||||||
"trace": [MockFunction],
|
"trace": [MockFunction],
|
||||||
"warn": [MockFunction],
|
"warn": [MockFunction],
|
||||||
},
|
},
|
||||||
|
"server": undefined,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
29
src/core/server/logging/appenders/appenders.test.mocks.ts
Normal file
29
src/core/server/logging/appenders/appenders.test.mocks.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockCreateLayout = jest.fn();
|
||||||
|
jest.mock('../layouts/layouts', () => {
|
||||||
|
const { schema } = require('@kbn/config-schema');
|
||||||
|
return {
|
||||||
|
Layouts: {
|
||||||
|
configSchema: schema.object({ kind: schema.literal('mock') }),
|
||||||
|
create: mockCreateLayout,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
|
@ -17,16 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mockCreateLayout = jest.fn();
|
import { mockCreateLayout } from './appenders.test.mocks';
|
||||||
jest.mock('../layouts/layouts', () => {
|
|
||||||
const { schema } = require('@kbn/config-schema');
|
|
||||||
return {
|
|
||||||
Layouts: {
|
|
||||||
configSchema: schema.object({ kind: schema.literal('mock') }),
|
|
||||||
create: mockCreateLayout,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
import { LegacyAppender } from '../../legacy/logging/appenders/legacy_appender';
|
import { LegacyAppender } from '../../legacy/logging/appenders/legacy_appender';
|
||||||
import { Appenders } from './appenders';
|
import { Appenders } from './appenders';
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
jest.mock('../../layouts/layouts', () => {
|
||||||
|
const { schema } = require('@kbn/config-schema');
|
||||||
|
return {
|
||||||
|
Layouts: {
|
||||||
|
configSchema: schema.object({
|
||||||
|
kind: schema.literal('mock'),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
export const mockCreateWriteStream = jest.fn();
|
||||||
|
jest.mock('fs', () => ({ createWriteStream: mockCreateWriteStream }));
|
|
@ -17,19 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jest.mock('../../layouts/layouts', () => {
|
import { mockCreateWriteStream } from './file_appender.test.mocks';
|
||||||
const { schema } = require('@kbn/config-schema');
|
|
||||||
return {
|
|
||||||
Layouts: {
|
|
||||||
configSchema: schema.object({
|
|
||||||
kind: schema.literal('mock'),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const mockCreateWriteStream = jest.fn();
|
|
||||||
jest.mock('fs', () => ({ createWriteStream: mockCreateWriteStream }));
|
|
||||||
|
|
||||||
import { LogLevel } from '../../log_level';
|
import { LogLevel } from '../../log_level';
|
||||||
import { LogRecord } from '../../log_record';
|
import { LogRecord } from '../../log_record';
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockReaddir = jest.fn();
|
||||||
|
export const mockReadFile = jest.fn();
|
||||||
|
export const mockStat = jest.fn();
|
||||||
|
jest.mock('fs', () => ({
|
||||||
|
readdir: mockReaddir,
|
||||||
|
readFile: mockReadFile,
|
||||||
|
stat: mockStat,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
||||||
|
jest.mock('../../../../../package.json', () => mockPackage);
|
|
@ -17,17 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mockReaddir = jest.fn();
|
import { mockPackage, mockReaddir, mockReadFile, mockStat } from './plugin_discovery.test.mocks';
|
||||||
const mockReadFile = jest.fn();
|
|
||||||
const mockStat = jest.fn();
|
|
||||||
jest.mock('fs', () => ({
|
|
||||||
readdir: mockReaddir,
|
|
||||||
readFile: mockReadFile,
|
|
||||||
stat: mockStat,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
|
||||||
jest.mock('../../../../../package.json', () => mockPackage);
|
|
||||||
|
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
|
|
@ -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 const mockReadFile = jest.fn();
|
||||||
|
const mockStat = jest.fn();
|
||||||
|
jest.mock('fs', () => ({ readFile: mockReadFile, stat: mockStat }));
|
|
@ -19,9 +19,7 @@
|
||||||
|
|
||||||
import { PluginDiscoveryErrorType } from './plugin_discovery_error';
|
import { PluginDiscoveryErrorType } from './plugin_discovery_error';
|
||||||
|
|
||||||
const mockReadFile = jest.fn();
|
import { mockReadFile } from './plugin_manifest_parser.test.mocks';
|
||||||
const mockStat = jest.fn();
|
|
||||||
jest.mock('fs', () => ({ readFile: mockReadFile, stat: mockStat }));
|
|
||||||
|
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { parseManifest } from './plugin_manifest_parser';
|
import { parseManifest } from './plugin_manifest_parser';
|
||||||
|
|
|
@ -30,15 +30,15 @@ import { createPluginInitializerContext, createPluginSetupContext } from './plug
|
||||||
|
|
||||||
const mockPluginInitializer = jest.fn();
|
const mockPluginInitializer = jest.fn();
|
||||||
const logger = loggingServiceMock.create();
|
const logger = loggingServiceMock.create();
|
||||||
jest.mock(
|
jest.doMock(
|
||||||
join('plugin-with-initializer-path', 'server'),
|
join('plugin-with-initializer-path', 'server'),
|
||||||
() => ({ plugin: mockPluginInitializer }),
|
() => ({ plugin: mockPluginInitializer }),
|
||||||
{ virtual: true }
|
{ virtual: true }
|
||||||
);
|
);
|
||||||
jest.mock(join('plugin-without-initializer-path', 'server'), () => ({}), {
|
jest.doMock(join('plugin-without-initializer-path', 'server'), () => ({}), {
|
||||||
virtual: true,
|
virtual: true,
|
||||||
});
|
});
|
||||||
jest.mock(join('plugin-with-wrong-initializer-path', 'server'), () => ({ plugin: {} }), {
|
jest.doMock(join('plugin-with-wrong-initializer-path', 'server'), () => ({ plugin: {} }), {
|
||||||
virtual: true,
|
virtual: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
26
src/core/server/plugins/plugins_service.test.mocks.ts
Normal file
26
src/core/server/plugins/plugins_service.test.mocks.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
||||||
|
jest.mock('../../../legacy/utils/package_json', () => ({ pkg: mockPackage }));
|
||||||
|
|
||||||
|
export const mockDiscover = jest.fn();
|
||||||
|
jest.mock('./discovery/plugins_discovery', () => ({ discover: mockDiscover }));
|
||||||
|
|
||||||
|
jest.mock('./plugins_system');
|
|
@ -17,13 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
import { mockDiscover, mockPackage } from './plugins_service.test.mocks';
|
||||||
jest.mock('../../../legacy/utils/package_json', () => ({ pkg: mockPackage }));
|
|
||||||
|
|
||||||
const mockDiscover = jest.fn();
|
|
||||||
jest.mock('./discovery/plugins_discovery', () => ({ discover: mockDiscover }));
|
|
||||||
|
|
||||||
jest.mock('./plugins_system');
|
|
||||||
|
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { BehaviorSubject, from } from 'rxjs';
|
import { BehaviorSubject, from } from 'rxjs';
|
||||||
|
|
23
src/core/server/plugins/plugins_system.test.mocks.ts
Normal file
23
src/core/server/plugins/plugins_system.test.mocks.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockCreatePluginSetupContext = jest.fn();
|
||||||
|
jest.mock('./plugin_context', () => ({
|
||||||
|
createPluginSetupContext: mockCreatePluginSetupContext,
|
||||||
|
}));
|
|
@ -17,16 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { CoreContext } from '../core_context';
|
import { mockCreatePluginSetupContext } from './plugins_system.test.mocks';
|
||||||
|
|
||||||
const mockCreatePluginSetupContext = jest.fn();
|
|
||||||
jest.mock('./plugin_context', () => ({
|
|
||||||
createPluginSetupContext: mockCreatePluginSetupContext,
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { Config, ConfigService, Env, ObjectToConfigAdapter } from '../config';
|
import { Config, ConfigService, Env, ObjectToConfigAdapter } from '../config';
|
||||||
import { getEnvOptions } from '../config/__mocks__/env';
|
import { getEnvOptions } from '../config/__mocks__/env';
|
||||||
|
import { CoreContext } from '../core_context';
|
||||||
import { elasticsearchServiceMock } from '../elasticsearch/elasticsearch_service.mock';
|
import { elasticsearchServiceMock } from '../elasticsearch/elasticsearch_service.mock';
|
||||||
import { loggingServiceMock } from '../logging/logging_service.mock';
|
import { loggingServiceMock } from '../logging/logging_service.mock';
|
||||||
import { Plugin, PluginName } from './plugin';
|
import { Plugin, PluginName } from './plugin';
|
||||||
|
|
33
src/core/server/root/index.test.mocks.ts
Normal file
33
src/core/server/root/index.test.mocks.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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 { loggingServiceMock } from '../logging/logging_service.mock';
|
||||||
|
export const logger = loggingServiceMock.create();
|
||||||
|
jest.doMock('../logging', () => ({
|
||||||
|
LoggingService: jest.fn(() => logger),
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { configServiceMock } from '../config/config_service.mock';
|
||||||
|
export const configService = configServiceMock.create();
|
||||||
|
jest.doMock('../config/config_service', () => ({
|
||||||
|
ConfigService: jest.fn(() => configService),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const mockServer = { setup: jest.fn(), stop: jest.fn() };
|
||||||
|
jest.mock('../server', () => ({ Server: jest.fn(() => mockServer) }));
|
|
@ -17,20 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loggingServiceMock } from '../logging/logging_service.mock';
|
import { configService, logger, mockServer } from './index.test.mocks';
|
||||||
const logger = loggingServiceMock.create();
|
|
||||||
jest.mock('../logging', () => ({
|
|
||||||
LoggingService: jest.fn(() => logger),
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { configServiceMock } from '../config/config_service.mock';
|
|
||||||
const configService = configServiceMock.create();
|
|
||||||
jest.mock('../config/config_service', () => ({
|
|
||||||
ConfigService: jest.fn(() => configService),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mockServer = { setup: jest.fn(), stop: jest.fn() };
|
|
||||||
jest.mock('../server', () => ({ Server: jest.fn(() => mockServer) }));
|
|
||||||
|
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { filter, first } from 'rxjs/operators';
|
import { filter, first } from 'rxjs/operators';
|
||||||
|
|
|
@ -16,27 +16,13 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { httpServiceMock } from './http/http_service.mock';
|
|
||||||
const httpService = httpServiceMock.create();
|
|
||||||
jest.mock('./http/http_service', () => ({
|
|
||||||
HttpService: jest.fn(() => httpService),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mockPluginsService = { setup: jest.fn(), stop: jest.fn() };
|
import {
|
||||||
jest.mock('./plugins/plugins_service', () => ({
|
elasticsearchService,
|
||||||
PluginsService: jest.fn(() => mockPluginsService),
|
httpService,
|
||||||
}));
|
mockLegacyService,
|
||||||
|
mockPluginsService,
|
||||||
import { elasticsearchServiceMock } from './elasticsearch/elasticsearch_service.mock';
|
} from './index.test.mocks';
|
||||||
const elasticsearchService = elasticsearchServiceMock.create();
|
|
||||||
jest.mock('./elasticsearch/elasticsearch_service', () => ({
|
|
||||||
ElasticsearchService: jest.fn(() => elasticsearchService),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mockLegacyService = { setup: jest.fn(), stop: jest.fn() };
|
|
||||||
jest.mock('./legacy/legacy_service', () => ({
|
|
||||||
LegacyService: jest.fn(() => mockLegacyService),
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { Env } from './config';
|
import { Env } from './config';
|
||||||
|
|
|
@ -47,8 +47,8 @@ import {
|
||||||
RemovePackageJsonDepsTask,
|
RemovePackageJsonDepsTask,
|
||||||
RemoveWorkspacesTask,
|
RemoveWorkspacesTask,
|
||||||
TranspileBabelTask,
|
TranspileBabelTask,
|
||||||
TranspileTypescriptTask,
|
|
||||||
TranspileScssTask,
|
TranspileScssTask,
|
||||||
|
TypecheckTypescriptTask,
|
||||||
UpdateLicenseFileTask,
|
UpdateLicenseFileTask,
|
||||||
VerifyEnvTask,
|
VerifyEnvTask,
|
||||||
VerifyExistingNodeBuildsTask,
|
VerifyExistingNodeBuildsTask,
|
||||||
|
@ -107,15 +107,14 @@ export async function buildDistributables(options) {
|
||||||
* run platform-generic build tasks
|
* run platform-generic build tasks
|
||||||
*/
|
*/
|
||||||
await run(CopySourceTask);
|
await run(CopySourceTask);
|
||||||
|
await run(TypecheckTypescriptTask);
|
||||||
await run(CreateEmptyDirsAndFilesTask);
|
await run(CreateEmptyDirsAndFilesTask);
|
||||||
await run(CreateReadmeTask);
|
await run(CreateReadmeTask);
|
||||||
await run(TranspileBabelTask);
|
await run(TranspileBabelTask);
|
||||||
await run(TranspileTypescriptTask);
|
|
||||||
await run(BuildPackagesTask);
|
await run(BuildPackagesTask);
|
||||||
await run(CreatePackageJsonTask);
|
await run(CreatePackageJsonTask);
|
||||||
await run(InstallDependenciesTask);
|
await run(InstallDependenciesTask);
|
||||||
await run(RemoveWorkspacesTask);
|
await run(RemoveWorkspacesTask);
|
||||||
await run(CleanTypescriptTask);
|
|
||||||
await run(CleanPackagesTask);
|
await run(CleanPackagesTask);
|
||||||
await run(CreateNoticeFileTask);
|
await run(CreateNoticeFileTask);
|
||||||
await run(UpdateLicenseFileTask);
|
await run(UpdateLicenseFileTask);
|
||||||
|
@ -123,6 +122,7 @@ export async function buildDistributables(options) {
|
||||||
await run(TranspileScssTask);
|
await run(TranspileScssTask);
|
||||||
await run(OptimizeBuildTask);
|
await run(OptimizeBuildTask);
|
||||||
await run(CleanClientModulesOnDLLTask);
|
await run(CleanClientModulesOnDLLTask);
|
||||||
|
await run(CleanTypescriptTask);
|
||||||
await run(CleanExtraFilesFromModulesTask);
|
await run(CleanExtraFilesFromModulesTask);
|
||||||
await run(CleanEmptyFoldersTask);
|
await run(CleanEmptyFoldersTask);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ export const CopySourceTask = {
|
||||||
select: [
|
select: [
|
||||||
'yarn.lock',
|
'yarn.lock',
|
||||||
'src/**',
|
'src/**',
|
||||||
'!src/**/*.test.{js,ts,tsx}',
|
'!src/**/*.{test,test.mocks,mock}.{js,ts,tsx}',
|
||||||
|
'!src/**/mocks.ts', // special file who imports .mock files
|
||||||
'!src/**/{__tests__,__snapshots__}/**',
|
'!src/**/{__tests__,__snapshots__}/**',
|
||||||
'!src/test_utils/**',
|
'!src/test_utils/**',
|
||||||
'!src/fixtures/**',
|
'!src/fixtures/**',
|
||||||
|
|
|
@ -33,7 +33,7 @@ export * from './notice_file_task';
|
||||||
export * from './optimize_task';
|
export * from './optimize_task';
|
||||||
export * from './os_packages';
|
export * from './os_packages';
|
||||||
export * from './transpile_babel_task';
|
export * from './transpile_babel_task';
|
||||||
export * from './transpile_typescript_task';
|
export * from './typecheck_typescript_task';
|
||||||
export * from './transpile_scss_task';
|
export * from './transpile_scss_task';
|
||||||
export * from './verify_env_task';
|
export * from './verify_env_task';
|
||||||
export * from './write_sha_sums_task';
|
export * from './write_sha_sums_task';
|
||||||
|
|
|
@ -22,31 +22,59 @@ import vfs from 'vinyl-fs';
|
||||||
|
|
||||||
import { createPromiseFromStreams } from '../../../legacy/utils';
|
import { createPromiseFromStreams } from '../../../legacy/utils';
|
||||||
|
|
||||||
|
const transpileWithBabel = async (srcGlobs, build, presets) => {
|
||||||
|
const buildRoot = build.resolvePath();
|
||||||
|
|
||||||
|
await createPromiseFromStreams([
|
||||||
|
vfs.src(
|
||||||
|
srcGlobs.concat([
|
||||||
|
'!**/*.d.ts',
|
||||||
|
'!packages/**',
|
||||||
|
'!**/node_modules/**',
|
||||||
|
'!**/bower_components/**',
|
||||||
|
'!**/__tests__/**',
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
cwd: buildRoot,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
gulpBabel({
|
||||||
|
babelrc: false,
|
||||||
|
presets,
|
||||||
|
}),
|
||||||
|
|
||||||
|
vfs.dest(buildRoot),
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
export const TranspileBabelTask = {
|
export const TranspileBabelTask = {
|
||||||
description: 'Transpiling sources with babel',
|
description: 'Transpiling sources with babel',
|
||||||
|
|
||||||
async run(config, log, build) {
|
async run(config, log, build) {
|
||||||
await createPromiseFromStreams([
|
// Transpile server code
|
||||||
vfs.src(
|
await transpileWithBabel(
|
||||||
[
|
[
|
||||||
'**/*.js',
|
'**/*.{js,ts,tsx}',
|
||||||
'!packages/**',
|
'!**/public/**',
|
||||||
'!**/public/**',
|
],
|
||||||
'!**/node_modules/**',
|
build,
|
||||||
'!**/bower_components/**',
|
[
|
||||||
'!**/__tests__/**',
|
require.resolve('@kbn/babel-preset/node_preset')
|
||||||
],
|
]
|
||||||
{
|
);
|
||||||
cwd: build.resolvePath(),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
|
|
||||||
gulpBabel({
|
// Transpile client code
|
||||||
babelrc: false,
|
// NOTE: For the client, as we have the optimizer, we are only
|
||||||
presets: [require.resolve('@kbn/babel-preset/node_preset')],
|
// pre-transpiling the typescript based files
|
||||||
}),
|
await transpileWithBabel(
|
||||||
|
[
|
||||||
vfs.dest(build.resolvePath()),
|
'**/public/**/*.{ts,tsx}',
|
||||||
]);
|
],
|
||||||
|
build,
|
||||||
|
[
|
||||||
|
require.resolve('@kbn/babel-preset/webpack_preset')
|
||||||
|
]
|
||||||
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,22 +20,13 @@
|
||||||
import { exec, write } from '../lib';
|
import { exec, write } from '../lib';
|
||||||
import { Project } from '../../typescript';
|
import { Project } from '../../typescript';
|
||||||
|
|
||||||
export const TranspileTypescriptTask = {
|
export const TypecheckTypescriptTask = {
|
||||||
description: 'Transpiling sources with typescript compiler',
|
description: 'Typechecking sources with typescript compiler',
|
||||||
|
|
||||||
async run(config, log, build) {
|
async run(config, log, build) {
|
||||||
// these projects are built in the build folder
|
// these projects are built in the build folder
|
||||||
const defaultProject = new Project(build.resolvePath('tsconfig.json'));
|
|
||||||
const browserProject = new Project(build.resolvePath('tsconfig.browser.json'));
|
const browserProject = new Project(build.resolvePath('tsconfig.browser.json'));
|
||||||
|
const defaultProject = new Project(build.resolvePath('tsconfig.json'));
|
||||||
// update the default config to exclude **/public/**/* files
|
|
||||||
await write(defaultProject.tsConfigPath, JSON.stringify({
|
|
||||||
...defaultProject.config,
|
|
||||||
exclude: [
|
|
||||||
...defaultProject.config.exclude,
|
|
||||||
'src/**/public/**/*'
|
|
||||||
]
|
|
||||||
}));
|
|
||||||
|
|
||||||
// update the browser config file to include **/public/**/* files
|
// update the browser config file to include **/public/**/* files
|
||||||
await write(browserProject.tsConfigPath, JSON.stringify({
|
await write(browserProject.tsConfigPath, JSON.stringify({
|
||||||
|
@ -47,21 +38,28 @@ export const TranspileTypescriptTask = {
|
||||||
]
|
]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// update the default config to exclude **/public/**/* files
|
||||||
|
await write(defaultProject.tsConfigPath, JSON.stringify({
|
||||||
|
...defaultProject.config,
|
||||||
|
exclude: [
|
||||||
|
...defaultProject.config.exclude,
|
||||||
|
'src/**/public/**/*'
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
|
||||||
const projects = [
|
const projects = [
|
||||||
// Browser needs to be compiled before server code so that any shared code
|
|
||||||
// is compiled to the lowest common denominator (server's CommonJS format)
|
|
||||||
// which can be supported by both environments.
|
|
||||||
browserProject.tsConfigPath,
|
browserProject.tsConfigPath,
|
||||||
defaultProject.tsConfigPath,
|
defaultProject.tsConfigPath,
|
||||||
];
|
];
|
||||||
|
|
||||||
// compile each typescript config file
|
// compile each typescript config file
|
||||||
for (const tsConfigPath of projects) {
|
for (const tsConfigPath of projects) {
|
||||||
log.info(`Compiling`, tsConfigPath, 'project');
|
log.info(`Typechecking`, tsConfigPath, 'project');
|
||||||
await exec(
|
await exec(
|
||||||
log,
|
log,
|
||||||
require.resolve('typescript/bin/tsc'),
|
require.resolve('typescript/bin/tsc'),
|
||||||
[
|
[
|
||||||
|
'--noEmit',
|
||||||
'--pretty', 'true',
|
'--pretty', 'true',
|
||||||
'--project', tsConfigPath,
|
'--project', tsConfigPath,
|
||||||
],
|
],
|
27
src/dev/i18n/integrate_locale_files.test.mocks.ts
Normal file
27
src/dev/i18n/integrate_locale_files.test.mocks.ts
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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 const mockWriteFileAsync = jest.fn();
|
||||||
|
export const mockMakeDirAsync = jest.fn();
|
||||||
|
jest.mock('./utils', () => ({
|
||||||
|
// Jest typings don't define `requireActual` for some reason.
|
||||||
|
...(jest as any).requireActual('./utils'),
|
||||||
|
writeFileAsync: mockWriteFileAsync,
|
||||||
|
makeDirAsync: mockMakeDirAsync,
|
||||||
|
}));
|
|
@ -17,14 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const mockWriteFileAsync = jest.fn();
|
import { mockMakeDirAsync, mockWriteFileAsync } from './integrate_locale_files.test.mocks';
|
||||||
const mockMakeDirAsync = jest.fn();
|
|
||||||
jest.mock('./utils', () => ({
|
|
||||||
// Jest typings don't define `requireActual` for some reason.
|
|
||||||
...(jest as any).requireActual('./utils'),
|
|
||||||
writeFileAsync: mockWriteFileAsync,
|
|
||||||
makeDirAsync: mockMakeDirAsync,
|
|
||||||
}));
|
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { integrateLocaleFiles, verifyMessages } from './integrate_locale_files';
|
import { integrateLocaleFiles, verifyMessages } from './integrate_locale_files';
|
||||||
|
|
|
@ -22,5 +22,5 @@ const babelJest = require('babel-jest');
|
||||||
module.exports = babelJest.createTransformer({
|
module.exports = babelJest.createTransformer({
|
||||||
presets: [
|
presets: [
|
||||||
require.resolve('@kbn/babel-preset/node_preset')
|
require.resolve('@kbn/babel-preset/node_preset')
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -59,11 +59,6 @@ export default {
|
||||||
coverageReporters: [
|
coverageReporters: [
|
||||||
'html',
|
'html',
|
||||||
],
|
],
|
||||||
globals: {
|
|
||||||
'ts-jest': {
|
|
||||||
skipBabel: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
moduleFileExtensions: [
|
moduleFileExtensions: [
|
||||||
'js',
|
'js',
|
||||||
'json',
|
'json',
|
||||||
|
@ -83,8 +78,7 @@ export default {
|
||||||
'integration_tests/'
|
'integration_tests/'
|
||||||
],
|
],
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.js$': '<rootDir>/src/dev/jest/babel_transform.js',
|
'^.+\\.(js|tsx?)$': '<rootDir>/src/dev/jest/babel_transform.js',
|
||||||
'^.+\\.tsx?$': '<rootDir>/src/dev/jest/ts_transform.js',
|
|
||||||
'^.+\\.txt?$': 'jest-raw-loader',
|
'^.+\\.txt?$': 'jest-raw-loader',
|
||||||
'^.+\\.html?$': 'jest-raw-loader',
|
'^.+\\.html?$': 'jest-raw-loader',
|
||||||
},
|
},
|
||||||
|
|
|
@ -18,6 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Note: In theory importing the polyfill should not be needed, as Babel should
|
// Note: In theory importing the polyfill should not be needed, as Babel should
|
||||||
// include the necessary polyfills when using `babel-preset-env`, but for some
|
// include the necessary polyfills when using `@babel/preset-env`, but for some
|
||||||
// reason it did not work. See https://github.com/elastic/kibana/issues/14506
|
// reason it did not work. See https://github.com/elastic/kibana/issues/14506
|
||||||
import '../../../setup_node_env/babel_register/polyfill';
|
import '../../../setup_node_env/babel_register/polyfill';
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 TsJest from 'ts-jest';
|
|
||||||
|
|
||||||
import { getTsProjectForAbsolutePath } from '../typescript';
|
|
||||||
|
|
||||||
const DEFAULT_TS_CONFIG_PATH = require.resolve('../../../tsconfig.json');
|
|
||||||
const DEFAULT_BROWSER_TS_CONFIG_PATH = require.resolve('../../../tsconfig.browser.json');
|
|
||||||
|
|
||||||
function extendJestConfigJSON(jestConfigJSON: string, filePath: string) {
|
|
||||||
const jestConfig = JSON.parse(jestConfigJSON) as jest.ProjectConfig;
|
|
||||||
return JSON.stringify(extendJestConfig(jestConfig, filePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
function extendJestConfig(jestConfig: jest.ProjectConfig, filePath: string) {
|
|
||||||
let tsConfigFile = getTsProjectForAbsolutePath(filePath).tsConfigPath;
|
|
||||||
|
|
||||||
// swap ts config file for jest tests
|
|
||||||
if (tsConfigFile === DEFAULT_BROWSER_TS_CONFIG_PATH) {
|
|
||||||
tsConfigFile = DEFAULT_TS_CONFIG_PATH;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...jestConfig,
|
|
||||||
globals: {
|
|
||||||
...(jestConfig.globals || {}),
|
|
||||||
'ts-jest': {
|
|
||||||
skipBabel: true,
|
|
||||||
tsConfigFile,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
canInstrument: true,
|
|
||||||
|
|
||||||
process(
|
|
||||||
src: string,
|
|
||||||
filePath: jest.Path,
|
|
||||||
jestConfig: jest.ProjectConfig,
|
|
||||||
transformOptions: jest.TransformOptions
|
|
||||||
) {
|
|
||||||
const extendedConfig = extendJestConfig(jestConfig, filePath);
|
|
||||||
return TsJest.process(src, filePath, extendedConfig, transformOptions);
|
|
||||||
},
|
|
||||||
|
|
||||||
getCacheKey(
|
|
||||||
src: string,
|
|
||||||
filePath: string,
|
|
||||||
jestConfigJSON: string,
|
|
||||||
transformOptions: jest.TransformOptions
|
|
||||||
) {
|
|
||||||
const extendedConfigJSON = extendJestConfigJSON(jestConfigJSON, filePath);
|
|
||||||
return TsJest.getCacheKey!(src, filePath, extendedConfigJSON, transformOptions);
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -105,5 +105,5 @@ export const LICENSE_OVERRIDES = {
|
||||||
'walk@2.3.9': ['MIT'],
|
'walk@2.3.9': ['MIT'],
|
||||||
|
|
||||||
// TODO remove this once we upgrade past or equal to v1.0.2
|
// TODO remove this once we upgrade past or equal to v1.0.2
|
||||||
'babel-plugin-mock-imports@0.0.5': ['MIT']
|
'babel-plugin-mock-imports@1.0.1': ['MIT']
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,7 +43,7 @@ export function runMochaCli() {
|
||||||
// check that we aren't leaking any globals
|
// check that we aren't leaking any globals
|
||||||
process.argv.push('--check-leaks');
|
process.argv.push('--check-leaks');
|
||||||
// prevent globals injected from canvas plugins from triggering leak check
|
// prevent globals injected from canvas plugins from triggering leak check
|
||||||
process.argv.push('--globals', 'core,regeneratorRuntime,_');
|
process.argv.push('--globals', '__core-js_shared__,core,_, ');
|
||||||
|
|
||||||
// ensure that mocha requires the setup_node_env script
|
// ensure that mocha requires the setup_node_env script
|
||||||
process.argv.push('--require', require.resolve('../../setup_node_env'));
|
process.argv.push('--require', require.resolve('../../setup_node_env'));
|
||||||
|
|
|
@ -222,6 +222,8 @@ exports[`Inspector Data View component should render loading state 1`] = `
|
||||||
},
|
},
|
||||||
"_eventsCount": 1,
|
"_eventsCount": 1,
|
||||||
"_maxListeners": undefined,
|
"_maxListeners": undefined,
|
||||||
|
"tabular": undefined,
|
||||||
|
"tabularOptions": undefined,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import 'babel-polyfill';
|
import '@babel/polyfill';
|
||||||
import { typeSpecs } from './index';
|
import { typeSpecs } from './index';
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
|
|
|
@ -1125,10 +1125,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
|
||||||
className="euiScreenReaderOnly"
|
className="euiScreenReaderOnly"
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="{resultCount} {resultCount, plural,
|
defaultMessage="{resultCount} {resultCount, plural, one {type} other {types} } found"
|
||||||
one {type}
|
|
||||||
other {types}
|
|
||||||
} found"
|
|
||||||
id="kbn.visualize.newVisWizard.resultsFound"
|
id="kbn.visualize.newVisWizard.resultsFound"
|
||||||
values={
|
values={
|
||||||
Object {
|
Object {
|
||||||
|
@ -1188,7 +1185,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
|
||||||
<div
|
<div
|
||||||
className="euiKeyPadMenuItem__icon"
|
className="euiKeyPadMenuItem__icon"
|
||||||
>
|
>
|
||||||
<Component
|
<VisTypeIcon
|
||||||
visType={
|
visType={
|
||||||
Object {
|
Object {
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
|
@ -1231,7 +1228,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
|
||||||
/>
|
/>
|
||||||
</empty>
|
</empty>
|
||||||
</EuiIcon>
|
</EuiIcon>
|
||||||
</Component>
|
</VisTypeIcon>
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
className="euiKeyPadMenuItem__label"
|
className="euiKeyPadMenuItem__label"
|
||||||
|
@ -1284,7 +1281,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
|
||||||
<div
|
<div
|
||||||
className="euiKeyPadMenuItem__icon"
|
className="euiKeyPadMenuItem__icon"
|
||||||
>
|
>
|
||||||
<Component
|
<VisTypeIcon
|
||||||
visType={
|
visType={
|
||||||
Object {
|
Object {
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
|
@ -1327,7 +1324,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
|
||||||
/>
|
/>
|
||||||
</empty>
|
</empty>
|
||||||
</EuiIcon>
|
</EuiIcon>
|
||||||
</Component>
|
</VisTypeIcon>
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
className="euiKeyPadMenuItem__label"
|
className="euiKeyPadMenuItem__label"
|
||||||
|
@ -1379,7 +1376,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
|
||||||
className="euiSpacer euiSpacer--m"
|
className="euiSpacer euiSpacer--m"
|
||||||
/>
|
/>
|
||||||
</EuiSpacer>
|
</EuiSpacer>
|
||||||
<Component>
|
<NewVisHelp>
|
||||||
<EuiText
|
<EuiText
|
||||||
grow={true}
|
grow={true}
|
||||||
size="m"
|
size="m"
|
||||||
|
@ -1398,7 +1395,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1`
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</EuiText>
|
</EuiText>
|
||||||
</Component>
|
</NewVisHelp>
|
||||||
</div>
|
</div>
|
||||||
</EuiFlexItem>
|
</EuiFlexItem>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2595,7 +2592,7 @@ exports[`NewVisModal should render as expected 1`] = `
|
||||||
<div
|
<div
|
||||||
className="euiKeyPadMenuItem__icon"
|
className="euiKeyPadMenuItem__icon"
|
||||||
>
|
>
|
||||||
<Component
|
<VisTypeIcon
|
||||||
visType={
|
visType={
|
||||||
Object {
|
Object {
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
|
@ -2638,7 +2635,7 @@ exports[`NewVisModal should render as expected 1`] = `
|
||||||
/>
|
/>
|
||||||
</empty>
|
</empty>
|
||||||
</EuiIcon>
|
</EuiIcon>
|
||||||
</Component>
|
</VisTypeIcon>
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
className="euiKeyPadMenuItem__label"
|
className="euiKeyPadMenuItem__label"
|
||||||
|
@ -2691,7 +2688,7 @@ exports[`NewVisModal should render as expected 1`] = `
|
||||||
<div
|
<div
|
||||||
className="euiKeyPadMenuItem__icon"
|
className="euiKeyPadMenuItem__icon"
|
||||||
>
|
>
|
||||||
<Component
|
<VisTypeIcon
|
||||||
visType={
|
visType={
|
||||||
Object {
|
Object {
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
|
@ -2734,7 +2731,7 @@ exports[`NewVisModal should render as expected 1`] = `
|
||||||
/>
|
/>
|
||||||
</empty>
|
</empty>
|
||||||
</EuiIcon>
|
</EuiIcon>
|
||||||
</Component>
|
</VisTypeIcon>
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
className="euiKeyPadMenuItem__label"
|
className="euiKeyPadMenuItem__label"
|
||||||
|
@ -2786,7 +2783,7 @@ exports[`NewVisModal should render as expected 1`] = `
|
||||||
className="euiSpacer euiSpacer--m"
|
className="euiSpacer euiSpacer--m"
|
||||||
/>
|
/>
|
||||||
</EuiSpacer>
|
</EuiSpacer>
|
||||||
<Component>
|
<NewVisHelp>
|
||||||
<EuiText
|
<EuiText
|
||||||
grow={true}
|
grow={true}
|
||||||
size="m"
|
size="m"
|
||||||
|
@ -2805,7 +2802,7 @@ exports[`NewVisModal should render as expected 1`] = `
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</EuiText>
|
</EuiText>
|
||||||
</Component>
|
</NewVisHelp>
|
||||||
</div>
|
</div>
|
||||||
</EuiFlexItem>
|
</EuiFlexItem>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* 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 const settingsGet = jest.fn();
|
||||||
|
|
||||||
|
jest.doMock('ui/chrome', () => ({
|
||||||
|
getUiSettingsClient: () => ({
|
||||||
|
get: settingsGet,
|
||||||
|
}),
|
||||||
|
}));
|
|
@ -20,13 +20,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mountWithIntl } from 'test_utils/enzyme_helpers';
|
import { mountWithIntl } from 'test_utils/enzyme_helpers';
|
||||||
|
|
||||||
const settingsGet = jest.fn();
|
import { settingsGet } from './new_vis_modal.test.mocks';
|
||||||
|
|
||||||
jest.mock('ui/chrome', () => ({
|
|
||||||
getUiSettingsClient: () => ({
|
|
||||||
get: settingsGet,
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
|
|
||||||
import { NewVisModal } from './new_vis_modal';
|
import { NewVisModal } from './new_vis_modal';
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ export const createTestEntryTemplate = (defaultUiSettings) => (bundle) => `
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// import global polyfills before everything else
|
// import global polyfills before everything else
|
||||||
import 'babel-polyfill';
|
import '@babel/polyfill';
|
||||||
import 'custom-event-polyfill';
|
import 'custom-event-polyfill';
|
||||||
import 'whatwg-fetch';
|
import 'whatwg-fetch';
|
||||||
import 'abortcontroller-polyfill';
|
import 'abortcontroller-polyfill';
|
||||||
|
|
|
@ -14,7 +14,7 @@ exports[`ScriptingHelpFlyout should render normally 1`] = `
|
||||||
<EuiTabbedContent
|
<EuiTabbedContent
|
||||||
initialSelectedTab={
|
initialSelectedTab={
|
||||||
Object {
|
Object {
|
||||||
"content": <Unknown />,
|
"content": <ScriptingSyntax />,
|
||||||
"data-test-subj": "syntaxTab",
|
"data-test-subj": "syntaxTab",
|
||||||
"id": "syntax",
|
"id": "syntax",
|
||||||
"name": "Syntax",
|
"name": "Syntax",
|
||||||
|
@ -23,7 +23,7 @@ exports[`ScriptingHelpFlyout should render normally 1`] = `
|
||||||
tabs={
|
tabs={
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"content": <Unknown />,
|
"content": <ScriptingSyntax />,
|
||||||
"data-test-subj": "syntaxTab",
|
"data-test-subj": "syntaxTab",
|
||||||
"id": "syntax",
|
"id": "syntax",
|
||||||
"name": "Syntax",
|
"name": "Syntax",
|
||||||
|
|
|
@ -47,9 +47,7 @@ exports[`LanguageSwitcher should toggle off if language is lucene 1`] = `
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="The {docsLink} (KQL) offers a simplified query
|
defaultMessage="The {docsLink} (KQL) offers a simplified query syntax and support for scripted fields. KQL also provides autocomplete if you have a Basic license or above. If you turn off KQL, Kibana uses Lucene."
|
||||||
syntax and support for scripted fields. KQL also provides autocomplete if you have
|
|
||||||
a Basic license or above. If you turn off KQL, Kibana uses Lucene."
|
|
||||||
id="common.ui.queryBar.syntaxOptionsDescription"
|
id="common.ui.queryBar.syntaxOptionsDescription"
|
||||||
values={
|
values={
|
||||||
Object {
|
Object {
|
||||||
|
@ -154,9 +152,7 @@ exports[`LanguageSwitcher should toggle on if language is kuery 1`] = `
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="The {docsLink} (KQL) offers a simplified query
|
defaultMessage="The {docsLink} (KQL) offers a simplified query syntax and support for scripted fields. KQL also provides autocomplete if you have a Basic license or above. If you turn off KQL, Kibana uses Lucene."
|
||||||
syntax and support for scripted fields. KQL also provides autocomplete if you have
|
|
||||||
a Basic license or above. If you turn off KQL, Kibana uses Lucene."
|
|
||||||
id="common.ui.queryBar.syntaxOptionsDescription"
|
id="common.ui.queryBar.syntaxOptionsDescription"
|
||||||
values={
|
values={
|
||||||
Object {
|
Object {
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* 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 mockChromeFactory = jest.fn(() => {
|
||||||
|
return {
|
||||||
|
getBasePath: () => `foo`,
|
||||||
|
getUiSettingsClient: () => {
|
||||||
|
return {
|
||||||
|
get: (key: string) => {
|
||||||
|
switch (key) {
|
||||||
|
case 'history:limit':
|
||||||
|
return 10;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unexpected config key: ${key}`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
export const mockPersistedLog = {
|
||||||
|
add: jest.fn(),
|
||||||
|
get: jest.fn(() => ['response:200']),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const mockPersistedLogFactory = jest.fn<jest.Mocked<typeof mockPersistedLog>, any>(() => {
|
||||||
|
return mockPersistedLog;
|
||||||
|
});
|
||||||
|
|
||||||
|
export const mockGetAutocompleteSuggestions = jest.fn(() => Promise.resolve([]));
|
||||||
|
const mockAutocompleteProvider = jest.fn(() => mockGetAutocompleteSuggestions);
|
||||||
|
export const mockGetAutocompleteProvider = jest.fn(() => mockAutocompleteProvider);
|
||||||
|
|
||||||
|
jest.mock('ui/chrome', () => mockChromeFactory());
|
||||||
|
jest.mock('../../chrome', () => mockChromeFactory());
|
||||||
|
jest.mock('ui/persisted_log', () => ({
|
||||||
|
PersistedLog: mockPersistedLogFactory,
|
||||||
|
}));
|
||||||
|
jest.mock('../../metadata', () => ({
|
||||||
|
metadata: {
|
||||||
|
branch: 'foo',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
jest.mock('../../autocomplete_providers', () => ({
|
||||||
|
getAutocompleteProvider: mockGetAutocompleteProvider,
|
||||||
|
}));
|
||||||
|
|
||||||
|
import _ from 'lodash';
|
||||||
|
// Using doMock to avoid hoisting so that I can override only the debounce method in lodash
|
||||||
|
jest.doMock('lodash', () => ({
|
||||||
|
..._,
|
||||||
|
debounce: (func: () => any) => func,
|
||||||
|
}));
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue