1717// 8. Delete a forecaster from the list page
1818// ============================================================================
1919
20- import { AD_FIXTURE_BASE_PATH } from '../../../utils/constants' ;
20+ import { AD_FIXTURE_BASE_PATH , BASE_PATH } from '../../../utils/constants' ;
2121import { setStorageItem } from '../../../utils/plugins/dashboards-assistant/helpers' ;
22- import { BASE_PATH } from '../../../utils/constants' ;
2322
2423const setupIndexWithData = ( indexName ) => {
2524 // Create index mapping first
@@ -82,6 +81,8 @@ context('list forecaster workflow', () => {
8281 const TEST_INDEX_NAME_2 = 'sample-forecast-index-2' ;
8382
8483 let restoreTenantSwitchModal ;
84+ let restoreWelcomeModal ;
85+ let restoreThemeModal ;
8586
8687 beforeEach ( ( ) => {
8788 // disable the tenant switch modal
@@ -90,6 +91,16 @@ context('list forecaster workflow', () => {
9091 'opendistro::security::tenant::show_popup' ,
9192 'false'
9293 ) ;
94+ restoreWelcomeModal = setStorageItem (
95+ localStorage ,
96+ 'home:welcome:show' ,
97+ 'false'
98+ ) ;
99+ restoreThemeModal = setStorageItem (
100+ localStorage ,
101+ 'home:newThemeModal:show' ,
102+ 'false'
103+ ) ;
93104 // Visit OSD
94105 // requrired otherwise we encounter connection issue in later test
95106 cy . visit ( `${ BASE_PATH } /app/home` ) ;
@@ -107,6 +118,12 @@ context('list forecaster workflow', () => {
107118 if ( restoreTenantSwitchModal ) {
108119 restoreTenantSwitchModal ( ) ;
109120 }
121+ if ( restoreWelcomeModal ) {
122+ restoreWelcomeModal ( ) ;
123+ }
124+ if ( restoreThemeModal ) {
125+ restoreThemeModal ( ) ;
126+ }
110127 } ) ;
111128
112129 it ( 'Full creation - based on real index' , ( ) => {
@@ -213,25 +230,44 @@ context('list forecaster workflow', () => {
213230 // Wait a moment for the cell to become active
214231 cy . wait ( 500 ) ;
215232
216- // Try to trigger hover as well, in case that's needed
217- cy . get ( '@statusCell' ) . trigger ( 'mouseover' ) ;
218-
219- // Check if the expand button is now visible, if not, try clicking again
220- cy . get ( '@statusCell' ) . then ( ( $cell ) => {
221- const expandButton = $cell . find (
222- 'button.euiDataGridRowCell__expandButtonIcon'
223- ) ;
224- if ( expandButton . length === 0 || ! expandButton . is ( ':visible' ) ) {
225- cy . log ( 'Expand button not visible, trying to click cell again' ) ;
226- cy . get ( '@statusCell' ) . click ( { force : true } ) ;
227- cy . wait ( 500 ) ;
233+ // Retry mechanism to handle the expand button visibility
234+ const attemptExpandButtonClick = ( retries = 5 ) => {
235+ if ( retries === 0 ) {
236+ throw new Error ( 'Failed to click expand button after multiple retries' ) ;
228237 }
229- } ) ;
230238
231- // Find the now-visible expand button inside the cell.
239+ cy . get ( '@statusCell' ) . then ( ( $cell ) => {
240+ const expandButton = $cell . find (
241+ 'button.euiDataGridRowCell__expandButtonIcon'
242+ ) ;
243+
244+ if ( expandButton . length === 0 ) {
245+ cy . log ( `Expand button not found, retries left: ${ retries } ` ) ;
246+ cy . get ( '@statusCell' ) . click ( { force : true } ) ;
247+ cy . wait ( 300 ) ;
248+ attemptExpandButtonClick ( retries - 1 ) ;
249+ } else if ( ! expandButton . is ( ':visible' ) ) {
250+ cy . log ( `Expand button not visible, retries left: ${ retries } ` ) ;
251+ // Try multiple hover techniques
252+ cy . get ( '@statusCell' )
253+ . scrollIntoView ( )
254+ . trigger ( 'mouseenter' , { force : true } )
255+ . trigger ( 'mouseover' , { force : true } )
256+ . trigger ( 'mousemove' , { force : true } ) ;
257+ cy . wait ( 200 ) ;
258+ attemptExpandButtonClick ( retries - 1 ) ;
259+ } else {
260+ cy . log ( 'Expand button is visible, clicking it' ) ;
261+ cy . wrap ( expandButton ) . click ( { force : true } ) ;
262+ }
263+ } ) ;
264+ } ;
265+
266+ attemptExpandButtonClick ( ) ;
267+
268+ // Alias the button for later use
232269 cy . get ( '@statusCell' )
233270 . find ( 'button.euiDataGridRowCell__expandButtonIcon' )
234- . should ( 'be.visible' )
235271 . as ( 'expandButton' ) ;
236272
237273 // Click the expand button to open the final popover.
0 commit comments