From d72961b1b3d4c742310d4ff40a035c0e7e7498f9 Mon Sep 17 00:00:00 2001 From: streamich Date: Thu, 30 Apr 2020 15:21:52 +0200 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20extra=20unit=20tes?= =?UTF-8?q?t=20for=20root=20embeddable=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flyout_create_drilldown.test.tsx | 10 ++++++++++ .../public/services/drilldowns/actions/test_helpers.ts | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx index ee25027959821..5ec1b881317d6 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx @@ -49,6 +49,7 @@ interface CompatibilityParams { isEdit?: boolean; isValueClickTriggerSupported?: boolean; isEmbeddableEnhanced?: boolean; + rootType?: string; } describe('isCompatible', () => { @@ -59,6 +60,7 @@ describe('isCompatible', () => { isEdit = true, isValueClickTriggerSupported = true, isEmbeddableEnhanced = true, + rootType = 'dashboard', }: CompatibilityParams, expectedResult: boolean = true ): Promise { @@ -71,6 +73,8 @@ describe('isCompatible', () => { } ); + embeddable.rootType = rootType; + if (isEmbeddableEnhanced) { embeddable = enhanceEmbeddable(embeddable); } @@ -106,6 +110,12 @@ describe('isCompatible', () => { isEdit: false, }); }); + + test('not compatible if root embeddable is not "dashboard"', async () => { + await assertNonCompatibility({ + rootType: 'visualization', + }); + }); }); describe('execute', () => { diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/test_helpers.ts b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/test_helpers.ts index e50617e2b1e6f..cccacf701a9ad 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/test_helpers.ts +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/test_helpers.ts @@ -15,6 +15,7 @@ import { TriggerContextMapping } from '../../../../../../../src/plugins/ui_actio import { uiActionsEnhancedPluginMock } from '../../../../../advanced_ui_actions/public/mocks'; export class MockEmbeddable extends Embeddable { + public rootType = 'dashboard'; public readonly type = 'mock'; private readonly triggers: Array = []; constructor( @@ -31,7 +32,7 @@ export class MockEmbeddable extends Embeddable { } public getRoot() { return { - type: 'dashboard', + type: this.rootType, } as Embeddable; } }