diff --git a/packages/kbn-test/jest-preset.js b/packages/kbn-test/jest-preset.js index f899a5b44ab6c1..63457aa3cc37d4 100644 --- a/packages/kbn-test/jest-preset.js +++ b/packages/kbn-test/jest-preset.js @@ -48,7 +48,6 @@ module.exports = { '^(!!)?file-loader!': '/packages/kbn-test/target/jest/mocks/file_mock.js', '^fixtures/(.*)': '/src/fixtures/$1', '^src/core/(.*)': '/src/core/$1', - '^src/legacy/(.*)': '/src/legacy/$1', '^src/plugins/(.*)': '/src/plugins/$1', }, diff --git a/packages/kbn-test/src/index.ts b/packages/kbn-test/src/index.ts index 3e4a62387d1bf4..9e6ba67a421ac4 100644 --- a/packages/kbn-test/src/index.ts +++ b/packages/kbn-test/src/index.ts @@ -58,3 +58,5 @@ export { runFailedTestsReporterCli } from './failed_tests_reporter'; export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix'; export * from './functional_test_runner'; + +export { getUrl } from './jest/utils/get_url'; diff --git a/packages/kbn-test/src/jest/utils/index.ts b/packages/kbn-test/src/jest/utils/index.ts index f85160652828b6..808f049cda6d8b 100644 --- a/packages/kbn-test/src/jest/utils/index.ts +++ b/packages/kbn-test/src/jest/utils/index.ts @@ -19,6 +19,8 @@ export * from './enzyme_helpers'; +export * from './get_url'; + export * from './find_test_subject'; export * from './jsdom_svg_mocks'; diff --git a/src/core/tsconfig.json b/src/core/tsconfig.json index 4281559c9aa140..e8a82ee533f11f 100644 --- a/src/core/tsconfig.json +++ b/src/core/tsconfig.json @@ -14,8 +14,5 @@ "test_helpers/**/*", "utils/**/*", "index.ts" - ], - "references": [ - { "path": "../test_utils/" } ] } diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 050ef8b861e43b..ec4f78ad150923 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -35,7 +35,6 @@ export default { '/src/legacy/utils', '/src/setup_node_env', '/packages', - '/src/test_utils', '/test/functional/services/remote', ], testRunner: 'jasmine2', diff --git a/src/dev/typescript/projects.ts b/src/dev/typescript/projects.ts index 9891e9fa02c82d..6a13a86ba55a54 100644 --- a/src/dev/typescript/projects.ts +++ b/src/dev/typescript/projects.ts @@ -27,7 +27,6 @@ export const PROJECTS = [ new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), { name: 'kibana/test' }), new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')), new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), { name: 'x-pack/test' }), - new Project(resolve(REPO_ROOT, 'src/test_utils/tsconfig.json')), new Project(resolve(REPO_ROOT, 'src/core/tsconfig.json')), new Project(resolve(REPO_ROOT, 'x-pack/plugins/security_solution/cypress/tsconfig.json'), { name: 'security_solution/cypress', diff --git a/src/plugins/kibana_utils/tsconfig.json b/src/plugins/kibana_utils/tsconfig.json index bd65e06c786087..ae5e9b90af8077 100644 --- a/src/plugins/kibana_utils/tsconfig.json +++ b/src/plugins/kibana_utils/tsconfig.json @@ -16,7 +16,6 @@ "../../../typings/**/*" ], "references": [ - { "path": "../../test_utils/tsconfig.json" }, { "path": "../../core/tsconfig.json" } ] } diff --git a/src/test_utils/__tests__/get_url.js b/src/test_utils/__tests__/get_url.js deleted file mode 100644 index c9dd4d5a6d6168..00000000000000 --- a/src/test_utils/__tests__/get_url.js +++ /dev/null @@ -1,67 +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 expect from '@kbn/expect'; -import getUrl from '../get_url'; - -describe('getUrl', function () { - it('should convert to a url', function () { - const url = getUrl( - { - protocol: 'http', - hostname: 'localhost', - }, - { - pathname: 'foo', - } - ); - - expect(url).to.be('http://localhost/foo'); - }); - - it('should convert to a url with port', function () { - const url = getUrl( - { - protocol: 'http', - hostname: 'localhost', - port: 9220, - }, - { - pathname: 'foo', - } - ); - - expect(url).to.be('http://localhost:9220/foo'); - }); - - it('should convert to a secure hashed url', function () { - expect( - getUrl( - { - protocol: 'https', - hostname: 'localhost', - }, - { - pathname: 'foo', - hash: 'bar', - } - ) - ).to.be('https://localhost/foo#bar'); - }); -}); diff --git a/src/test_utils/get_url.js b/src/test_utils/get_url.js deleted file mode 100644 index 182cb8e6e118db..00000000000000 --- a/src/test_utils/get_url.js +++ /dev/null @@ -1,55 +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 _ from 'lodash'; -import url from 'url'; - -/** - * Converts a config and a pathname to a url - * @param {object} config A url config - * example: - * { - * protocol: 'http', - * hostname: 'localhost', - * port: 9220, - * auth: kibanaTestUser.username + ':' + kibanaTestUser.password - * } - * @param {object} app The params to append - * example: - * { - * pathname: 'app/kibana', - * hash: '/discover' - * } - * @return {string} - */ - -export default function getUrl(config, app) { - return url.format(_.assign({}, config, app)); -} - -getUrl.noAuth = function getUrlNoAuth(config, app) { - config = _.pickBy(config, function (val, param) { - return param !== 'auth'; - }); - return getUrl(config, app); -}; - -getUrl.baseUrl = function getBaseUrl(config) { - return url.format(_.pick(config, 'protocol', 'hostname', 'port')); -}; diff --git a/src/test_utils/public/key_map.ts b/src/test_utils/public/key_map.ts deleted file mode 100644 index aac3c6b2db3e0e..00000000000000 --- a/src/test_utils/public/key_map.ts +++ /dev/null @@ -1,121 +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. - */ - -export const keyMap: { [key: number]: string } = { - 8: 'backspace', - 9: 'tab', - 13: 'enter', - 16: 'shift', - 17: 'ctrl', - 18: 'alt', - 19: 'pause', - 20: 'capsLock', - 27: 'escape', - 32: 'space', - 33: 'pageUp', - 34: 'pageDown', - 35: 'end', - 36: 'home', - 37: 'left', - 38: 'up', - 39: 'right', - 40: 'down', - 45: 'insert', - 46: 'delete', - 48: '0', - 49: '1', - 50: '2', - 51: '3', - 52: '4', - 53: '5', - 54: '6', - 55: '7', - 56: '8', - 57: '9', - 65: 'a', - 66: 'b', - 67: 'c', - 68: 'd', - 69: 'e', - 70: 'f', - 71: 'g', - 72: 'h', - 73: 'i', - 74: 'j', - 75: 'k', - 76: 'l', - 77: 'm', - 78: 'n', - 79: 'o', - 80: 'p', - 81: 'q', - 82: 'r', - 83: 's', - 84: 't', - 85: 'u', - 86: 'v', - 87: 'w', - 88: 'x', - 89: 'y', - 90: 'z', - 91: 'leftWindowKey', - 92: 'rightWindowKey', - 93: 'selectKey', - 96: '0', - 97: '1', - 98: '2', - 99: '3', - 100: '4', - 101: '5', - 102: '6', - 103: '7', - 104: '8', - 105: '9', - 106: 'multiply', - 107: 'add', - 109: 'subtract', - 110: 'period', - 111: 'divide', - 112: 'f1', - 113: 'f2', - 114: 'f3', - 115: 'f4', - 116: 'f5', - 117: 'f6', - 118: 'f7', - 119: 'f8', - 120: 'f9', - 121: 'f10', - 122: 'f11', - 123: 'f12', - 144: 'numLock', - 145: 'scrollLock', - 186: 'semiColon', - 187: 'equalSign', - 188: 'comma', - 189: 'dash', - 190: 'period', - 191: 'forwardSlash', - 192: 'graveAccent', - 219: 'openBracket', - 220: 'backSlash', - 221: 'closeBracket', - 222: 'singleQuote', - 224: 'meta', -}; diff --git a/src/test_utils/tsconfig.json b/src/test_utils/tsconfig.json deleted file mode 100644 index 2fa89e29898914..00000000000000 --- a/src/test_utils/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./target", - "composite": true, - "emitDeclarationOnly": true, - "declaration": true, - "declarationMap": true - }, - "include": [ - "public/**/*" - ], - "exclude": [ - "target" - ] -} diff --git a/test/common/services/deployment.ts b/test/common/services/deployment.ts index 88389b57dd1db2..cad7a87e39f7c8 100644 --- a/test/common/services/deployment.ts +++ b/test/common/services/deployment.ts @@ -19,8 +19,7 @@ import { get } from 'lodash'; import fetch from 'node-fetch'; -// @ts-ignore not TS yet -import getUrl from '../../../src/test_utils/get_url'; +import { getUrl } from '@kbn/test'; import { FtrProviderContext } from '../ftr_provider_context'; diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 31df98bb23c1e2..b825853e794f31 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -21,9 +21,8 @@ import { delay } from 'bluebird'; import expect from '@kbn/expect'; // @ts-ignore import fetch from 'node-fetch'; +import { getUrl } from '@kbn/test'; import { FtrProviderContext } from '../ftr_provider_context'; -// @ts-ignore not TS yet -import getUrl from '../../../src/test_utils/get_url'; export function CommonPageProvider({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); diff --git a/test/functional/page_objects/context_page.ts b/test/functional/page_objects/context_page.ts index 9cbada532cde32..ce5ffad87e8f38 100644 --- a/test/functional/page_objects/context_page.ts +++ b/test/functional/page_objects/context_page.ts @@ -18,9 +18,8 @@ */ import rison from 'rison-node'; +import { getUrl } from '@kbn/test'; import { FtrProviderContext } from '../ftr_provider_context'; -// @ts-ignore not TS yet -import getUrl from '../../../src/test_utils/get_url'; const DEFAULT_INITIAL_STATE = { columns: ['@message'], diff --git a/test/server_integration/http/platform/headers.ts b/test/server_integration/http/platform/headers.ts index 50cfa5c7022312..9361d3131b7199 100644 --- a/test/server_integration/http/platform/headers.ts +++ b/test/server_integration/http/platform/headers.ts @@ -18,11 +18,9 @@ */ import Http from 'http'; import Url from 'url'; +import { getUrl } from '@kbn/test'; import { FtrProviderContext } from '../../services/types'; -// @ts-ignore -import getUrl from '../../../../src/test_utils/get_url'; - const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); const oneSec = 1_000; diff --git a/tsconfig.base.json b/tsconfig.base.json index 111c9dbc949de0..247813da51cfb3 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -6,10 +6,6 @@ "kibana": ["./kibana"], "kibana/public": ["src/core/public"], "kibana/server": ["src/core/server"], - "plugins/*": ["src/legacy/core_plugins/*/public/"], - "test_utils/*": [ - "src/test_utils/public/*" - ], "fixtures/*": ["src/fixtures/*"] }, // Support .tsx files and transform JSX into calls to React.createElement diff --git a/tsconfig.json b/tsconfig.json index 6e137e445762de..02048414f678e3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "incremental": false }, - "include": ["kibana.d.ts", "src/**/*", "typings/**/*", "test_utils/**/*"], + "include": ["kibana.d.ts", "src/**/*", "typings/**/*"], "exclude": [ "src/**/__fixtures__/**/*", "src/core/**/*", @@ -20,7 +20,6 @@ "src/plugins/telemetry_collection_manager/**/*", "src/plugins/url_forwarding/**/*", "src/plugins/usage_collection/**/*", - "src/test_utils/**/*" // In the build we actually exclude **/public/**/* from this config so that // we can run the TSC on both this and the .browser version of this config // file, but if we did it during development IDEs would not be able to find @@ -42,6 +41,5 @@ { "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "./src/plugins/url_forwarding/tsconfig.json" }, { "path": "./src/plugins/usage_collection/tsconfig.json" }, - { "path": "./src/test_utils/tsconfig.json" } ] } diff --git a/tsconfig.refs.json b/tsconfig.refs.json index 55d63f516b998f..a99d4d57d3f0ac 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -15,6 +15,5 @@ { "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "./src/plugins/url_forwarding/tsconfig.json" }, { "path": "./src/plugins/usage_collection/tsconfig.json" }, - { "path": "./src/test_utils/tsconfig.json" } ] } diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index 12782e6bdd5eaf..87dcc939a4eb6d 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "../tsconfig.base.json", - "include": ["mocks.ts", "typings/**/*", "plugins/**/*", "test_utils/**/*", "tasks/**/*"], + "include": ["mocks.ts", "typings/**/*", "plugins/**/*", "tasks/**/*"], "exclude": [ "plugins/apm/e2e/cypress/**/*", "plugins/apm/scripts/**/*", @@ -11,12 +11,6 @@ "test/**/*" ], "compilerOptions": { - "paths": { - "kibana/public": ["src/core/public"], - "kibana/server": ["src/core/server"], - "test_utils/*": ["x-pack/test_utils/*"], - "fixtures/*": ["src/fixtures/*"] - }, // overhead is too significant "incremental": false }, @@ -35,7 +29,6 @@ { "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "../src/plugins/url_forwarding/tsconfig.json" }, { "path": "../src/plugins/usage_collection/tsconfig.json" }, - { "path": "../src/test_utils/tsconfig.json" }, { "path": "./plugins/global_search/tsconfig.json" }, { "path": "./plugins/licensing/tsconfig.json" },