[8.12] [Discover] Improve histogram functional tests (#174038) (#174065)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[Discover] Improve histogram functional tests
(#174038)](https://github.com/elastic/kibana/pull/174038)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Matthias
Wilhelm","email":"matthias.wilhelm@elastic.co"},"sourceCommit":{"committedDate":"2023-12-29T18:08:11Z","message":"[Discover]
Improve histogram functional tests (#174038)\n\nImproving Discover
histogram tests to fix occasional flakiness due to a redundant time
range UI
interaction","sha":"3c0a48c86f927fb4998b734b7134203b8fd93090","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:skip","Team:DataDiscovery","backport:prev-minor","v8.13.0"],"title":"[Discover]
Improve histogram functional
tests","number":174038,"url":"https://github.com/elastic/kibana/pull/174038","mergeCommit":{"message":"[Discover]
Improve histogram functional tests (#174038)\n\nImproving Discover
histogram tests to fix occasional flakiness due to a redundant time
range UI
interaction","sha":"3c0a48c86f927fb4998b734b7134203b8fd93090"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/174038","number":174038,"mergeCommit":{"message":"[Discover]
Improve histogram functional tests (#174038)\n\nImproving Discover
histogram tests to fix occasional flakiness due to a redundant time
range UI
interaction","sha":"3c0a48c86f927fb4998b734b7134203b8fd93090"}}]}]
BACKPORT-->

Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
This commit is contained in:
Kibana Machine 2023-12-29 16:07:41 -05:00 committed by GitHub
parent b88f55a8cf
commit 1fb896593f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 17 deletions

View file

@ -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');
@ -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);

View file

@ -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-*');
@ -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 () {
@ -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');