From bd9e2148a5c6bedccfcbeb6bac3a341c25dc0610 Mon Sep 17 00:00:00 2001 From: Spencer Date: Fri, 14 Sep 2018 13:24:10 -0700 Subject: [PATCH] [kbn-plugin-helpers] move jest tests to integration suite (#23005) (#23012) The plugin helper tests have failed due to timeouts every once and a while, which makes sense because they run a bunch of CLI tasks, so this just moved them to the jest integration tests where tests can take a little longer to run. --- .../build_action_test_plugin/index.js | 0 .../build_action_test_plugin/package.json | 0 .../build_action_test_plugin/public/hack.js | 0 .../translations/es.json | 0 .../create_build_test_plugin/index.js | 0 .../create_build_test_plugin/package.json | 0 .../create_build_test_plugin/public/hack.js | 0 .../public/styles.scss | 0 .../translations/es.json | 0 .../create_package_test_plugin/index.js | 0 .../create_package_test_plugin/package.json | 0 .../create_package_test_plugin/public/hack.js | 0 .../translations/es.json | 0 .../__snapshots__/build_action.test.js.snap | 0 .../build_action.test.js | 28 ++++++++++++------- .../create_build.test.js | 4 +-- .../create_package.test.js | 6 ++-- 17 files changed, 23 insertions(+), 15 deletions(-) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/build_action_test_plugin/index.js (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/build_action_test_plugin/package.json (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/build_action_test_plugin/public/hack.js (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/build_action_test_plugin/translations/es.json (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_build_test_plugin/index.js (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_build_test_plugin/package.json (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_build_test_plugin/public/hack.js (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_build_test_plugin/public/styles.scss (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_build_test_plugin/translations/es.json (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_package_test_plugin/index.js (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_package_test_plugin/package.json (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_package_test_plugin/public/hack.js (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__fixtures__/create_package_test_plugin/translations/es.json (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/__snapshots__/build_action.test.js.snap (100%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/build_action.test.js (83%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/create_build.test.js (97%) rename packages/kbn-plugin-helpers/tasks/build/{ => integration_tests}/create_package.test.js (90%) diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/build_action_test_plugin/index.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/build_action_test_plugin/index.js similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/build_action_test_plugin/index.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/build_action_test_plugin/index.js diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/build_action_test_plugin/package.json b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/build_action_test_plugin/package.json similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/build_action_test_plugin/package.json rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/build_action_test_plugin/package.json diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/build_action_test_plugin/public/hack.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/build_action_test_plugin/public/hack.js similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/build_action_test_plugin/public/hack.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/build_action_test_plugin/public/hack.js diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/build_action_test_plugin/translations/es.json b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/build_action_test_plugin/translations/es.json similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/build_action_test_plugin/translations/es.json rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/build_action_test_plugin/translations/es.json diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/index.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/index.js similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/index.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/index.js diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/package.json b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/package.json similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/package.json rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/package.json diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/public/hack.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/public/hack.js similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/public/hack.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/public/hack.js diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/public/styles.scss b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/public/styles.scss similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/public/styles.scss rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/public/styles.scss diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/translations/es.json b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/translations/es.json similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_build_test_plugin/translations/es.json rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_build_test_plugin/translations/es.json diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_package_test_plugin/index.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_package_test_plugin/index.js similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_package_test_plugin/index.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_package_test_plugin/index.js diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_package_test_plugin/package.json b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_package_test_plugin/package.json similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_package_test_plugin/package.json rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_package_test_plugin/package.json diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_package_test_plugin/public/hack.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_package_test_plugin/public/hack.js similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_package_test_plugin/public/hack.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_package_test_plugin/public/hack.js diff --git a/packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_package_test_plugin/translations/es.json b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_package_test_plugin/translations/es.json similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__fixtures__/create_package_test_plugin/translations/es.json rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__fixtures__/create_package_test_plugin/translations/es.json diff --git a/packages/kbn-plugin-helpers/tasks/build/__snapshots__/build_action.test.js.snap b/packages/kbn-plugin-helpers/tasks/build/integration_tests/__snapshots__/build_action.test.js.snap similarity index 100% rename from packages/kbn-plugin-helpers/tasks/build/__snapshots__/build_action.test.js.snap rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/__snapshots__/build_action.test.js.snap diff --git a/packages/kbn-plugin-helpers/tasks/build/build_action.test.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/build_action.test.js similarity index 83% rename from packages/kbn-plugin-helpers/tasks/build/build_action.test.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/build_action.test.js index 43aa1d68a1d6..9bef3a91e944 100644 --- a/packages/kbn-plugin-helpers/tasks/build/build_action.test.js +++ b/packages/kbn-plugin-helpers/tasks/build/integration_tests/build_action.test.js @@ -23,11 +23,11 @@ const del = require('del'); const PLUGIN_FIXTURE = resolve(__dirname, '__fixtures__/build_action_test_plugin'); const PLUGIN_BUILD_DIR = resolve(PLUGIN_FIXTURE, 'build'); -const PLUGIN = require('../../lib/plugin_config')(PLUGIN_FIXTURE); +const PLUGIN = require('../../../lib/plugin_config')(PLUGIN_FIXTURE); const noop = () => {}; describe('creating build zip', () => { - const buildAction = require('./build_action'); + const buildAction = require('../build_action'); beforeEach(() => del(PLUGIN_BUILD_DIR)); afterEach(() => del(PLUGIN_BUILD_DIR)); @@ -58,8 +58,16 @@ describe('calling create_build', () => { beforeEach(() => { jest.resetModules(); mockBuild = jest.fn(() => Promise.resolve()); - jest.mock('./create_build', () => mockBuild); - buildAction = require('./build_action'); + jest.mock('../create_build', () => mockBuild); + buildAction = require('../build_action'); + }); + + const nameArgs = ([plugin, buildTarget, buildVersion, kibanaVersion, files]) => ({ + plugin, + buildTarget, + buildVersion, + kibanaVersion, + files, }); it('takes optional build version', async () => { @@ -71,8 +79,8 @@ describe('calling create_build', () => { await buildAction(PLUGIN, noop, options); expect(mockBuild.mock.calls).toHaveLength(1); - // eslint-disable-next-line no-unused-vars - const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0]; + + const { buildVersion, kibanaVersion } = nameArgs(mockBuild.mock.calls[0]); expect(buildVersion).toBe('1.2.3'); expect(kibanaVersion).toBe('4.5.6'); }); @@ -81,8 +89,8 @@ describe('calling create_build', () => { await buildAction(PLUGIN); expect(mockBuild.mock.calls).toHaveLength(1); - // eslint-disable-next-line no-unused-vars - const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0]; + + const { files } = nameArgs(mockBuild.mock.calls[0]); PLUGIN.buildSourcePatterns.forEach(file => expect(files).toContain(file)); }); @@ -99,8 +107,8 @@ describe('calling create_build', () => { await buildAction(PLUGIN, noop, options); expect(mockBuild.mock.calls).toHaveLength(1); - // eslint-disable-next-line no-unused-vars - const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0]; + + const { files } = nameArgs(mockBuild.mock.calls[0]); options.files.forEach(file => expect(files).toContain(file)); }); diff --git a/packages/kbn-plugin-helpers/tasks/build/create_build.test.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/create_build.test.js similarity index 97% rename from packages/kbn-plugin-helpers/tasks/build/create_build.test.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/create_build.test.js index 18d15b8cf2de..8ecddae0115c 100644 --- a/packages/kbn-plugin-helpers/tasks/build/create_build.test.js +++ b/packages/kbn-plugin-helpers/tasks/build/integration_tests/create_build.test.js @@ -20,10 +20,10 @@ const { resolve } = require('path'); const { readdirSync, existsSync, unlink } = require('fs'); const del = require('del'); -const createBuild = require('./create_build'); +const createBuild = require('../create_build'); const PLUGIN_FIXTURE = resolve(__dirname, '__fixtures__/create_build_test_plugin'); -const PLUGIN = require('../../lib/plugin_config')(PLUGIN_FIXTURE); +const PLUGIN = require('../../../lib/plugin_config')(PLUGIN_FIXTURE); const PLUGIN_BUILD_DIR = resolve(PLUGIN_FIXTURE, 'build'); const PLUGIN_BUILD_TARGET = resolve(PLUGIN_BUILD_DIR, 'kibana', PLUGIN.id); diff --git a/packages/kbn-plugin-helpers/tasks/build/create_package.test.js b/packages/kbn-plugin-helpers/tasks/build/integration_tests/create_package.test.js similarity index 90% rename from packages/kbn-plugin-helpers/tasks/build/create_package.test.js rename to packages/kbn-plugin-helpers/tasks/build/integration_tests/create_package.test.js index 1cfb1fa77c75..9659cfbaa2a3 100644 --- a/packages/kbn-plugin-helpers/tasks/build/create_package.test.js +++ b/packages/kbn-plugin-helpers/tasks/build/integration_tests/create_package.test.js @@ -20,11 +20,11 @@ const { resolve } = require('path'); const { statSync } = require('fs'); const del = require('del'); -const createBuild = require('./create_build'); -const createPackage = require('./create_package'); +const createBuild = require('../create_build'); +const createPackage = require('../create_package'); const PLUGIN_FIXTURE = resolve(__dirname, '__fixtures__/create_package_test_plugin'); -const PLUGIN = require('../../lib/plugin_config')(PLUGIN_FIXTURE); +const PLUGIN = require('../../../lib/plugin_config')(PLUGIN_FIXTURE); const PLUGIN_BUILD_DIR = resolve(PLUGIN_FIXTURE, 'build-custom'); const buildVersion = PLUGIN.version;