Skip to content

Commit 07b7b92

Browse files
[9.2] [Discover] Cherry pick a new test for the histogram request and total hits counter (#240803) (#241344)
# Backport This will backport the following commits from `main` to `9.2`: - [[Discover] Cherry pick a new test for the histogram request and total hits counter (#240803)](#240803) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-30T17:54:19Z","message":"[Discover] Cherry pick a new test for the histogram request and total hits counter (#240803)\n\n## Summary\n\nPulled from #239707 to prevent\nissues like in #239564 and to\nprepare for the upcoming changes as in\nhttps://github.com//issues/226313\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"41b43a024d9d9634e06944552db9004ba4022e16","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:DataDiscovery","Feature:UnifiedHistogram","backport:version","v9.3.0","v9.2.1"],"title":"[Discover] Cherry pick a new test for the histogram request and total hits counter","number":240803,"url":"https://github.com/elastic/kibana/pull/240803","mergeCommit":{"message":"[Discover] Cherry pick a new test for the histogram request and total hits counter (#240803)\n\n## Summary\n\nPulled from #239707 to prevent\nissues like in #239564 and to\nprepare for the upcoming changes as in\nhttps://github.com//issues/226313\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"41b43a024d9d9634e06944552db9004ba4022e16"}},"sourceBranch":"main","suggestedTargetBranches":["9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240803","number":240803,"mergeCommit":{"message":"[Discover] Cherry pick a new test for the histogram request and total hits counter (#240803)\n\n## Summary\n\nPulled from #239707 to prevent\nissues like in #239564 and to\nprepare for the upcoming changes as in\nhttps://github.com//issues/226313\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"41b43a024d9d9634e06944552db9004ba4022e16"}},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julia Rechkunova <[email protected]>
1 parent e12fa47 commit 07b7b92

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

src/platform/test/functional/apps/discover/group10/_lens_vis.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1717
const monacoEditor = getService('monacoEditor');
1818
const browser = getService('browser');
1919
const dataViews = getService('dataViews');
20+
const filterBar = getService('filterBar');
21+
const retry = getService('retry');
2022
const { common, discover, header, timePicker } = getPageObjects([
2123
'common',
2224
'discover',
@@ -666,5 +668,55 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
666668
await testSubjects.existOrFail('partitionVisChart');
667669
expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion');
668670
});
671+
672+
it('should be able to recover after an aborted request', async () => {
673+
const reducedTimeRange = {
674+
from: 'Sep 20, 2015 @ 00:00:00.000',
675+
to: 'Sep 20, 2015 @ 23:50:13.253',
676+
};
677+
const reducedTimeSpan = `${reducedTimeRange.from} - ${reducedTimeRange.to} (interval: Auto - 30 minutes)`;
678+
const reducedTotalCount = '4,756';
679+
680+
// add a shorter time range to the recently used list in the time picker
681+
await timePicker.setAbsoluteRange(reducedTimeRange.from, reducedTimeRange.to);
682+
await discover.waitUntilTabIsLoaded();
683+
684+
// go back to default time range
685+
await timePicker.setDefaultAbsoluteRange();
686+
await checkHistogramVis(defaultTimespan, defaultTotalCount);
687+
688+
// trigger the first request
689+
await filterBar.addDslFilter(
690+
JSON.stringify({
691+
error_query: {
692+
indices: [
693+
{
694+
error_type: 'warning',
695+
message: "'Fake slow request'",
696+
name: '*',
697+
stall_time_seconds: 15,
698+
},
699+
],
700+
},
701+
}),
702+
false
703+
);
704+
705+
// wait a moment to ensure the request is in flight
706+
await retry.waitFor('loading state', async () => {
707+
return (
708+
(await header.isGlobalLoadingIndicatorVisible()) && (await discover.isDataGridUpdating())
709+
);
710+
});
711+
712+
// by changing the time range it should abort the previous request, fire a new one and recover from the aborted state
713+
await timePicker.setRecentlyUsedTime(`${reducedTimeRange.from} to ${reducedTimeRange.to}`);
714+
715+
await retry.try(async () => {
716+
// check that the histogram is showing data for the new time range
717+
// and the reported total hits count got updated too
718+
await checkHistogramVis(reducedTimeSpan, reducedTotalCount);
719+
});
720+
});
669721
});
670722
}

src/platform/test/functional/page_objects/discover_page.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,15 @@ export class DiscoverPageObject extends FtrService {
112112
await this.testSubjects.click('addFilter');
113113
}
114114

115+
public async isDataGridUpdating() {
116+
return await this.testSubjects.exists('discoverDataGridUpdating');
117+
}
118+
115119
public async waitUntilSearchingHasFinished() {
116120
await this.testSubjects.missingOrFail('loadingSpinner', {
117121
timeout: this.defaultFindTimeout * 10,
118122
});
123+
// TODO: Should we add a check for `discoverDataGridUpdating` too?
119124
}
120125

121126
public async waitUntilTabIsLoaded() {

src/platform/test/functional/page_objects/time_picker.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ export class TimePickerPageObject extends FtrService {
100100
await this.testSubjects.click(`superDatePickerCommonlyUsed_${option}`);
101101
}
102102

103+
/**
104+
* Sets recently used time (including custom ranges)
105+
* @param option a custom recently used time range (example: "Sep 20, 2015 @ 00:00:00.000 to Sep 20, 2015 @ 23:50:13.253")
106+
*/
107+
async setRecentlyUsedTime(option: string) {
108+
await this.testSubjects.exists('superDatePickerToggleQuickMenuButton', { timeout: 5000 });
109+
await this.testSubjects.click('superDatePickerToggleQuickMenuButton');
110+
const panel = await this.testSubjects.find('superDatePickerQuickMenu');
111+
const buttonByOptionText = await panel.findByXpath(`.//button[text()='${option}']`);
112+
await buttonByOptionText?.click();
113+
}
114+
103115
public async inputValue(dataTestSubj: string, value: string) {
104116
if (this.browser.isFirefox) {
105117
const input = await this.testSubjects.find(dataTestSubj);

0 commit comments

Comments
 (0)