Skip to content

Commit

Permalink
Migrate test plugins ⇒ NP (kbn_tp_sample_panel_action) (elastic#60749)
Browse files Browse the repository at this point in the history
* Migrated sample_action to NP. Panel action tests returned to the test flow.

* fixed names

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
VladLasitsa and elasticmachine committed Apr 2, 2020
1 parent e57ef04 commit 52ee957
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .ci/Jenkinsfile_flaky
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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"]
}
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -16,7 +16,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"@kbn/plugin-helpers": "9.0.2",
"typescript": "3.7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Original file line number Diff line number Diff line change
@@ -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<SampelPanelActionTestPluginSetup, SampelPanelActionTestPluginStart> {
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<SampelPanelActionTestPlugin['setup']>;
export type SampelPanelActionTestPluginStart = ReturnType<SampelPanelActionTestPlugin['start']>;
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,32 @@
* 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<typeof SAMPLE_PANEL_ACTION>({
type: SAMPLE_PANEL_ACTION,
getDisplayName: () => 'Sample Panel Action',
execute: async ({ embeddable }: SamplePanelActionContext) => {
if (!embeddable) {
return;
}
npStart.core.overlays.openFlyout(
const openFlyout = (await getStartServices())[0].overlays.openFlyout;
openFlyout(
toMountPoint(
<React.Fragment>
<EuiFlyoutHeader>
Expand All @@ -60,7 +61,3 @@ function createSamplePanelAction() {
},
});
}

const action = createSamplePanelAction();
npSetup.plugins.uiActions.registerAction(action);
npSetup.plugins.uiActions.attachAction(CONTEXT_MENU_TRIGGER, action);
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
5 changes: 2 additions & 3 deletions test/plugin_functional/test_suites/panel_actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions test/scripts/jenkins_build_kbn_sample_panel_action.sh
Original file line number Diff line number Diff line change
@@ -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 -;
9 changes: 0 additions & 9 deletions test/scripts/jenkins_build_kbn_tp_sample_panel_action.sh

This file was deleted.

2 changes: 1 addition & 1 deletion test/scripts/jenkins_ci_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 52ee957

Please sign in to comment.