From 2dab77b98ff7a6897afc9ac793584c47857dfc3b Mon Sep 17 00:00:00 2001 From: Corey Robertson Date: Tue, 5 May 2020 15:29:16 -0400 Subject: [PATCH] Fix jest test and paths --- x-pack/plugins/canvas/.storybook/storyshots.test.js | 11 ++++------- .../middleware/__tests__/workpad_refresh.test.ts | 1 - x-pack/plugins/canvas/scripts/_helpers.js | 10 +++++----- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/canvas/.storybook/storyshots.test.js b/x-pack/plugins/canvas/.storybook/storyshots.test.js index a81483d1e7a1..59645cad2620 100644 --- a/x-pack/plugins/canvas/.storybook/storyshots.test.js +++ b/x-pack/plugins/canvas/.storybook/storyshots.test.js @@ -7,7 +7,7 @@ import path from 'path'; import moment from 'moment'; import 'moment-timezone'; -import ReactDOM from "react-dom"; +import ReactDOM from 'react-dom'; import initStoryshots, { multiSnapshotWithOptions } from '@storybook/addon-storyshots'; import styleSheetSerializer from 'jest-styled-components/src/styleSheetSerializer'; @@ -25,8 +25,8 @@ moment.tz.setDefault('UTC'); const testTime = new Date(Date.UTC(2019, 5, 1)); // June 1 2019 Date.now = jest.fn(() => testTime); -// Mock telemetry service -jest.mock('../public/lib/ui_metric', () => ({ trackCanvasUiMetric: () => { } })); +// Mock telemetry service +jest.mock('../public/lib/ui_metric', () => ({ trackCanvasUiMetric: () => {} })); // Mock EUI generated ids to be consistently predictable for snapshots. jest.mock(`@elastic/eui/lib/components/form/form_row/make_id`, () => () => `generated-id`); @@ -65,9 +65,8 @@ jest.mock('@elastic/eui/packages/react-datepicker', () => { }; }); - // Mock React Portal for components that use modals, tooltips, etc -ReactDOM.createPortal = jest.fn((element) => { +ReactDOM.createPortal = jest.fn(element => { return element; }); @@ -77,8 +76,6 @@ jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => { }; }); -jest.mock('plugins/interpreter/registries', () => ({})); - // Disabling this test due to https://github.com/elastic/eui/issues/2242 jest.mock( '../public/components/workpad_header/share_menu/flyout/__examples__/share_website_flyout.stories', diff --git a/x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_refresh.test.ts b/x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_refresh.test.ts index 2123c9606f1f..f90f570bc6eb 100644 --- a/x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_refresh.test.ts +++ b/x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_refresh.test.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../legacy'); jest.mock('ui/new_platform'); // actions/elements has some dependencies on ui/new_platform. jest.mock('../../../lib/app_state'); diff --git a/x-pack/plugins/canvas/scripts/_helpers.js b/x-pack/plugins/canvas/scripts/_helpers.js index dea58e90cc60..0f4b07d98830 100644 --- a/x-pack/plugins/canvas/scripts/_helpers.js +++ b/x-pack/plugins/canvas/scripts/_helpers.js @@ -7,19 +7,19 @@ const { resolve } = require('path'); exports.runGulpTask = function(name) { - process.chdir(resolve(__dirname, '../../../..')); + process.chdir(resolve(__dirname, '../../..')); process.argv.splice(1, 1, require.resolve('gulp/bin/gulp'), name); require('gulp/bin/gulp'); }; exports.runKibanaScript = function(name, args = []) { - process.chdir(resolve(__dirname, '../../../../..')); + process.chdir(resolve(__dirname, '../../../..')); process.argv.splice(2, 0, ...args); - require('../../../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require + require('../../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require }; exports.runXPackScript = function(name, args = []) { - process.chdir(resolve(__dirname, '../../../..')); + process.chdir(resolve(__dirname, '../../..')); process.argv.splice(2, 0, ...args); - require('../../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require + require('../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require };