Skip to content

Commit

Permalink
[Visualize] Fixes wrong display of split warning callout (#120199)
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula authored Dec 2, 2021
1 parent a88ac0c commit 23652de
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React from 'react';
import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest';
import { VisualizeEditorCommon } from './visualize_editor_common';
import { VisualizeEditorVisInstance } from '../types';
import { SplitChartWarning } from './split_chart_warning';

const mockGetLegacyUrlConflict = jest.fn();
const mockRedirectLegacyUrl = jest.fn(() => Promise.resolve());
Expand Down Expand Up @@ -115,4 +116,86 @@ describe('VisualizeEditorCommon', () => {
'TSVB visualization'
);
});

it('should display a warning callout for new heatmap implementation with split aggs', async () => {
const wrapper = shallowWithIntl(
<VisualizeEditorCommon
appState={null}
hasUnsavedChanges={false}
setHasUnsavedChanges={() => {}}
hasUnappliedChanges={false}
isEmbeddableRendered={false}
onAppLeave={() => {}}
visEditorRef={React.createRef()}
visInstance={
{
savedVis: {
id: 'test',
sharingSavedObjectProps: {
outcome: 'conflict',
aliasTargetId: 'alias_id',
},
},
vis: {
type: {
title: 'Heatmap',
name: 'heatmap',
},
data: {
aggs: {
aggs: [
{
schema: 'split',
},
],
},
},
},
} as unknown as VisualizeEditorVisInstance
}
/>
);
expect(wrapper.find(SplitChartWarning).length).toBe(1);
});

it('should not display a warning callout for XY charts with split aggs', async () => {
const wrapper = shallowWithIntl(
<VisualizeEditorCommon
appState={null}
hasUnsavedChanges={false}
setHasUnsavedChanges={() => {}}
hasUnappliedChanges={false}
isEmbeddableRendered={false}
onAppLeave={() => {}}
visEditorRef={React.createRef()}
visInstance={
{
savedVis: {
id: 'test',
sharingSavedObjectProps: {
outcome: 'conflict',
aliasTargetId: 'alias_id',
},
},
vis: {
type: {
title: 'XY',
name: 'line',
},
data: {
aggs: {
aggs: [
{
schema: 'split',
},
],
},
},
},
} as unknown as VisualizeEditorVisInstance
}
/>
);
expect(wrapper.find(SplitChartWarning).length).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export const VisualizeEditorCommon = ({
/>
)}
{visInstance?.vis?.type?.stage === 'experimental' && <ExperimentalVisInfo />}
{!hasHeatmapLegacyhartsEnabled && isSplitChart && <SplitChartWarning />}
{!hasHeatmapLegacyhartsEnabled &&
isSplitChart &&
visInstance?.vis.type.name === 'heatmap' && <SplitChartWarning />}
{visInstance?.vis?.type?.getInfoMessage?.(visInstance.vis)}
{getLegacyUrlConflictCallout()}
{visInstance && (
Expand Down

0 comments on commit 23652de

Please sign in to comment.