From b10b46b0a34486b03a8ed569b845ed6dfc7eb630 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 6 Dec 2021 17:00:19 +0300 Subject: [PATCH] Update suggestions.test.ts --- .../pie_visualization/suggestions.test.ts | 153 +----------------- .../public/pie_visualization/suggestions.ts | 10 -- 2 files changed, 2 insertions(+), 161 deletions(-) diff --git a/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts b/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts index 4dd3d37189c4e..a2e3f6d3ca865 100644 --- a/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts +++ b/x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts @@ -784,8 +784,7 @@ describe('suggestions', () => { ).toHaveLength(0); }); - /** The following test should be activated when Experimental flag will be removed from the Waffle chart **/ - it.skip('mosaic type should be added only in case of 2 groups', () => { + it('mosaic type should be hidden from the suggestion list', () => { expect( suggestions({ table: { @@ -828,97 +827,6 @@ describe('suggestions', () => { }, keptLayerIds: ['first'], }).filter(({ hide, state }) => !hide && state.shape === 'mosaic') - ).toMatchInlineSnapshot(` - Array [ - Object { - "hide": false, - "previewIcon": "bullseye", - "score": 0.6, - "state": Object { - "layers": Array [ - Object { - "categoryDisplay": "default", - "groups": Array [ - "a", - "b", - ], - "layerId": "first", - "layerType": "data", - "legendDisplay": "show", - "legendMaxLines": 1, - "metric": "c", - "nestedLegend": true, - "numberDisplay": "hidden", - "percentDecimals": 0, - "truncateLegend": true, - }, - ], - "palette": undefined, - "shape": "mosaic", - }, - "title": "As Mosaic", - }, - ] - `); - }); - - it('mosaic type should be added only in case of 2 groups (negative test)', () => { - const meta: Parameters[0] = { - table: { - layerId: 'first', - isMultiRow: true, - columns: [ - { - columnId: 'a', - operation: { label: 'Top 5', dataType: 'string' as DataType, isBucketed: true }, - }, - { - columnId: 'c', - operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false }, - }, - ], - changeType: 'unchanged', - }, - state: { - shape: 'pie', - layers: [ - { - layerId: 'first', - layerType: layerTypes.DATA, - groups: ['a', 'b'], - metric: 'c', - - numberDisplay: 'hidden', - categoryDisplay: 'inside', - legendDisplay: 'show', - percentDecimals: 0, - legendMaxLines: 1, - truncateLegend: true, - nestedLegend: true, - }, - ], - }, - keptLayerIds: ['first'], - }; - - // test with 1 group - expect( - suggestions(meta).filter(({ hide, state }) => !hide && state.shape === 'mosaic') - ).toMatchInlineSnapshot(`Array []`); - - meta.table.columns.push({ - columnId: 'b', - operation: { label: 'Top 6', dataType: 'string' as DataType, isBucketed: true }, - }); - - meta.table.columns.push({ - columnId: 'c', - operation: { label: 'Top 7', dataType: 'string' as DataType, isBucketed: true }, - }); - - // test with 3 groups - expect( - suggestions(meta).filter(({ hide, state }) => !hide && state.shape === 'mosaic') ).toMatchInlineSnapshot(`Array []`); }); }); @@ -953,8 +861,7 @@ describe('suggestions', () => { ).toHaveLength(0); }); - /** The following test should be activated when Experimental flag will be removed from the Mosaic chart **/ - it.skip('waffle type should be added only in case of 1 group', () => { + it('waffle type should be hidden from the suggestion list', () => { expect( suggestions({ table: { @@ -994,61 +901,5 @@ describe('suggestions', () => { }).filter(({ hide, state }) => !hide && state.shape === 'waffle') ).toMatchInlineSnapshot(`Array []`); }); - - it('waffle type should be added only in case of 1 group (negative test)', () => { - const meta: Parameters[0] = { - table: { - layerId: 'first', - isMultiRow: true, - columns: [ - { - columnId: 'c', - operation: { label: 'Count', dataType: 'number' as DataType, isBucketed: false }, - }, - ], - changeType: 'unchanged', - }, - state: { - shape: 'pie', - layers: [ - { - layerId: 'first', - layerType: layerTypes.DATA, - groups: ['a', 'b'], - metric: 'c', - - numberDisplay: 'hidden', - categoryDisplay: 'inside', - legendDisplay: 'show', - percentDecimals: 0, - legendMaxLines: 1, - truncateLegend: true, - nestedLegend: true, - }, - ], - }, - keptLayerIds: ['first'], - }; - - // test with no group - expect( - suggestions(meta).filter(({ hide, state }) => state.shape === 'waffle') - ).toMatchInlineSnapshot(`Array []`); - - meta.table.columns.push({ - columnId: 'b', - operation: { label: 'Top 6', dataType: 'string' as DataType, isBucketed: true }, - }); - - meta.table.columns.push({ - columnId: 'c', - operation: { label: 'Top 7', dataType: 'string' as DataType, isBucketed: true }, - }); - - // test with 2 groups - expect( - suggestions(meta).filter(({ hide, state }) => !hide && state.shape === 'waffle') - ).toMatchInlineSnapshot(`Array []`); - }); }); }); diff --git a/x-pack/plugins/lens/public/pie_visualization/suggestions.ts b/x-pack/plugins/lens/public/pie_visualization/suggestions.ts index cce5299819b20..248f4a82b1694 100644 --- a/x-pack/plugins/lens/public/pie_visualization/suggestions.ts +++ b/x-pack/plugins/lens/public/pie_visualization/suggestions.ts @@ -233,11 +233,6 @@ export function suggestions({ }, previewIcon: 'bullseye', hide: true, - /** The following code should be uncomment when Experimental flag will be removed from Mosaic chart **/ - // groups.length !== 2 || - // table.changeType === 'reduced' || - // hasIntervalScale(groups) || - // (state && state.shape === 'mosaic'), }); } @@ -277,11 +272,6 @@ export function suggestions({ }, previewIcon: 'bullseye', hide: true, - /** The following code should be uncomment when Experimental flag will be removed from Waffle chart **/ - // groups.length !== 1 || - // table.changeType === 'reduced' || - // hasIntervalScale(groups) || - // (state && state.shape === 'waffle'), }); }