File tree Expand file tree Collapse file tree
cypress/integration/plugins/anomaly-detection-dashboards-plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,13 +36,16 @@ const clickControlAndVerifyChartUpdate = (buttonAriaLabel) => {
3636 cy . get ( '.echChartStatus' )
3737 . invoke ( 'attr' , 'data-ech-render-count' )
3838 . then ( ( initialRenderCount ) => {
39- cy . get ( `button[aria-label="${ buttonAriaLabel } "]` ) . click ( ) ;
40-
41- // Cypress's .should() will automatically retry until the assertion passes or times out,
42- // which handles the async nature of the re-render.
43- cy . get ( '.echChartStatus' )
44- . invoke ( 'attr' , 'data-ech-render-count' )
45- . should ( 'not.eq' , initialRenderCount ) ;
39+ // Re-check disabled state right before clicking to avoid TOCTOU race
40+ cy . get ( `button[aria-label="${ buttonAriaLabel } "]` ) . then ( ( $btn ) => {
41+ if ( ! $btn . is ( ':disabled' ) ) {
42+ cy . wrap ( $btn ) . click ( ) ;
43+
44+ cy . get ( '.echChartStatus' )
45+ . invoke ( 'attr' , 'data-ech-render-count' )
46+ . should ( 'not.eq' , initialRenderCount ) ;
47+ }
48+ } ) ;
4649 } ) ;
4750 }
4851 } ) ;
You can’t perform that action at this time.
0 commit comments