diff --git a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.test.js b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.test.js index 35d1b1ab11384..322936be9a722 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.test.js +++ b/src/core_plugins/kibana/public/dashboard/panel/dashboard_panel.test.js @@ -14,7 +14,7 @@ import { getEmbeddableFactoryMock } from '../__tests__/get_embeddable_factories_ import { takeMountedSnapshot, -} from 'ui_framework/src/test'; +} from 'ui_framework/test'; function getProps(props = {}) { const defaultTestProps = { diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header_container.test.js b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header_container.test.js index 0ff43bcc65411..4b91d80dd9caa 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header_container.test.js +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_header/panel_header_container.test.js @@ -16,7 +16,7 @@ import { import { getEmbeddableFactoryMock } from '../../__tests__/get_embeddable_factories_mock'; import { TestSubjects, -} from 'ui_framework/src/test'; +} from 'ui_framework/test'; function getProps(props = {}) { const defaultTestProps = { diff --git a/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.test.js b/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.test.js index 80947ab8200c7..3638aa6eab185 100644 --- a/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.test.js +++ b/src/core_plugins/kibana/public/dashboard/top_nav/clone_modal.test.js @@ -1,6 +1,9 @@ import React from 'react'; import sinon from 'sinon'; import { mount, render } from 'enzyme'; +import { + findTestSubject, +} from 'ui_framework/test'; import { DashboardCloneModal, @@ -32,14 +35,14 @@ test('renders DashboardCloneModal', () => { test('onClone', () => { createComponent(); - component.find('[data-test-subj="cloneConfirmButton"]').simulate('click'); + findTestSubject(component, 'cloneConfirmButton', false).simulate('click'); sinon.assert.calledWith(onClone, 'dash title'); sinon.assert.notCalled(onClose); }); test('onClose', () => { createComponent(); - component.find('[data-test-subj="cloneCancelButton"]').simulate('click'); + findTestSubject(component, 'cloneCancelButton', false).simulate('click'); sinon.assert.calledOnce(onClose); sinon.assert.notCalled(onClone); }); @@ -48,6 +51,6 @@ test('title', () => { createComponent(); const event = { target: { value: 'a' } }; component.find('input').simulate('change', event); - component.find('[data-test-subj="cloneConfirmButton"]').simulate('click'); + findTestSubject(component, 'cloneConfirmButton', false).simulate('click'); sinon.assert.calledWith(onClone, 'a'); }); diff --git a/src/dev/jest/config.json b/src/dev/jest/config.json index f1eb6a82a0129..a30fe06e0c4f8 100644 --- a/src/dev/jest/config.json +++ b/src/dev/jest/config.json @@ -16,14 +16,14 @@ "moduleNameMapper": { "^ui_framework/components": "/ui_framework/components", "^ui_framework/services": "/ui_framework/services", - "^ui_framework/src/test": "/ui_framework/src/test", + "^ui_framework/test": "/ui_framework/test", "^ui/(.*)": "/src/ui/public/$1", "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/src/dev/jest/mocks/file_mock.js", "\\.(css|less|scss)$": "/src/dev/jest/mocks/style_mock.js" }, "setupFiles": [ "/src/dev/jest/setup/babel_polyfill.js", - "/src/dev/jest/setup/request_animation_frame_polyfill.js" + "/src/dev/jest/setup/request_animation_frame_polyfill.js", "/src/dev/jest/setup/enzyme.js" ], "coverageDirectory": "/target/jest-coverage", diff --git a/src/jest/setup/enzyme.js b/src/jest/setup/enzyme.js new file mode 100644 index 0000000000000..82edfc9e5adea --- /dev/null +++ b/src/jest/setup/enzyme.js @@ -0,0 +1,4 @@ +import { configure } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; + +configure({ adapter: new Adapter() }); diff --git a/ui_framework/src/components/code_editor/__snapshots__/code_editor.test.js.snap b/ui_framework/src/components/code_editor/__snapshots__/code_editor.test.js.snap index 971c88b219d5f..1778b94580ad5 100644 --- a/ui_framework/src/components/code_editor/__snapshots__/code_editor.test.js.snap +++ b/ui_framework/src/components/code_editor/__snapshots__/code_editor.test.js.snap @@ -2,23 +2,21 @@ exports[`KuiCodeEditor behavior hint element should be disabled when the ui ace box gains focus 1`] = `

