From 6df8f1188a5e6ae1e43efc7f8d3905e0d9c596d4 Mon Sep 17 00:00:00 2001 From: Marta Bondyra Date: Thu, 24 Oct 2024 11:31:58 +0200 Subject: [PATCH 1/3] [Discover] Fix suggestions for ES|QL charts --- test/functional/apps/discover/group3/_lens_vis.ts | 5 ++--- .../plugins/lens/public/visualizations/metric/suggestions.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/functional/apps/discover/group3/_lens_vis.ts b/test/functional/apps/discover/group3/_lens_vis.ts index db526fe978610..6c860a76303bf 100644 --- a/test/functional/apps/discover/group3/_lens_vis.ts +++ b/test/functional/apps/discover/group3/_lens_vis.ts @@ -110,8 +110,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return seriesType; } - // Failing: See https://github.com/elastic/kibana/issues/197342 - describe.skip('discover lens vis', function () { + describe('discover lens vis', function () { before(async () => { await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); @@ -616,7 +615,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - await discover.chooseLensSuggestion('barVerticalStacked'); + await discover.chooseLensSuggestion('heatMap'); await changeVisShape('Line'); await testSubjects.existOrFail('unsavedChangesBadge'); diff --git a/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts b/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts index 877d2b45d66af..dfb00a3b7c9ee 100644 --- a/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts @@ -64,7 +64,7 @@ export const getSuggestions: Visualization['getSuggest title: metricColumns[0]?.operation.label || metricLabel, previewIcon: IconChartMetric, score: 0.5, - hide: hasInterval, + hide: bucketedColumns.length, }; const accessorMappings: Pick = From 9e12c6fa50a9ef2104dd3f9aa9d488c12f08f7da Mon Sep 17 00:00:00 2001 From: Marta Bondyra Date: Thu, 24 Oct 2024 13:07:40 +0200 Subject: [PATCH 2/3] fix tests --- .../public/visualizations/metric/suggestions.test.ts | 10 +++++----- .../lens/public/visualizations/metric/suggestions.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/lens/public/visualizations/metric/suggestions.test.ts b/x-pack/plugins/lens/public/visualizations/metric/suggestions.test.ts index 4f1c7b46d06be..c9a97c0d170a0 100644 --- a/x-pack/plugins/lens/public/visualizations/metric/suggestions.test.ts +++ b/x-pack/plugins/lens/public/visualizations/metric/suggestions.test.ts @@ -189,7 +189,7 @@ describe('metric suggestions', () => { breakdownByAccessor: bucketColumn.columnId, }, title: 'Metric', - hide: false, + hide: true, previewIcon: IconChartMetric, score: 0.51, }, @@ -221,7 +221,7 @@ describe('metric suggestions', () => { breakdownByAccessor: bucketColumn.columnId, }, title: 'Metric', - hide: false, + hide: true, previewIcon: IconChartMetric, score: 0.51, }, @@ -294,7 +294,7 @@ describe('metric suggestions', () => { breakdownByAccessor: bucketColumn.columnId, }, title: 'Metric', - hide: false, + hide: true, previewIcon: IconChartMetric, score: 0.52, }, @@ -326,7 +326,7 @@ describe('metric suggestions', () => { breakdownByAccessor: bucketColumn.columnId, }, title: 'Metric', - hide: false, + hide: true, previewIcon: IconChartMetric, score: 0.52, }, @@ -357,7 +357,7 @@ describe('metric suggestions', () => { breakdownByAccessor: bucketColumn.columnId, }, title: 'Metric', - hide: false, + hide: true, previewIcon: IconChartMetric, score: 0.52, }, diff --git a/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts b/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts index dfb00a3b7c9ee..07233bf0147de 100644 --- a/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts @@ -64,7 +64,7 @@ export const getSuggestions: Visualization['getSuggest title: metricColumns[0]?.operation.label || metricLabel, previewIcon: IconChartMetric, score: 0.5, - hide: bucketedColumns.length, + hide: !!bucketedColumns.length, }; const accessorMappings: Pick = From 1b5c65d334e2fdfe0a321e92e42af252a30884c0 Mon Sep 17 00:00:00 2001 From: Marta Bondyra Date: Thu, 24 Oct 2024 13:20:58 +0200 Subject: [PATCH 3/3] change to waffle chart --- test/functional/apps/discover/group3/_lens_vis.ts | 8 ++++---- .../lens/public/visualizations/metric/suggestions.ts | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/functional/apps/discover/group3/_lens_vis.ts b/test/functional/apps/discover/group3/_lens_vis.ts index 6c860a76303bf..5e13c8bbb243c 100644 --- a/test/functional/apps/discover/group3/_lens_vis.ts +++ b/test/functional/apps/discover/group3/_lens_vis.ts @@ -615,8 +615,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - await discover.chooseLensSuggestion('heatMap'); - await changeVisShape('Line'); + await discover.chooseLensSuggestion('waffle'); + await changeVisShape('Treemap'); await testSubjects.existOrFail('unsavedChangesBadge'); await discover.saveUnsavedChanges(); @@ -625,8 +625,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); - expect(await getCurrentVisTitle()).to.be('Line'); - await testSubjects.existOrFail('xyVisChart'); + expect(await getCurrentVisTitle()).to.be('Treemap'); + await testSubjects.existOrFail('partitionVisChart'); }); it('should close lens flyout on revert changes', async () => { diff --git a/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts b/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts index 07233bf0147de..5d066318d734f 100644 --- a/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts +++ b/x-pack/plugins/lens/public/visualizations/metric/suggestions.ts @@ -30,8 +30,6 @@ export const getSuggestions: Visualization['getSuggest const bucketedColumns = table.columns.filter(({ operation }) => operation.isBucketed); - const hasInterval = bucketedColumns.some(({ operation }) => operation.scale === 'interval'); - const unsupportedColumns = table.columns.filter( ({ operation }) => !supportedDataTypes.has(operation.dataType) && !operation.isBucketed );