From 52ee957f81753dd836e348f722967c2b70c10bd4 Mon Sep 17 00:00:00 2001 From: Uladzislau Lasitsa Date: Wed, 1 Apr 2020 17:11:33 +0300 Subject: [PATCH] =?UTF-8?q?Migrate=20test=20plugins=20=E2=87=92=20NP=20(kb?= =?UTF-8?q?n=5Ftp=5Fsample=5Fpanel=5Faction)=20(#60749)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Migrated sample_action to NP. Panel action tests returned to the test flow. * fixed names Co-authored-by: Elastic Machine --- .ci/Jenkinsfile_flaky | 2 +- .../kbn_sample_panel_action/kibana.json | 9 ++++ .../package.json | 5 +- .../public}/index.ts | 30 ++++-------- .../kbn_sample_panel_action/public/plugin.ts | 47 +++++++++++++++++++ .../public/sample_panel_action.tsx | 15 +++--- .../public/sample_panel_link.ts | 6 --- .../tsconfig.json | 0 .../test_suites/panel_actions/index.js | 5 +- .../jenkins_build_kbn_sample_panel_action.sh | 9 ++++ ...enkins_build_kbn_tp_sample_panel_action.sh | 9 ---- test/scripts/jenkins_ci_group.sh | 2 +- 12 files changed, 87 insertions(+), 52 deletions(-) create mode 100644 test/plugin_functional/plugins/kbn_sample_panel_action/kibana.json rename test/plugin_functional/plugins/{kbn_tp_sample_panel_action => kbn_sample_panel_action}/package.json (70%) rename test/plugin_functional/plugins/{kbn_tp_sample_panel_action => kbn_sample_panel_action/public}/index.ts (58%) create mode 100644 test/plugin_functional/plugins/kbn_sample_panel_action/public/plugin.ts rename test/plugin_functional/plugins/{kbn_tp_sample_panel_action => kbn_sample_panel_action}/public/sample_panel_action.tsx (81%) rename test/plugin_functional/plugins/{kbn_tp_sample_panel_action => kbn_sample_panel_action}/public/sample_panel_link.ts (82%) rename test/plugin_functional/plugins/{kbn_tp_sample_panel_action => kbn_sample_panel_action}/tsconfig.json (100%) create mode 100644 test/scripts/jenkins_build_kbn_sample_panel_action.sh delete mode 100755 test/scripts/jenkins_build_kbn_tp_sample_panel_action.sh diff --git a/.ci/Jenkinsfile_flaky b/.ci/Jenkinsfile_flaky index befb8d259b5b6..425a5e71798b1 100644 --- a/.ci/Jenkinsfile_flaky +++ b/.ci/Jenkinsfile_flaky @@ -35,7 +35,7 @@ kibanaPipeline(timeoutMinutes: 180) { if (!IS_XPACK) { kibanaPipeline.buildOss() if (CI_GROUP == '1') { - runbld("./test/scripts/jenkins_build_kbn_tp_sample_panel_action.sh", "Build kbn tp sample panel action for ciGroup1") + runbld("./test/scripts/jenkins_build_kbn_sample_panel_action.sh", "Build kbn tp sample panel action for ciGroup1") } } else { kibanaPipeline.buildXpack() diff --git a/test/plugin_functional/plugins/kbn_sample_panel_action/kibana.json b/test/plugin_functional/plugins/kbn_sample_panel_action/kibana.json new file mode 100644 index 0000000000000..109afbcd5dabd --- /dev/null +++ b/test/plugin_functional/plugins/kbn_sample_panel_action/kibana.json @@ -0,0 +1,9 @@ +{ + "id": "kbn_sample_panel_action", + "version": "0.0.1", + "kibanaVersion": "kibana", + "configPath": ["kbn_sample_panel_action"], + "server": false, + "ui": true, + "requiredPlugins": ["uiActions", "embeddable"] +} \ No newline at end of file diff --git a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/package.json b/test/plugin_functional/plugins/kbn_sample_panel_action/package.json similarity index 70% rename from test/plugin_functional/plugins/kbn_tp_sample_panel_action/package.json rename to test/plugin_functional/plugins/kbn_sample_panel_action/package.json index 8bc9afbc803a5..914ff39884fa3 100644 --- a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/package.json +++ b/test/plugin_functional/plugins/kbn_sample_panel_action/package.json @@ -1,7 +1,7 @@ { - "name": "kbn_tp_sample_panel_action", + "name": "kbn_sample_panel_action", "version": "1.0.0", - "main": "target/test/plugin_functional/plugins/kbn_tp_sample_panel_action", + "main": "target/test/plugin_functional/plugins/kbn_sample_panel_action", "kibana": { "version": "kibana", "templateVersion": "1.0.0" @@ -16,7 +16,6 @@ "build": "rm -rf './target' && tsc" }, "devDependencies": { - "@kbn/plugin-helpers": "9.0.2", "typescript": "3.7.2" } } diff --git a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/index.ts b/test/plugin_functional/plugins/kbn_sample_panel_action/public/index.ts similarity index 58% rename from test/plugin_functional/plugins/kbn_tp_sample_panel_action/index.ts rename to test/plugin_functional/plugins/kbn_sample_panel_action/public/index.ts index 13b7f8fe52fa0..c7eb1745226cc 100644 --- a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/index.ts +++ b/test/plugin_functional/plugins/kbn_sample_panel_action/public/index.ts @@ -17,24 +17,14 @@ * under the License. */ -import { resolve } from 'path'; +import { PluginInitializer } from 'kibana/public'; +import { + SampelPanelActionTestPlugin, + SampelPanelActionTestPluginSetup, + SampelPanelActionTestPluginStart, +} from './plugin'; -// TODO: use something better once https://github.com/elastic/kibana/issues/26555 is -// figured out. -type KibanaPlugin = any; - -function samplePanelAction(kibana: KibanaPlugin) { - return new kibana.Plugin({ - publicDir: resolve(__dirname, './public'), - uiExports: { - embeddableActions: [ - 'plugins/kbn_tp_sample_panel_action/sample_panel_action', - 'plugins/kbn_tp_sample_panel_action/sample_panel_link', - ], - }, - }); -} - -module.exports = (kibana: KibanaPlugin) => { - return [samplePanelAction(kibana)]; -}; +export const plugin: PluginInitializer< + SampelPanelActionTestPluginSetup, + SampelPanelActionTestPluginStart +> = () => new SampelPanelActionTestPlugin(); diff --git a/test/plugin_functional/plugins/kbn_sample_panel_action/public/plugin.ts b/test/plugin_functional/plugins/kbn_sample_panel_action/public/plugin.ts new file mode 100644 index 0000000000000..8ea8d2ff49e3b --- /dev/null +++ b/test/plugin_functional/plugins/kbn_sample_panel_action/public/plugin.ts @@ -0,0 +1,47 @@ +/* + * 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 { CoreSetup, Plugin } from 'kibana/public'; +import { UiActionsSetup } from '../../../../../src/plugins/ui_actions/public'; +import { CONTEXT_MENU_TRIGGER } from '../../../../../src/plugins/embeddable/public'; +import { createSamplePanelAction } from './sample_panel_action'; +import { createSamplePanelLink } from './sample_panel_link'; + +export class SampelPanelActionTestPlugin + implements Plugin { + public setup(core: CoreSetup, { uiActions }: { uiActions: UiActionsSetup }) { + const samplePanelAction = createSamplePanelAction(core.getStartServices); + + uiActions.registerAction(samplePanelAction); + uiActions.attachAction(CONTEXT_MENU_TRIGGER, samplePanelAction); + + const samplePanelLink = createSamplePanelLink(); + + uiActions.registerAction(samplePanelLink); + uiActions.attachAction(CONTEXT_MENU_TRIGGER, samplePanelLink); + + return {}; + } + + public start() {} + public stop() {} +} + +export type SampelPanelActionTestPluginSetup = ReturnType; +export type SampelPanelActionTestPluginStart = ReturnType; diff --git a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/public/sample_panel_action.tsx b/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_action.tsx similarity index 81% rename from test/plugin_functional/plugins/kbn_tp_sample_panel_action/public/sample_panel_action.tsx rename to test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_action.tsx index 8395fddece2a4..18e45c22abaca 100644 --- a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/public/sample_panel_action.tsx +++ b/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_action.tsx @@ -16,23 +16,23 @@ * specific language governing permissions and limitations * under the License. */ +import { CoreSetup } from 'kibana/public'; import { EuiFlyoutBody, EuiFlyoutHeader, EuiTitle } from '@elastic/eui'; import React from 'react'; -import { npStart, npSetup } from 'ui/new_platform'; -import { CONTEXT_MENU_TRIGGER, IEmbeddable } from '../../../../../src/plugins/embeddable/public'; +import { IEmbeddable } from '../../../../../src/plugins/embeddable/public'; import { createAction, ActionType } from '../../../../../src/plugins/ui_actions/public'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; // Casting to ActionType is a hack - in a real situation use // declare module and add this id to ActionContextMapping. -export const SAMPLE_PANEL_ACTION = 'SAMPLE_PANEL_ACTION' as ActionType; +export const SAMPLE_PANEL_ACTION = 'samplePanelAction' as ActionType; export interface SamplePanelActionContext { embeddable: IEmbeddable; } -function createSamplePanelAction() { +export function createSamplePanelAction(getStartServices: CoreSetup['getStartServices']) { return createAction({ type: SAMPLE_PANEL_ACTION, getDisplayName: () => 'Sample Panel Action', @@ -40,7 +40,8 @@ function createSamplePanelAction() { if (!embeddable) { return; } - npStart.core.overlays.openFlyout( + const openFlyout = (await getStartServices())[0].overlays.openFlyout; + openFlyout( toMountPoint( @@ -60,7 +61,3 @@ function createSamplePanelAction() { }, }); } - -const action = createSamplePanelAction(); -npSetup.plugins.uiActions.registerAction(action); -npSetup.plugins.uiActions.attachAction(CONTEXT_MENU_TRIGGER, action); diff --git a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/public/sample_panel_link.ts b/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_link.ts similarity index 82% rename from test/plugin_functional/plugins/kbn_tp_sample_panel_action/public/sample_panel_link.ts rename to test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_link.ts index 4b09be4db8a60..b0f1219a815a3 100644 --- a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/public/sample_panel_link.ts +++ b/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_link.ts @@ -16,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { npStart } from 'ui/new_platform'; import { Action, createAction, ActionType } from '../../../../../src/plugins/ui_actions/public'; -import { CONTEXT_MENU_TRIGGER } from '../../../../../src/plugins/embeddable/public'; // Casting to ActionType is a hack - in a real situation use // declare module and add this id to ActionContextMapping. @@ -31,7 +29,3 @@ export const createSamplePanelLink = (): Action => execute: async () => {}, getHref: () => 'https://example.com/kibana/test', }); - -const action = createSamplePanelLink(); -npStart.plugins.uiActions.registerAction(action); -npStart.plugins.uiActions.attachAction(CONTEXT_MENU_TRIGGER, action); diff --git a/test/plugin_functional/plugins/kbn_tp_sample_panel_action/tsconfig.json b/test/plugin_functional/plugins/kbn_sample_panel_action/tsconfig.json similarity index 100% rename from test/plugin_functional/plugins/kbn_tp_sample_panel_action/tsconfig.json rename to test/plugin_functional/plugins/kbn_sample_panel_action/tsconfig.json diff --git a/test/plugin_functional/test_suites/panel_actions/index.js b/test/plugin_functional/test_suites/panel_actions/index.js index 1c4b30771f3cc..bacd930c76e56 100644 --- a/test/plugin_functional/test_suites/panel_actions/index.js +++ b/test/plugin_functional/test_suites/panel_actions/index.js @@ -32,10 +32,9 @@ export default function({ getService, getPageObjects, loadTestFile }) { const browser = getService('browser'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['dashboard']); + const PageObjects = getPageObjects(['common', 'dashboard']); - // FLAKY: https://github.com/elastic/kibana/issues/41050 - describe.skip('pluggable panel actions', function() { + describe('pluggable panel actions', function() { before(async () => { await browser.setWindowSize(1300, 900); await esArchiver.load(KIBANA_ARCHIVE_PATH); diff --git a/test/scripts/jenkins_build_kbn_sample_panel_action.sh b/test/scripts/jenkins_build_kbn_sample_panel_action.sh new file mode 100644 index 0000000000000..0c425d61d0528 --- /dev/null +++ b/test/scripts/jenkins_build_kbn_sample_panel_action.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +source src/dev/ci_setup/setup_env.sh + +cd test/plugin_functional/plugins/kbn_sample_panel_action; +if [[ ! -d "target" ]]; then + checks-reporter-with-killswitch "Build kbn_sample_panel_action" yarn build; +fi +cd -; diff --git a/test/scripts/jenkins_build_kbn_tp_sample_panel_action.sh b/test/scripts/jenkins_build_kbn_tp_sample_panel_action.sh deleted file mode 100755 index 4b16e3b32fefd..0000000000000 --- a/test/scripts/jenkins_build_kbn_tp_sample_panel_action.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -source src/dev/ci_setup/setup_env.sh - -cd test/plugin_functional/plugins/kbn_tp_sample_panel_action; -if [[ ! -d "target" ]]; then - checks-reporter-with-killswitch "Build kbn_tp_sample_panel_action" yarn build; -fi -cd -; diff --git a/test/scripts/jenkins_ci_group.sh b/test/scripts/jenkins_ci_group.sh index 82d71cbdaae62..9110a13c452c3 100755 --- a/test/scripts/jenkins_ci_group.sh +++ b/test/scripts/jenkins_ci_group.sh @@ -5,7 +5,7 @@ source test/scripts/jenkins_test_setup_oss.sh checks-reporter-with-killswitch "Functional tests / Group ${CI_GROUP}" yarn run grunt "run:functionalTests_ciGroup${CI_GROUP}"; if [ "$CI_GROUP" == "1" ]; then - source test/scripts/jenkins_build_kbn_tp_sample_panel_action.sh + source test/scripts/jenkins_build_kbn_sample_panel_action.sh yarn run grunt run:pluginFunctionalTestsRelease --from=source; yarn run grunt run:exampleFunctionalTestsRelease --from=source; yarn run grunt run:interpreterFunctionalTestsRelease;