@@ -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}
0 commit comments