@@ -222,19 +222,18 @@ describe('Query-Level Monitors', () => {
222222 // Wait for page to load
223223 cy . contains ( 'Select data' ) ;
224224
225- // Click on the Index field and type in multiple index names to replicate the bug.
226- // Each step re-queries the element because clicking triggers an async fetch
227- // of remote indexes, and each {enter} causes a React re-render that detaches
228- // the original input element from the DOM.
225+ // Allow the page to fully load and render the index options before
226+ // interacting with the combo box. On slow CI machines the combo box
227+ // options aren't ready immediately after 'Select data' appears.
228+ cy . wait ( 3000 ) ;
229+
229230 cy . get ( '#index' ) . click ( { force : true } ) ;
230231 cy . get ( '#index' ) . type ( `${ TESTING_INDEX_A } {enter}` , { force : true } ) ;
232+ cy . wait ( 1000 ) ;
231233 cy . get ( '#index' ) . type ( `${ TESTING_INDEX_B } {enter}` , { force : true } ) ;
232234 cy . get ( '#index' ) . trigger ( 'blur' , { force : true } ) ;
233235
234- // Confirm Index field only contains the expected text
235- cy . get ( '[data-test-subj="indicesComboBox"]' ) . contains ( '*' , {
236- timeout : ALERTING_PLUGIN_TIMEOUT ,
237- } ) ;
236+ // Confirm Index field contains the expected indices as pills
238237 cy . get ( '[data-test-subj="indicesComboBox"]' ) . contains ( TESTING_INDEX_A , {
239238 timeout : ALERTING_PLUGIN_TIMEOUT ,
240239 } ) ;
@@ -353,11 +352,14 @@ describe('Query-Level Monitors', () => {
353352 // Wait for page to load
354353 cy . contains ( 'Select data' ) ;
355354
356- // Wait for input to load and then type in the index name
357- cy . get ( '#index' ) . type (
358- `{backspace}${ ALERTING_INDEX . SAMPLE_DATA_ECOMMERCE } {enter}` ,
359- { force : true }
360- ) ;
355+ // Wait for input to load and then type in the index name.
356+ // The backspace removes the existing index pill; allow time for the
357+ // combo box to stabilize before typing the new index name.
358+ cy . get ( '#index' ) . type ( `{backspace}` , { force : true } ) ;
359+ cy . wait ( 2000 ) ;
360+ cy . get ( '#index' ) . type ( `${ ALERTING_INDEX . SAMPLE_DATA_ECOMMERCE } {enter}` , {
361+ force : true ,
362+ } ) ;
361363
362364 // Enter the time field
363365 cy . get ( '#timeField' ) . type ( 'order_date{downArrow}{enter}' , {
@@ -378,8 +380,10 @@ describe('Query-Level Monitors', () => {
378380 ) ;
379381 }
380382
381- // Click save button
383+ // Click save button and wait for the monitor update API to complete
384+ cy . intercept ( 'PUT' , '**/api/alerting/monitors/*' ) . as ( 'saveMonitor' ) ;
382385 cy . get ( 'button' ) . contains ( 'Save' ) . last ( ) . click ( { force : true } ) ;
386+ cy . wait ( '@saveMonitor' , { timeout : ALERTING_PLUGIN_TIMEOUT } ) ;
383387
384388 // Confirm we can see the correct number of rows in the trigger list by checking <caption> element
385389 cy . contains ( `This table contains ${ triggers . length } rows` , {
0 commit comments