@@ -427,6 +427,7 @@ export default class CodeGraph extends BasePage {
427427 const button = this . searchBarOptionBtn ( buttonNum ) ;
428428 await button . waitFor ( { state : "visible" } )
429429 await button . click ( ) ;
430+ await this . page . waitForTimeout ( 4000 ) ;
430431 }
431432
432433 async getSearchBarInputValue ( ) : Promise < string > {
@@ -668,29 +669,36 @@ export default class CodeGraph extends BasePage {
668669 }
669670
670671 async isNodeToolTipVisible ( node : string ) : Promise < boolean > {
671- try {
672- await this . page . waitForTimeout ( 10000 ) ;
673- const count = await this . nodeToolTip ( node ) . count ( ) ;
674- if ( count === 0 ) {
675- console . error ( "Tooltip not found" ) ;
676- return false ;
677- }
672+ return await this . nodeToolTip ( node ) . isVisible ( ) ;
673+ }
678674
679- const box = await this . nodeToolTip ( node ) . boundingBox ( ) ;
680- if ( box && box . width > 0 && box . height > 0 ) {
681- return true ;
682- }
675+ async waitForCanvasAnimationToEnd ( timeout = 5000 ) : Promise < void > {
676+ const canvasHandle = await this . canvasElement . elementHandle ( ) ;
683677
684- return await this . nodeToolTip ( node ) . evaluate ( el => {
685- const style = getComputedStyle ( el ) ;
686- return style . visibility === 'visible' && parseFloat ( style . opacity ) > 0 ;
687- } ) ;
688- } catch ( error ) {
689- console . error ( "Tooltip visibility check failed:" , error ) ;
690- return false ;
678+ if ( ! canvasHandle ) {
679+ throw new Error ( "Canvas element not found!" ) ;
691680 }
692- }
693-
694-
695681
682+ await this . page . waitForFunction (
683+ ( canvas : HTMLElement ) => {
684+ const canvasElement = canvas as HTMLCanvasElement ;
685+ if ( ! canvasElement ) return false ;
686+
687+ const ctx = canvasElement . getContext ( '2d' ) ;
688+ if ( ! ctx ) return false ;
689+
690+ const getPixelData = ( ) => ctx . getImageData ( 0 , 0 , canvasElement . width , canvasElement . height ) . data ;
691+ const imageData1 = getPixelData ( ) ;
692+
693+ return new Promise < boolean > ( ( resolve ) => {
694+ setTimeout ( ( ) => {
695+ const imageData2 = getPixelData ( ) ;
696+ resolve ( JSON . stringify ( imageData1 ) === JSON . stringify ( imageData2 ) ) ;
697+ } , 500 ) ;
698+ } ) ;
699+ } ,
700+ canvasHandle as unknown as HTMLElement ,
701+ { timeout }
702+ ) ;
703+ }
696704}
0 commit comments