Skip to content

Commit

Permalink
[Lens] Temporarily exclude Mosaic/Waffle from the suggestions list (#…
Browse files Browse the repository at this point in the history
…120488)

* [Lens] Temporarily exclude Mosaic/Waffle from the suggestions list

* Update suggestions.test.ts
  • Loading branch information
alexwizp authored Dec 7, 2021
1 parent c4edb8c commit 10bc8ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 161 deletions.
154 changes: 3 additions & 151 deletions x-pack/plugins/lens/public/pie_visualization/suggestions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ describe('suggestions', () => {
).toHaveLength(0);
});

it('mosaic type should be added only in case of 2 groups', () => {
it('mosaic type should be hidden from the suggestion list', () => {
expect(
suggestions({
table: {
Expand Down Expand Up @@ -827,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<typeof suggestions>[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 []`);
});
});
Expand Down Expand Up @@ -952,7 +861,7 @@ describe('suggestions', () => {
).toHaveLength(0);
});

it('waffle type should be added only in case of 1 group', () => {
it('waffle type should be hidden from the suggestion list', () => {
expect(
suggestions({
table: {
Expand All @@ -971,14 +880,13 @@ describe('suggestions', () => {
changeType: 'unchanged',
},
state: {
shape: 'waffle',
shape: 'pie',
layers: [
{
layerId: 'first',
layerType: layerTypes.DATA,
groups: ['a', 'b'],
metric: 'c',

numberDisplay: 'hidden',
categoryDisplay: 'inside',
legendDisplay: 'show',
Expand All @@ -993,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<typeof suggestions>[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 }) => !hide && 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 []`);
});
});
});
12 changes: 2 additions & 10 deletions x-pack/plugins/lens/public/pie_visualization/suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,7 @@ export function suggestions({
],
},
previewIcon: 'bullseye',
hide:
groups.length !== 2 ||
table.changeType === 'reduced' ||
hasIntervalScale(groups) ||
(state && state.shape === 'mosaic'),
hide: true,
});
}

Expand Down Expand Up @@ -275,11 +271,7 @@ export function suggestions({
],
},
previewIcon: 'bullseye',
hide:
groups.length !== 1 ||
table.changeType === 'reduced' ||
hasIntervalScale(groups) ||
(state && state.shape === 'waffle'),
hide: true,
});
}

Expand Down

0 comments on commit 10bc8ca

Please sign in to comment.