From 793aa061087dc9cf8ed2af0d1242c0b2b3b8c17d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 28 Dec 2023 18:54:26 +0100 Subject: [PATCH 1/7] Improve discover histogram tests --- .../apps/discover/group1/_discover_histogram.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test/functional/apps/discover/group1/_discover_histogram.ts b/test/functional/apps/discover/group1/_discover_histogram.ts index 72ad1854a605e..3baff5c73eea2 100644 --- a/test/functional/apps/discover/group1/_discover_histogram.ts +++ b/test/functional/apps/discover/group1/_discover_histogram.ts @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const queryBar = getService('queryBar'); - describe('discover histogram', function describeIndexTests() { + describe.only('discover histogram', function describeIndexTests() { before(async () => { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.load('test/functional/fixtures/es_archiver/long_window_logstash'); @@ -43,6 +43,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await security.testUser.setRoles(['kibana_admin', 'long_window_logstash']); await kibanaServer.uiSettings.replace(defaultSettings); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); }); after(async () => { @@ -65,13 +66,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should modify the time range when the histogram is brushed', async function () { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); // this is the number of renderings of the histogram needed when new data is fetched let renderingCountInc = 1; const prevRenderingCount = await elasticChart.getVisualizationRenderingCount(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await queryBar.submitQuery(); await retry.waitFor('chart rendering complete', async () => { const actualCount = await elasticChart.getVisualizationRenderingCount(); const expectedCount = prevRenderingCount + renderingCountInc; @@ -107,8 +105,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should update correctly when switching data views and brushing the histogram', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('logstash-*'); await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('long-window-logstash-*'); @@ -281,7 +277,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should recover from broken query search when clearing the query bar', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); // Make sure the chart is visible await testSubjects.click('unifiedHistogramChartOptionsToggle'); await testSubjects.click('unifiedHistogramChartToggle'); @@ -304,7 +299,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should reset all histogram state when resetting the saved search', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); const savedSearch = 'histogram state'; await PageObjects.discover.saveSearch(savedSearch); await PageObjects.discover.chooseBreakdownField('extension.keyword'); From 582349b5cdbf7db5b41f90665b8a45efd19f39f9 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 28 Dec 2023 21:26:38 +0100 Subject: [PATCH 2/7] Undo change --- test/functional/apps/discover/group1/_discover_histogram.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional/apps/discover/group1/_discover_histogram.ts b/test/functional/apps/discover/group1/_discover_histogram.ts index 3baff5c73eea2..2f852e047ff0f 100644 --- a/test/functional/apps/discover/group1/_discover_histogram.ts +++ b/test/functional/apps/discover/group1/_discover_histogram.ts @@ -299,6 +299,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should reset all histogram state when resetting the saved search', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.timePicker.setDefaultAbsoluteRange(); const savedSearch = 'histogram state'; await PageObjects.discover.saveSearch(savedSearch); await PageObjects.discover.chooseBreakdownField('extension.keyword'); From 6249699723494faa9152659b959bec257679ed85 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 28 Dec 2023 22:37:13 +0100 Subject: [PATCH 3/7] remove describe.only --- test/functional/apps/discover/group1/_discover_histogram.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/discover/group1/_discover_histogram.ts b/test/functional/apps/discover/group1/_discover_histogram.ts index 2f852e047ff0f..5926335dbe0d2 100644 --- a/test/functional/apps/discover/group1/_discover_histogram.ts +++ b/test/functional/apps/discover/group1/_discover_histogram.ts @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const queryBar = getService('queryBar'); - describe.only('discover histogram', function describeIndexTests() { + describe('discover histogram', function describeIndexTests() { before(async () => { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.load('test/functional/fixtures/es_archiver/long_window_logstash'); From be9a3f6d227f5fed083ea500310c845f146c2060 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 28 Dec 2023 22:53:30 +0100 Subject: [PATCH 4/7] Align serverless and stateful test --- .../apps/discover/group1/_discover_histogram.ts | 3 +-- .../common/discover/group1/_discover_histogram.ts | 9 ++------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/test/functional/apps/discover/group1/_discover_histogram.ts b/test/functional/apps/discover/group1/_discover_histogram.ts index 5926335dbe0d2..64e9b0e47dc90 100644 --- a/test/functional/apps/discover/group1/_discover_histogram.ts +++ b/test/functional/apps/discover/group1/_discover_histogram.ts @@ -289,8 +289,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // now remove the query await queryBar.clearQuery(); - await queryBar.clickQuerySubmitButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await queryBar.submitQuery(); await PageObjects.discover.waitUntilSearchingHasFinished(); // check no error state expect(await PageObjects.discover.isChartVisible()).to.be(true); diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts b/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts index becf81ab3da9f..750b164a52fe7 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts @@ -42,6 +42,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await security.testUser.setRoles(['kibana_admin', 'long_window_logstash']); await kibanaServer.uiSettings.replace(defaultSettings); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); }); after(async () => { @@ -64,13 +65,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should modify the time range when the histogram is brushed', async function () { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); // this is the number of renderings of the histogram needed when new data is fetched let renderingCountInc = 1; const prevRenderingCount = await elasticChart.getVisualizationRenderingCount(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await queryBar.submitQuery(); await retry.waitFor('chart rendering complete', async () => { const actualCount = await elasticChart.getVisualizationRenderingCount(); const expectedCount = prevRenderingCount + renderingCountInc; @@ -108,8 +106,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should update correctly when switching data views and brushing the histogram', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('logstash-*'); await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('long-window-logstash-*'); @@ -284,7 +280,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should recover from broken query search when clearing the query bar', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); // Make sure the chart is visible await testSubjects.click('unifiedHistogramChartOptionsToggle'); await testSubjects.click('unifiedHistogramChartToggle'); From 870f54825e424d918ed6b1b5f8d946e10c58faac Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 29 Dec 2023 11:52:45 +0100 Subject: [PATCH 5/7] Update _discover_histogram.ts --- .../test_suites/common/discover/group1/_discover_histogram.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts b/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts index 750b164a52fe7..c896088d13ebd 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts @@ -106,6 +106,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should update correctly when switching data views and brushing the histogram', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.timePicker.setDefaultAbsoluteRange(); + await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('logstash-*'); await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('long-window-logstash-*'); From 0fd7a784ec990222f88e7ac3477b6385bd03e80b Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 29 Dec 2023 11:53:24 +0100 Subject: [PATCH 6/7] Update _discover_histogram.ts --- test/functional/apps/discover/group1/_discover_histogram.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/functional/apps/discover/group1/_discover_histogram.ts b/test/functional/apps/discover/group1/_discover_histogram.ts index 64e9b0e47dc90..3d1db686e6f36 100644 --- a/test/functional/apps/discover/group1/_discover_histogram.ts +++ b/test/functional/apps/discover/group1/_discover_histogram.ts @@ -105,6 +105,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should update correctly when switching data views and brushing the histogram', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.timePicker.setDefaultAbsoluteRange(); + await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('logstash-*'); await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('long-window-logstash-*'); From e0cd8bc76f20f8a1ad3af9342c6104d0bb89e580 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 29 Dec 2023 14:16:49 +0100 Subject: [PATCH 7/7] Fix tests --- test/functional/apps/discover/group1/_discover_histogram.ts | 2 -- .../test_suites/common/discover/group1/_discover_histogram.ts | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/test/functional/apps/discover/group1/_discover_histogram.ts b/test/functional/apps/discover/group1/_discover_histogram.ts index 3d1db686e6f36..64e9b0e47dc90 100644 --- a/test/functional/apps/discover/group1/_discover_histogram.ts +++ b/test/functional/apps/discover/group1/_discover_histogram.ts @@ -105,8 +105,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should update correctly when switching data views and brushing the histogram', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('logstash-*'); await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('long-window-logstash-*'); diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts b/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts index c896088d13ebd..ccba699ffa710 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/group1/_discover_histogram.ts @@ -106,8 +106,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should update correctly when switching data views and brushing the histogram', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('logstash-*'); await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.discover.selectIndexPattern('long-window-logstash-*'); @@ -116,7 +114,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.discover.waitUntilSearchingHasFinished(); // TODO: The Serverless sidebar causes `PageObjects.discover.brushHistogram()` // to brush a different range in the histogram, resulting in a different count - expect(await PageObjects.discover.getHitCount()).to.be('12'); + expect(await PageObjects.discover.getHitCount()).to.be('10'); }); it('should update the histogram timerange when the query is resubmitted', async function () {