Skip to content

Commit

Permalink
[Discover] Improve histogram functional tests (#174038)
Browse files Browse the repository at this point in the history
Improving Discover histogram tests to fix occasional flakiness due to a redundant time range UI interaction
  • Loading branch information
kertal authored Dec 29, 2023
1 parent b31d537 commit 3c0a48c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
12 changes: 3 additions & 9 deletions test/functional/apps/discover/group1/_discover_histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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;
Expand Down Expand Up @@ -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-*');
Expand Down Expand Up @@ -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');
Expand All @@ -294,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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;
Expand Down Expand Up @@ -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-*');
Expand All @@ -118,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 () {
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 3c0a48c

Please sign in to comment.