Press Enter to start editing .

When you’re done, press Escape to stop editing @@ -29,23 +27,46 @@ exports[`KuiCodeEditor behavior hint element should be disabled when the ui ace exports[`KuiCodeEditor behavior hint element should be enabled when the ui ace box loses focus 1`] = `

Press Enter to start editing .

+ When you’re done, press Escape to stop + editing + . +

+
+`; + +exports[`KuiCodeEditor behavior hint element should be tabable 1`] = ` +
+

+ Press Enter to start + editing + . +

+

When you’re done, press Escape to stop editing @@ -68,28 +89,12 @@ exports[`KuiCodeEditor is rendered 1`] = `

- - Press Enter to start - - - editing - - - . - + Press Enter to start editing.

- - When you’re done, press Escape to stop - - - editing - - - . - + When you’re done, press Escape to stop editing.

- - Press Enter to start - - - interacting with the code - - - . - + Press Enter to start interacting with the code.

- - When you’re done, press Escape to stop - - - interacting with the code - - - . - + When you’re done, press Escape to stop interacting with the code.

{ describe('hint element', () => { test('should be tabable', () => { - expect(component.find('[data-test-subj="codeEditorHint"]').prop('tabIndex')).toBe('0'); + const hint = findTestSubject(component, 'codeEditorHint'); + expect(hint).toMatchSnapshot(); }); test('should be disabled when the ui ace box gains focus', () => { - const hint = component.find('[data-test-subj="codeEditorHint"]'); - hint.simulate('keydown', { keyCode: keyCodes.ENTER }); - expect(hint).toMatchSnapshot(); + const hint = findTestSubject(component, 'codeEditorHint', false); + hint.simulate('keyup', { keyCode: keyCodes.ENTER }); + expect(findTestSubject(component, 'codeEditorHint')).toMatchSnapshot(); }); test('should be enabled when the ui ace box loses focus', () => { - const hint = component.find('[data-test-subj="codeEditorHint"]'); - hint.simulate('keydown', { keyCode: keyCodes.ENTER }); + const hint = findTestSubject(component, 'codeEditorHint', false); + hint.simulate('keyup', { keyCode: keyCodes.ENTER }); component.instance().onBlurAce(); - expect(hint).toMatchSnapshot(); + expect(findTestSubject(component, 'codeEditorHint')).toMatchSnapshot(); }); }); @@ -66,11 +68,10 @@ describe('KuiCodeEditor', () => { component.instance().onKeydownAce({ preventDefault: () => {}, stopPropagation: () => {}, - keyCode: keyCodes.ESCAPE + keyCode: keyCodes.ESCAPE, }); - expect( - component.find('[data-test-subj="codeEditorHint"]').matchesElement(document.activeElement) - ).toBe(true); + const hint = findTestSubject(component, 'codeEditorHint'); + expect(hint).toBe(document.activeElement); }); }); }); diff --git a/ui_framework/src/components/context_menu/__snapshots__/context_menu_item.test.js.snap b/ui_framework/src/components/context_menu/__snapshots__/context_menu_item.test.js.snap index de10f1d71ac7e..a11599a5244f5 100644 --- a/ui_framework/src/components/context_menu/__snapshots__/context_menu_item.test.js.snap +++ b/ui_framework/src/components/context_menu/__snapshots__/context_menu_item.test.js.snap @@ -18,6 +18,21 @@ exports[`KuiContextMenuItem is rendered 1`] = ` `; +exports[`KuiContextMenuItem props disabled is rendered 1`] = ` + +`; + exports[`KuiContextMenuItem props hasPanel is rendered 1`] = `