From cee11cce0f5bf94d0404be01f19383b27bad4023 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Wed, 11 Nov 2020 21:43:02 -0800 Subject: [PATCH] Removes rest of x-pack/test_utils Signed-off-by: Tyler Smalley --- x-pack/test_utils/README.md | 332 ------------------ .../test_subjects_finder/background.js | 27 -- .../test_subjects_finder/images/kibana128.png | Bin 2658 -> 0 bytes .../test_subjects_finder/images/kibana16.png | Bin 2658 -> 0 bytes .../test_subjects_finder/images/kibana32.png | Bin 2658 -> 0 bytes .../test_subjects_finder/images/kibana48.png | Bin 2658 -> 0 bytes .../test_subjects_finder/images/kibana64.png | Bin 2658 -> 0 bytes .../test_subjects_finder/manifest.json | 26 -- .../test_subjects_finder/popup.html | 49 --- .../test_subjects_finder/popup.js | 104 ------ .../start_tracking_test_subjects.js | 164 --------- .../stop_tracking_test_subjects.js | 11 - .../test_subjects_finder/style.css | 110 ------ x-pack/test_utils/get_config_schema.ts | 17 - x-pack/test_utils/index.ts | 8 - x-pack/test_utils/jest/config.integration.js | 28 -- x-pack/test_utils/jest/config.js | 49 --- x-pack/test_utils/kbn_server_config.ts | 34 -- x-pack/test_utils/lib/index.ts | 7 - x-pack/test_utils/lib/utils.ts | 18 - 20 files changed, 984 deletions(-) delete mode 100644 x-pack/test_utils/README.md delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/background.js delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana128.png delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana16.png delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana32.png delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana48.png delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana64.png delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/manifest.json delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/popup.html delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/popup.js delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/start_tracking_test_subjects.js delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/stop_tracking_test_subjects.js delete mode 100644 x-pack/test_utils/chrome_extension/test_subjects_finder/style.css delete mode 100644 x-pack/test_utils/get_config_schema.ts delete mode 100644 x-pack/test_utils/index.ts delete mode 100644 x-pack/test_utils/jest/config.integration.js delete mode 100644 x-pack/test_utils/jest/config.js delete mode 100644 x-pack/test_utils/kbn_server_config.ts delete mode 100644 x-pack/test_utils/lib/index.ts delete mode 100644 x-pack/test_utils/lib/utils.ts diff --git a/x-pack/test_utils/README.md b/x-pack/test_utils/README.md deleted file mode 100644 index ee36f13e2f6d0..0000000000000 --- a/x-pack/test_utils/README.md +++ /dev/null @@ -1,332 +0,0 @@ -# Testbed utils - -The Testbed is a small library to help testing React components. It is most useful when testing application "sections" (or pages) in **integration** -than when unit testing single components in isolation. - -## Motivation - -The Elasticsearch UI team built this to support client-side integration testing. When testing complete "pages" we get to test -our application in a way that is closer to how a user would interact with it in a browser. It also gives us more confidence in -our tests and avoids testing implementation details. - -We test everything up to the HTTP Requests made from the client to the Node.js API server. Those requests need to be mocked. This means that with a good -**API integration test** coverage of those endpoints, we can reduce the functional tests to a minimum. - -With this in mind, we needed a way to easily mount a component on a React Router `` (this component could possibily have _child_ routes and -need access to the browser URL parameters and query params). In order to solve that, the Testbed wraps the component around a `MemoryRouter`. - -On the other side, the majority of our current applications use Redux as state management so we needed a simple way to wrap our component under test -inside a redux store provider. - -## How to use it - -At the top of your test file (you only need to declare it once), register a new Testbed by providing a React Component and an optional configuration object. -You receive in return a function that you need to call to mount the component in your test. - -**Example 1** - -```ts -// remote_clusters_list.helpers.ts - -import { registerTestBed } from '@kbn/test/jest'; -import { RemoteClusterList } from '../../app/sections/remote_cluster_list'; -import { remoteClustersStore } from '../../app/store'; -import routing from '../../app/services/routing'; - -const config = { - memoryRouter: { - onRouter(router) { - routing.registerRouter(router); // send the router instance to the routing service - }, - initialEntries: ['/some-resource-name'], // the Router initial URL - componentRoutePath: '/:name' // the Component path - }, - store: remoteClusterStore -}; - -export const setup = registerTestBed(RemoteClusterList, config); -``` - -Once you have registered a TestBed, you can call the `setup()` function to mount the component in your tests. You will get an object -back with a set of utility methods to test the component (refer to the documentation below for a complete list of the methods available). - -```ts -// remote_cluster.test.ts - -import { setup } from './remote_clusters_list.helpers.ts'; - -describe('', () => { - test('it should have a table with 3 rows', () => { - const { component, exists, find } = setup(); - - // component is an Enzyme reactWrapper - console.log(component.debug()); - - expect(exists('remoteClusterTable')).toBe(true); - expect(find('remoteClusterTable.row').length).toBe(3); - }); -}); -``` - -## Test subjects - -The Testbed utils are meant to be used with test subjects. Test subjects are elements that are tagged specifically for selecting from tests. Use test subjects over CSS selectors when possible. - -```html -
-
-``` - -```ts -find('containerButton').simulate('click'); -``` - -If you need to access a CSS selector, target first the closest test subject. - -```ts -const text = find('containerButton').find('.link--active').text(); -``` - -## Typescript - -If you use Typescript, you can provide a string union type for your test subjects and you will get **autocomplete** on the test subjects in your test. To automate finding all the subjects on the page, use the Chrome extension below. - -```ts -type TestSubjects = 'indicesTable' | 'createIndexButton' | 'pageTitle'; - -export const setup = registerTestBed(MyComponent); -``` - -## Best practices - -In order to prevent flakiness in component integration tests, please consider the following best practices: - -- **Use** `jest.useFakeTimers()`. - - The code under a test might be using `setTimeout()` calls. This is bad for deterministic tests. In order to avoid it, we need to use mocked timers from jest. For that we declare at the top of each component integration test the following: -​ - ```js - beforeAll(() => { - jest.useFakeTimers(); - }); - ​ - afterAll(() => { - jest.useRealTimers(); - }); - ``` - -- **Do not use** using `nextTick()`, `waitFor`, or `waitForFunc` helpers in tests. These helpers use `setTimeout` underneath and add latency in the tests, especially on CI where a timeout (even of a few ms) can trigger a timeout error. These helpers will eventually be deprecated once existing tests has been updated. - -- **Do not declare** `component.update()` inside `act()`. Each `act()` call should contain a chunk of actions that updates the internal state(s). The `component.update()` that re-renders the internal DOM needs to be called outside, before asserting against the updated DOM. - -- Be **synchronous** as much as possible. -​ - Hooks are delicate when it comes to state updates. Sometimes calling `act()` synchronously works, sometimes it doesn't. The reasoning behind this isn't clear yet. The best approach is to try synchronously first and if it fails, because of an `act()` error, then use the async version. - - ```js - // First try this - act(() => { - find('someTestSubject').simulate('click'); - }); - component.update(); - ​ - // If there is a "missing `act()` error", then change it to - await act(async () => { - find('someTestSubject').simulate('click'); - }); - component.update(); - ``` - -## Chrome extension - -There is a small Chrome extension that you can install in order to track the test subjects on the current page. As it is meant to be used -during development, the extension is only active when navigating to a `localhost` URL. - -You will find the "Test subjects finder" extension in the `x-pack/test_utils/chrome_extension` folder. - -### Install the extension - -- open the "extensions" window in Chrome -- activate the "Developer mode" (top right corner) -- drag and drop the `test_subjects_finder` folder on the window. - -You can specify a DOM node (the tree "root") from which the test subjects will be found. If you don't specify any, the document `` will be used. The output format can either be `Typescript` (to export a string union type) or `List`. - -### Output - -Once you start tracking the test subjects on the page, the output will be printed in the **Chrome dev console**. - -## API - -## `registerTestBed(Component [, testBedConfig])` - -Instantiate a new TestBed to test a React component. The arguments it receives are - -- `Component` (the React component to test) -- `testBedConfig` (optional). An optional Testbed configuration object. - -**@returns** A function to instantiate and mount the component. - -### `testBedConfig` - -The `testBedConfig` has the following properties (all **optional**) - -- `defaultProps` The default props to pass to the mounted component. Those props can be overriden when calling the `setup([props])` callback -- `memoryRouter` Configuration object for the react-router `MemoryRouter` with the following properties - - `wrapComponent` Flag to provide or not a `MemoryRouter`. If set to `false`, there won't be any router and the component won't be added on a ``. (default: `true`) - - `initialEntries` The React Router **initial entries** setting. (default: `['/']`. [see doc](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/MemoryRouter.md)) - - `initialIndex` The React Router **initial index** setting (default: `0`) - - `componentRoutePath` The route **path** for the mounted component (default: `"/"`) - - `onRouter` A callback that will be called with the React Router instance when the component is mounted -- `store` A redux store. You can also provide a function that returns a store. (default: `null`) - - -## `setup([props])` - -When registering a Testbed, you receive in return a setup function. This function accepts one optional argument: - -- `props` (optional) Props to pass to the mounted component. - -```js -describe('', () => { - test('it should be green', () => { - // Will mount - const { component } = setup({ color: 'green' }); - ... - }); -}); -``` - -**@returns** An object with the following **properties** and **helpers** for testing - -#### `component` - -The mounted component. It is an enzyme **reactWrapper**. - -#### `exists(testSubject)` - -Pass it a `data-test-subj` and it will return true if it exists or false if it does not exist. You can provide a nested path to access the -test subject by separating the parent and child with a dot (e.g. `myForm.followerIndexName`). - -```js -const { exists } = setup(); -expect(exists('myTestSubject')).toBe(true); -``` - -#### `find(testDataSubject)` - -Pass it a `data-test-subj` and it will return an Enzyme reactWrapper of the node. You can provide a nested path to access the -test subject by separating the parent and child with a dot (e.g. `myForm.followerIndexName`). - -```js -const { find } = setup(); - -const someNode = find('myTestSubject'); -expect(someNode.text()).toBe('hello'); -``` - -#### `setProps(props)` - -Update the props passed to a component. - -**Important**: This method can only be used on a Component that is _not_ wrapped by a ``. - -```js -... - -const { setup } = registerTestBed(RemoteClusterList); - -describe('', () => { - - test('it should work', () => { - const { exists, find, setProps } = setup(); - // test logic... - - // update the props of the component - setProps({ color: 'yellow' }); - ... - }); -}); -``` - -#### `table` - -An object with the following methods: - -##### `getMetaData(testSubject)` - -Parse an EUI table and return metadata information about its rows and columns. You can provide a nested path to access the -test subject by separating the parent and child with a dot (e.g. `mySection.myTable`). It returns an object with two properties: - -- `tableCellsValues` a two dimensional array of rows + columns with the text content of each cell of the table -- `rows` an array of row objects. A row object has the following two properties: - - `reactWrapper` the Enzyme react wrapper of the `tr` element. - - `columns` an array of columns objects. A column object has two properties: - - `reactWrapper` the Enzyme react wrapper for the table row `td` - - `value` the text content of the table cell - -```html - - - - - - - - - -
Row 0, column 0Row 0, column 1
Row 1, column 0Row 1, column 1
-``` - -```js -const { table: { getMetaData } } = setup(); -const { tableCellsValues } = getMetaData('myTable'); - -expect(tableCellsValues).toEqual([ - ['Row 0, column 0'], ['Row 0, column 1'], - ['Row 1, column 0'], ['Row 1, column 1'], -]); -``` - -#### `form` - -An object with the following methods: - -##### `setInputValue(input, value, isAsync)` - -Set the value of a form input. The input can either be a test subject (a string) or an Enzyme react wrapper. If you specify a test subject, -you can provide a nested path to access it by separating the parent and child with a dot (e.g. `myForm.followerIndexName`). - -`isAsync`: flag that will return a Promise that resolves on the next "tick". This is useful if updating the input triggers -an async operation (like a HTTP request) and we need it to resolve so the DOM gets updated (default: `false`). - -```js -await form.setInputValue('myInput', 'some value', true); -``` - -##### `selectCheckBox(testSubject)` - -Select a form checkbox. - -##### `toggleEuiSwitch(testSubject)` - -Toggle an Eui Switch. - -##### `setComboBoxValue(testSubject, value)` - -The EUI `` component is special in the sense that it needs the keyboard ENTER key to be pressed -in order to register the value provided. This helper takes care of that. - -##### `getErrorsMessages()` - -Find all the DOM nodes with the `.euiFormErrorText` css class from EUI and return an Array with its text content. - -#### `router` - -An object with the following methods: - -##### `navigateTo(url)` - -If you need to navigate to a different route inside your test and you are not using the `` component from `react-router` -in your component, you need to use the `router.navigateTo()` method from the testBed in order to trigger the route change on the `MemoryRouter`. diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/background.js b/x-pack/test_utils/chrome_extension/test_subjects_finder/background.js deleted file mode 100644 index c57ba4458e646..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/background.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* eslint-disable no-undef */ -chrome.runtime.onInstalled.addListener(function () { - chrome.storage.sync.set({ outputType: 'typescript' }); - - chrome.declarativeContent.onPageChanged.removeRules(undefined, () => { - // Only activate the plugin on localhost - chrome.declarativeContent.onPageChanged.addRules([ - { - conditions: [ - new chrome.declarativeContent.PageStateMatcher({ - pageUrl: { hostEquals: 'localhost' }, - }), - new chrome.declarativeContent.PageStateMatcher({ - pageUrl: { hostEquals: 'kibana-dev' }, - }), - ], - actions: [new chrome.declarativeContent.ShowPageAction()], - }, - ]); - }); -}); diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana128.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana128.png deleted file mode 100644 index d88ec6d8b4e4284637f718e417ec23e4e17843fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2658 zcmV-o3Z3A|#Y-T-M8%V9kM5B1gt@8OK*4Zu+?R~XvaT^qdBz_5N4djsTZGt&)2!0&s;-m%Dx z-Z`EQ`Bt?z09Uz;aYS^a({wJnq;}UoB%^o(NYu*+OGIPsE!@zxYv{0a1aAPTg6{FB z(ZZ^p`rwF0Yi|Gz6&-Sz7VhY-5AM)v=?$QzqyruTZSAcMZP9Gy4WOx}MJ@t8+FKji zsNKRFKwD88d_)JjPaN$tqgy7l>AeB86;S1N6jix=*^`*n3{0NwyLRMp}n9K(cJ z-1E$)KWkB*&*KeXOIaZ=f&N=Dm7sfg({F`TbHcp=Y^uxV=0&@lcHRIS)huJU(Jp5! zZvc*JHZepG_e4X3He0-%+Z(`@(uw-ep6;=ut8DzaH(PsefJ7T(zi2AjMaK=McGn5} z-QMcp4d7DkS$b(jyPTzX18`JR#ArsloUyzCII8JkRHI$aSl$2})s!&W(Jp5!Zvc*J z8W_S4dZNJxG^ivT-T)Hy*jU*~UUu6VfZhO_Y9`^DigqswBqw>3v`Jdy4UkkRl{&l8 zE@wn<0FG)LjDu*GGnO|1N41m~SJ7_Dv8Kws0XV9q#1NTvY2VsS*@9i}4ZxNz8PLW_ z-ejGVRe1v>(}`7O>m)C0m{~yH0Get}<8mMEa+cx^z)|f2n5?2*&QiPqII7Ko$uipI zEX5muquMN(tfO7dQoI2;s?CU@7FuSd)?2%3V_ksA8$d~EmnV6ZM)v;*(h^c~Nt4zL zTps@f;3{_xm!D{tvlMRtj%sHyIg55VOYsKas5XVkU$o0viZ=j9wVXz~oTYdJq*v{< zF{a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ShA!=u7mv@%8^;z6AdGfrzoDym zTcO$&{Bn!hM=bF1>h@{Z zu!+BaC-DtkY8n)YXg`9mPjg^Z1Bg%Zjy(MlR3_tN(!H9CEEQJ;AH~w}Pg-lzG=S_R zFZYHnEhP%Wqk9LDngK-7uKb3s!fc;-(D(qU>ADm_Fd^pB_$4d;9l%Gs8e5Tq!_aM5 zR{eDf#H^*_C&0g}KYOINHnfpFOf&i+fN!wz^AormLHK!%rHc(98p75MU812104AD5 zC-rJvRGpmxtl!X8fQ=N5NOvNr#@}Ti`eb7O7dLc?WGMt#^Q!cLr!S+d(HrV9XN9z#cnI0r5EjhX%;} zhOY8?hv*OJuZr$FbYp-hh;ya-1~~k9Cth1H3gEMxfjow#zz~9vb*a|>0Ls(gy?f>t QoB#j-07*qoM6N<$f>`+azyJUM diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana16.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana16.png deleted file mode 100644 index d88ec6d8b4e4284637f718e417ec23e4e17843fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2658 zcmV-o3Z3A|#Y-T-M8%V9kM5B1gt@8OK*4Zu+?R~XvaT^qdBz_5N4djsTZGt&)2!0&s;-m%Dx z-Z`EQ`Bt?z09Uz;aYS^a({wJnq;}UoB%^o(NYu*+OGIPsE!@zxYv{0a1aAPTg6{FB z(ZZ^p`rwF0Yi|Gz6&-Sz7VhY-5AM)v=?$QzqyruTZSAcMZP9Gy4WOx}MJ@t8+FKji zsNKRFKwD88d_)JjPaN$tqgy7l>AeB86;S1N6jix=*^`*n3{0NwyLRMp}n9K(cJ z-1E$)KWkB*&*KeXOIaZ=f&N=Dm7sfg({F`TbHcp=Y^uxV=0&@lcHRIS)huJU(Jp5! zZvc*JHZepG_e4X3He0-%+Z(`@(uw-ep6;=ut8DzaH(PsefJ7T(zi2AjMaK=McGn5} z-QMcp4d7DkS$b(jyPTzX18`JR#ArsloUyzCII8JkRHI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Mn)uJd z&tX~h1x?blT)8!XINE(~_hmSF>LnPwFRdsJ>;I04i>}3r6>m7~IjvP*4IqnlpMQJ- z#uw~^!KbqlHhEvFBdCVS>vb#hX@C}ndg_DQSxY4{Xx8g6Sk1y`0x}yA4E!>S*10o) z_#|(m_Are3Y8GO$d&bAj+uN_klGU%VIheql89*5AHlq7ru#Krj*05a&!U5Mq4M_!wFIo?;Llvo)wQ1Bj#D_!u`){O;Z*w#3LO?=}SC{kCRvVu1K0Z~G(` zb?q8D%v#7)w0rVpN5{BXBU%KFW3qLnt#gD93?MwodnmdXC+GlRK5kLuyi@-aL3p=~ zA*~xgd`VLy+6{x1HWptf&K9n~P2myknXMW?9PPgShA!=u7mv@%8^;z6AdGfrzoDym zTcO$&{Bn!hM=bF1>h@{Z zu!+BaC-DtkY8n)YXg`9mPjg^Z1Bg%Zjy(MlR3_tN(!H9CEEQJ;AH~w}Pg-lzG=S_R zFZYHnEhP%Wqk9LDngK-7uKb3s!fc;-(D(qU>ADm_Fd^pB_$4d;9l%Gs8e5Tq!_aM5 zR{eDf#H^*_C&0g}KYOINHnfpFOf&i+fN!wz^AormLHK!%rHc(98p75MU812104AD5 zC-rJvRGpmxtl!X8fQ=N5NOvNr#@}Ti`eb7O7dLc?WGMt#^Q!cLr!S+d(HrV9XN9z#cnI0r5EjhX%;} zhOY8?hv*OJuZr$FbYp-hh;ya-1~~k9Cth1H3gEMxfjow#zz~9vb*a|>0Ls(gy?f>t QoB#j-07*qoM6N<$f>`+azyJUM diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana32.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana32.png deleted file mode 100644 index d88ec6d8b4e4284637f718e417ec23e4e17843fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2658 zcmV-o3Z3A|#Y-T-M8%V9kM5B1gt@8OK*4Zu+?R~XvaT^qdBz_5N4djsTZGt&)2!0&s;-m%Dx z-Z`EQ`Bt?z09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XN9z#cnI0r5EjhX%;} zhOY8?hv*OJuZr$FbYp-hh;ya-1~~k9Cth1H3gEMxfjow#zz~9vb*a|>0Ls(gy?f>t QoB#j-07*qoM6N<$f>`+azyJUM diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana48.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana48.png deleted file mode 100644 index d88ec6d8b4e4284637f718e417ec23e4e17843fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2658 zcmV-o3Z3A|#Y-T-M8%V9kM5B1gt@8OK*4Zu+?R~XvaT^qdBz_5N4djsTZGt&)2!0&s;-m%Dx z-Z`EQ`Bt?z09Uz;aYS^a({wJnq;}UoB%^o(NYu*+OGIPsE!@zxYv{0a1aAPTg6{FB z(ZZ^p`rwF0Yi|Gz6&-Sz7VhY-5AM)v=?$QzqyruTZSAcMZP9Gy4WOx}MJ@t8+FKji zsNKRFKwD88d_)JjPaN$tqgy7l>AeB86;S1N6jix=*^`*n3{0NwyLRMp}n9K(cJ z-1E$)KWkB*&*KeXOIaZ=f&N=Dm7sfg({F`TbHcp=Y^uxV=0&@lcHRIS)huJU(Jp5! zZvc*JHZepG_e4X3He0-%+Z(`@(uw-ep6;=ut8DzaH(PsefJ7T(zi2AjMaK=McGn5} z-QMcp4d7DkS$b(jyPTzX18`JR#ArsloUyzCII8JkRHI$aSl$2})s!&W(Jp5!Zvc*J z8W_S4dZNJxG^ivT-T)Hy*jU*~UUu6VfZhO_Y9`^DigqswBqw>3v`Jdy4UkkRl{&l8 zE@wn<0FG)LjDu*GGnO|1N41m~SJ7_Dv8Kws0XV9q#1NTvY2VsS*@9i}4ZxNz8PLW_ z-ejGVRe1v>(}`7O>m)C0m{~yH0Get}<8mMEa+cx^z)|f2n5?2*&QiPqII7Ko$uipI zEX5muquMN(tfO7dQoI2;s?CU@7FuSd)?2%3V_ksA8$d~EmnV6ZM)v;*(h^c~Nt4zL zTps@f;3{_xm!D{tvlMRt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i@-aL3p=~ zA*~xgd`VLy+6{x1HWptf&K9n~P2myknXMW?9PPgShA!=u7mv@%8^;z6AdGfrzoDym zTcO$&{Bn!hM=bF1>h@{Z zu!+BaC-DtkY8n)YXg`9mPjg^Z1Bg%Zjy(MlR3_tN(!H9CEEQJ;AH~w}Pg-lzG=S_R zFZYHnEhP%Wqk9LDngK-7uKb3s!fc;-(D(qU>ADm_Fd^pB_$4d;9l%Gs8e5Tq!_aM5 zR{eDf#H^*_C&0g}KYOINHnfpFOf&i+fN!wz^AormLHK!%rHc(98p75MU812104AD5 zC-rJvRGpmxtl!X8fQ=N5NOvNr#@}Ti`eb7O7dLc?WGMt#^Q!cLr!S+d(HrV9XN9z#cnI0r5EjhX%;} zhOY8?hv*OJuZr$FbYp-hh;ya-1~~k9Cth1H3gEMxfjow#zz~9vb*a|>0Ls(gy?f>t QoB#j-07*qoM6N<$f>`+azyJUM diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana64.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana64.png deleted file mode 100644 index d88ec6d8b4e4284637f718e417ec23e4e17843fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2658 zcmV-o3Z3A|#Y-T-M8%V9kM5B1gt@8OK*4Zu+?R~XvaT^qdBz_5N4djsTZGt&)2!0&s;-m%Dx z-Z`EQ`Bt?z09Uz;aYS^a({wJnq;}UoB%^o(NYu*+OGIPsE!@zxYv{0a1aAPTg6{FB z(ZZ^p`rwF0Yi|Gz6&-Sz7VhY-5AM)v=?$QzqyruTZSAcMZP9Gy4WOx}MJ@t8+FKji zsNKRFKwD88d_)JjPaN$tqgy7l>AeB86;S1N6jix=*^`*n3{0NwyLRMp}n9K(cJ z-1E$)KWkB*&*KeXOIaZ=f&N=Dm7sfg({F`TbHcp=Y^uxV=0&@lcHRIS)huJU(Jp5! zZvc*JHZepG_e4X3He0-%+Z(`@(uw-ep6;=ut8DzaH(PsefJ7T(zi2AjMaK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(e7xy57Zg~OoxVGdK|PFL6!gGOlgo@8$cZGHioYODhFY(P)RRMn)uJd z&tX~h1x?blT)8!XINE(~_hmSF>LnPwFRdsJ>;I04i>}3r6>m7~IjvP*4IqnlpMQJ- z#uw~^!KbqlHhEvFBdCVS>vb#hX@C}ndg_DQSxY4{Xx8g6Sk1y`0x}yA4E!>S*10o) z_#|(m_Are3Y8GO$d&bAj+uN_klGU%VIheql89*5AHlq7ru#Krj*05a&!U5Mq4M_!wFIo?;Llvo)wQ1Bj#D_!u`){O;Z*w#3LO?=}SC{kCRvVu1K0Z~G(` zb?q8D%v#7)w0rVpN5{BXBU%KFW3qLnt#gD93?MwodnmdXC+GlRK5kLuyi@-aL3p=~ zA*~xgd`VLy+6{x1HWptf&K9n~P2myknXMW?9PPgShA!=u7mv@%8^;z6AdGfrzoDym zTcO$&{Bn!hM=bF1>h@{Z zu!+BaC-DtkY8n)YXg`9mPjg^Z1Bg%Zjy(MlR3_tN(!H9CEEQJ;AH~w}Pg-lzG=S_R zFZYHnEhP%Wqk9LDngK-7uKb3s!fc;-(D(qU>ADm_Fd^pB_$4d;9l%Gs8e5Tq!_aM5 zR{eDf#H^*_C&0g}KYOINHnfpFOf&i+fN!wz^AormLHK!%rHc(98p75MU812104AD5 zC-rJvRGpmxtl!X8fQ=N5NOvNr#@}Ti`eb7O7dLc?WGMt#^Q!cLr!S+d(HrV9XN9z#cnI0r5EjhX%;} zhOY8?hv*OJuZr$FbYp-hh;ya-1~~k9Cth1H3gEMxfjow#zz~9vb*a|>0Ls(gy?f>t QoB#j-07*qoM6N<$f>`+azyJUM diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/manifest.json b/x-pack/test_utils/chrome_extension/test_subjects_finder/manifest.json deleted file mode 100644 index a954a281257b0..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/manifest.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "Test subjects finder", - "version": "1.0", - "description": "Read and print the test subjects on the current page.", - "permissions": ["activeTab", "declarativeContent", "storage"], - "background": { - "scripts": ["background.js"], - "persistent": false - }, - "page_action": { - "default_popup": "popup.html", - "default_icon": { - "16": "images/kibana16.png", - "32": "images/kibana32.png", - "48": "images/kibana48.png", - "128": "images/kibana128.png" - } - }, - "icons": { - "16": "images/kibana16.png", - "32": "images/kibana32.png", - "48": "images/kibana48.png", - "128": "images/kibana128.png" - }, - "manifest_version": 2 -} diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.html b/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.html deleted file mode 100644 index a7fd489dcf86c..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - -

Test subjects finder

-
-
-
- - -
- The DOM node you want to start to traverse from. If not specified, the "body" will be used. -
-
- -
- - -
- If you chose "typescript" you will get a Union Type ready to copy and paste in your test file. -
-
- -
- - -
- The dom traversal "depth" to be returned. In most cases 2 level depth is enough to access all your test subjects. - You can always add manually later other depths in your Typescript union string type. -
-
-
- -
- - -
-
- - - - diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.js b/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.js deleted file mode 100644 index 0944038b59370..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* eslint-disable no-undef */ - -// const trace = (message) => { -// chrome.tabs.executeScript( -// undefined, -// { code: `console.log("${message}")` }, -// ); -// }; - -const isTrackingTestSubjects = () => - new Promise((resolve) => { - chrome.tabs.executeScript( - undefined, - { code: '(() => Boolean(window.__test_utils__ && window.__test_utils__.isTracking))()' }, - ([result]) => { - resolve(result); - } - ); - }); - -const onStartTracking = () => { - document.body.classList.add('is-tracking'); -}; - -const onStopTracking = () => { - document.body.classList.remove('is-tracking'); -}; - -chrome.storage.sync.get( - ['outputType', 'domTreeRoot', 'depth'], - async ({ outputType, domTreeRoot, depth }) => { - const domRootInput = document.getElementById('domRootInput'); - const outputTypeSelect = document.getElementById('outputTypeSelect'); - const depthInput = document.getElementById('depthInput'); - const startTrackButton = document.getElementById('startTrackingButton'); - const stopTrackButton = document.getElementById('stopTrackingButton'); - - const isTracking = await isTrackingTestSubjects(); - - // UI state - if (isTracking) { - document.body.classList.add('is-tracking'); - } else { - document.body.classList.remove('is-tracking'); - } - - // FORM state - if (domTreeRoot) { - domRootInput.value = domTreeRoot; - } - - if (depth) { - depthInput.value = depth; - } - - document.querySelectorAll('#outputTypeSelect option').forEach((node) => { - if (node.value === outputType) { - node.setAttribute('selected', 'selected'); - } - }); - - // FORM events - domRootInput.addEventListener('change', (e) => { - const { value } = e.target; - chrome.storage.sync.set({ domTreeRoot: value }); - }); - - depthInput.addEventListener('change', (e) => { - const { value } = e.target; - if (value) { - chrome.storage.sync.set({ depth: value }); - } - }); - - outputTypeSelect.addEventListener('change', (e) => { - const { value } = e.target; - chrome.storage.sync.set({ outputType: value }); - }); - - startTrackButton.addEventListener('click', () => { - onStartTracking(); - - chrome.tabs.executeScript(undefined, { file: 'start_tracking_test_subjects.js' }); - }); - - stopTrackButton.addEventListener('click', () => { - onStopTracking(); - - chrome.tabs.executeScript(undefined, { file: 'stop_tracking_test_subjects.js' }); - }); - } -); - -chrome.runtime.onMessage.addListener((request) => { - if (request === 'TRACK_SUBJECTS_ERROR') { - onStopTracking(); - } -}); diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/start_tracking_test_subjects.js b/x-pack/test_utils/chrome_extension/test_subjects_finder/start_tracking_test_subjects.js deleted file mode 100644 index 4c2612a2223e5..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/start_tracking_test_subjects.js +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* eslint-disable no-undef */ - -(function () { - /** - * Go from ['a', 'b', 'c', 'd', 'e'] - * To ['a.b.c.d.e', 'a.b.c.d', 'a.b.c', 'a.b'] - * @param arr The array to outpu - */ - const outputArray = (arr) => { - const output = []; - let i = 0; - while (i < arr.length - 1) { - const end = i ? i * -1 : undefined; - output.push(arr.slice(0, end).join('.')); - i++; - } - return output; - }; - - const getAllNestedPathsFromArray = (arr, computedArray = []) => { - // Output the array without skipping any item - let output = [...computedArray, ...outputArray(arr)]; - - // We remove the "head" and the "tail" of the array (pos 0 and arr.length -1) - // We go from ['a', 'b', 'c', 'd', 'e'] (5 items) - // To 3 modified arrays - // ['a', 'c', 'd', 'e'] => outputArray() - // ['a', 'd', 'e'] => outputArray() - // ['a', 'e'] => outputArray() - let itemsToSkip = arr.length - 2; - if (itemsToSkip > 0) { - while (itemsToSkip) { - const newArray = [...arr]; - newArray.splice(1, itemsToSkip); - output = [...output, ...outputArray(newArray)]; - itemsToSkip--; - } - } - - if (arr.length > 2) { - // Recursively call the function skipping the first array item - return getAllNestedPathsFromArray(arr.slice(1), output); - } - - return output.sort(); - }; - - chrome.storage.sync.get( - ['domTreeRoot', 'outputType', 'depth'], - ({ domTreeRoot, outputType, depth = 2 }) => { - const datasetKey = 'testSubj'; - - if (domTreeRoot && !document.querySelector(domTreeRoot)) { - // Let our popup extension know about this... - chrome.runtime.sendMessage('TRACK_SUBJECTS_ERROR'); - throw new Error(`DOM node "${domTreeRoot}" not found.`); - } - - const arrayToType = (array) => - array.reduce((string, subject) => { - return string === '' ? `'${subject}'` : `${string}\n | '${subject}'`; - }, ''); - - const arrayToList = (array) => - array.reduce((string, subject) => { - return string === '' ? `'${subject}'` : `${string}\n\'${subject}'`; - }, ''); - - const addTestSubject = (testSubject) => { - const subjectDepth = testSubject.split('.').length; - if (subjectDepth <= parseInt(depth, 10)) { - window.__test_utils__.dataTestSubjects.add(testSubject); - } - }; - - const findTestSubjects = ( - node = domTreeRoot ? document.querySelector(domTreeRoot) : document.querySelector('body'), - path = [] - ) => { - if (!node) { - // We probably navigated outside the initial DOM root - return; - } - const testSubjectOnNode = node.dataset[datasetKey]; - - const updatedPath = testSubjectOnNode ? [...path, testSubjectOnNode] : path; - - if (!node.children.length) { - const pathToString = updatedPath.join('.'); - - if (pathToString) { - // Add the complete nested path ('a.b.c.d') - addTestSubject(pathToString); - // Add each item separately - updatedPath.forEach(addTestSubject); - // Add all the combination ('a.b', 'a.c', 'a.e', ...) - const nestedPaths = getAllNestedPathsFromArray(updatedPath); - nestedPaths.forEach(addTestSubject); - } - - return; - } - - for (let i = 0; i < node.children.length; i++) { - findTestSubjects(node.children[i], updatedPath); - } - }; - - const output = () => { - const { dataTestSubjects } = window.__test_utils__; - const allTestSubjects = Array.from(dataTestSubjects).sort(); - - console.log(`------------- TEST SUBJECTS (${allTestSubjects.length}) ------------- `); - - const content = - outputType === 'list' - ? `${arrayToList(allTestSubjects)}` - : `export type TestSubjects = ${arrayToType(allTestSubjects)}`; - - console.log(content); - }; - - // Handler for the clicks on the document to keep tracking - // new test subjects - const documentClicksHandler = () => { - const { dataTestSubjects } = window.__test_utils__; - const total = dataTestSubjects.size; - - // Wait to be sure that the DOM has updated - setTimeout(() => { - findTestSubjects(); - if (dataTestSubjects.size === total) { - // No new test subject, nothing to output - return; - } - - output(); - }, 500); - }; - - // Add meta data on the window object - window.__test_utils__ = window.__test_utils__ || { - documentClicksHandler, - isTracking: false, - dataTestSubjects: new Set(), - }; - - // Handle "click" event on the document to update our test subjects - if (!window.__test_utils__.isTracking) { - document.addEventListener('click', window.__test_utils__.documentClicksHandler); - window.__test_utils__.isTracking = true; - } - - findTestSubjects(); - output(); - } - ); -})(); diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/stop_tracking_test_subjects.js b/x-pack/test_utils/chrome_extension/test_subjects_finder/stop_tracking_test_subjects.js deleted file mode 100644 index 94875a9d1b8d8..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/stop_tracking_test_subjects.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -if (window.__test_utils__ && window.__test_utils__.isTracking) { - document.removeEventListener('click', window.__test_utils__.documentClicksHandler); - window.__test_utils__.isTracking = false; - window.__test_utils__.dataTestSubjects = new Set(); -} diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/style.css b/x-pack/test_utils/chrome_extension/test_subjects_finder/style.css deleted file mode 100644 index 7cf56cf14fcf8..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/style.css +++ /dev/null @@ -1,110 +0,0 @@ -* { - box-sizing: border-box; -} -body { - padding: 16px; - width: 300px; -} -h1 { - font-size: 1rem; - margin: 0 0 16px; - text-align: center; -} - -.form-control { - margin-bottom: 16px; -} - -.form-control__label { - display: block; - font-weight: 600; - margin-bottom: 4px; -} - -.form-control__input { - width: 100%; - height: 40px; - background-color: #fbfcfd; - background-repeat: no-repeat; - background-size: 0% 100%; - box-shadow: 0 1px 1px -1px rgba(152, 162, 179, 0.2), 0 3px 2px -2px rgba(152, 162, 179, 0.2), inset 0 0 0 1px rgba(0, 0, 0, 0.1); - transition: background-color 150ms ease-in, background-image 150ms ease-in, background-size 150ms ease-in, -webkit-box-shadow 150ms ease-in; - transition: box-shadow 150ms ease-in, background-color 150ms ease-in, background-image 150ms ease-in, background-size 150ms ease-in; - font-family: "Inter UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; - font-weight: 400; - letter-spacing: -.005em; - -webkit-text-size-adjust: 100%; - -webkit-font-kerning: normal; - font-kerning: normal; - font-size: 14px; - line-height: 1em; - color: #343741; - border: none; - border-radius: 0; - padding: 12px; - margin-bottom: 4px; -} - -.form-control__helper-text { - font-size: 0.7rem; - color: #666; -} - -.form-control__select { - width: 100%; - padding: 4px; - margin-bottom: 4px; -} - -.form-actions { - border-top: 1px solid #ddd; - padding-top: 24px; - text-align: center; -} - -button { - font-family: "Inter UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; - font-weight: 400; - letter-spacing: -.005em; - -webkit-text-size-adjust: 100%; - -webkit-font-kerning: normal; - font-kerning: normal; - font-size: 1rem; - line-height: 1.5; - display: inline-block; - -webkit-appearance: none; - appearance: none; - cursor: pointer; - height: 40px; - line-height: 40px; - text-decoration: none; - border: solid 1px transparent; - text-align: center; - transition: all 250ms cubic-bezier(0.34, 1.61, 0.7, 1); - white-space: nowrap; - max-width: 100%; - vertical-align: middle; - box-shadow: 0 2px 2px -1px rgba(152, 162, 179, 0.3); - border-radius: 4px; - min-width: 112px; - background-color: #017D73; - border-color: #017D73; - color: #FFF; - box-shadow: 0 2px 2px -1px rgba(39, 87, 83, 0.3); -} - -.is-tracking .track-config { - display: none; -} - -#stopTrackingButton { - display: none; -} - -.is-tracking #stopTrackingButton { - display: inline; -} - -.is-tracking #startTrackingButton { - display: none; -} diff --git a/x-pack/test_utils/get_config_schema.ts b/x-pack/test_utils/get_config_schema.ts deleted file mode 100644 index cca0bc07a4e91..0000000000000 --- a/x-pack/test_utils/get_config_schema.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import Joi from 'joi'; - -export async function getConfigSchema(pluginProvider: any): Promise { - class Plugin { - constructor(public readonly options: any) {} - } - - const plugin = pluginProvider({ Plugin }); - - return await plugin.options.config(Joi); -} diff --git a/x-pack/test_utils/index.ts b/x-pack/test_utils/index.ts deleted file mode 100644 index 5d0042bdaef14..0000000000000 --- a/x-pack/test_utils/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export * from './lib'; -export { getConfigSchema } from './get_config_schema'; diff --git a/x-pack/test_utils/jest/config.integration.js b/x-pack/test_utils/jest/config.integration.js deleted file mode 100644 index 4ec1711eb6fca..0000000000000 --- a/x-pack/test_utils/jest/config.integration.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../../../src/dev/constants'; -import config from './config'; - -export default { - ...config, - testMatch: [ - `**/${RESERVED_DIR_JEST_INTEGRATION_TESTS}/**/*.test.{js,mjs,ts,tsx}`, - // Tests within `__jest__` directories should be treated as regular unit tests. - `!**/__jest__/${RESERVED_DIR_JEST_INTEGRATION_TESTS}/**/*.test.{js,mjs,ts,tsx}`, - ], - testPathIgnorePatterns: config.testPathIgnorePatterns.filter( - (pattern) => !pattern.includes(RESERVED_DIR_JEST_INTEGRATION_TESTS) - ), - reporters: [ - 'default', - [ - '/../packages/kbn-test/target/jest/junit_reporter', - { reportName: 'Jest Integration Tests' }, - ], - ], - setupFilesAfterEnv: ['/../packages/kbn-test/target/jest/setup/after_env.integration.js'], -}; diff --git a/x-pack/test_utils/jest/config.js b/x-pack/test_utils/jest/config.js deleted file mode 100644 index 7d4f6b713da27..0000000000000 --- a/x-pack/test_utils/jest/config.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../../../src/dev/constants'; - -export default { - rootDir: '../../', - roots: [ - '/plugins', - '/legacy/plugins', - '/legacy/server', - '/legacy/common', - '/test_utils/jest/integration_tests', - ], - collectCoverageFrom: ['legacy/plugins/**/*.js', 'legacy/common/**/*.js', 'legacy/server/**/*.js'], - moduleNameMapper: { - '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': - '/packages/kbn-test/target/jest/mocks/file_mock.js', - '\\.(css|less|scss)$': '/../packages/kbn-test/target/jest/mocks/style_mock.js', - }, - setupFiles: [ - '/../packages/kbn-test/target/jest/setup/babel_polyfill.js', - '/../packages/kbn-test/target/jest/setup/polyfills.js', - '/../packages/kbn-test/target/jest/setup/enzyme.js', - ], - coverageDirectory: '/../target/kibana-coverage/jest', - coverageReporters: ['html'], - moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'], - modulePathIgnorePatterns: ['__fixtures__/', 'target/'], - testEnvironment: 'jest-environment-jsdom-thirteen', - testMatch: ['**/*.test.{js,mjs,ts,tsx}'], - testPathIgnorePatterns: [ - '/packages/kbn-ui-framework/(dist|doc_site|generator-kui)/', - '/packages/kbn-pm/dist/', - `${RESERVED_DIR_JEST_INTEGRATION_TESTS}/`, - ], - testRunner: 'jest-circus/runner', - transform: { - '^.+\\.(js|tsx?)$': '/../packages/kbn-test/target/jest/babel_transform.js', - '^.+\\.txt?$': 'jest-raw-loader', - '^.+\\.html?$': 'jest-raw-loader', - }, - transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.js$', 'packages/kbn-pm/dist/index.js'], - snapshotSerializers: ['/../node_modules/enzyme-to-json/serializer'], - reporters: ['default', '/../packages/kbn-test/target/jest/junit_reporter'], -}; diff --git a/x-pack/test_utils/kbn_server_config.ts b/x-pack/test_utils/kbn_server_config.ts deleted file mode 100644 index 3cac6ed5df014..0000000000000 --- a/x-pack/test_utils/kbn_server_config.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { resolve } from 'path'; - -type Licenses = 'oss' | 'basic' | 'gold' | 'trial'; - -export const TestKbnServerConfig = { - kbn: { - plugins: { paths: [resolve(__dirname, '../../x-pack')] }, - xpack: { - monitoring: { - tests: { - cloud_detector: { - enabled: false, - }, - }, - }, - }, - }, - es: { - license: 'trial' as Licenses, - }, - users: [ - { - username: 'kibana_admin', - password: 'x-pack-test-password', - roles: ['kibana_admin'], - }, - ], -}; diff --git a/x-pack/test_utils/lib/index.ts b/x-pack/test_utils/lib/index.ts deleted file mode 100644 index 07120636f09cf..0000000000000 --- a/x-pack/test_utils/lib/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { nextTick, getRandomString, getRandomNumber } from './utils'; diff --git a/x-pack/test_utils/lib/utils.ts b/x-pack/test_utils/lib/utils.ts deleted file mode 100644 index 0765a4cd88476..0000000000000 --- a/x-pack/test_utils/lib/utils.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import Chance from 'chance'; - -const chance = new Chance(); -const CHARS_POOL = 'abcdefghijklmnopqrstuvwxyz'; - -export const nextTick = (time = 0) => new Promise((resolve) => setTimeout(resolve, time)); - -export const getRandomNumber = (range: { min: number; max: number } = { min: 1, max: 20 }) => - chance.integer(range); - -export const getRandomString = (options = {}) => - `${chance.string({ pool: CHARS_POOL, ...options })}-${Date.now()}`;