File tree Expand file tree Collapse file tree
workspaces/scorecard/packages/app-legacy/e2e-tests/pages Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,18 +37,25 @@ export class CatalogPage {
3737 }
3838
3939 async loginAndSetLocale ( locale : string ) {
40- this . page . on ( 'dialog' , dialog => dialog . accept ( ) ) ;
40+ // Set up dialog handler before any page navigation to catch potential dialogs
41+ const dialogHandler = ( dialog : any ) => dialog . accept ( ) ;
42+ this . page . on ( 'dialog' , dialogHandler ) ;
4143
42- await this . page . goto ( '/' ) ;
43- const enterButton = this . page . getByRole ( 'button' , { name : 'Enter' } ) ;
44- await expect ( enterButton ) . toBeVisible ( { timeout : 30000 } ) ;
45- await enterButton . click ( ) ;
46- await expect (
47- this . page . getByRole ( 'link' , { name : 'Home' } ) . first ( ) ,
48- ) . toBeVisible ( {
49- timeout : 30000 ,
50- } ) ;
51- await this . switchToLocale ( locale ) ;
44+ try {
45+ await this . page . goto ( '/' ) ;
46+ const enterButton = this . page . getByRole ( 'button' , { name : 'Enter' } ) ;
47+ await expect ( enterButton ) . toBeVisible ( { timeout : 30000 } ) ;
48+ await enterButton . click ( ) ;
49+ await expect (
50+ this . page . getByRole ( 'link' , { name : 'Home' } ) . first ( ) ,
51+ ) . toBeVisible ( {
52+ timeout : 30000 ,
53+ } ) ;
54+ await this . switchToLocale ( locale ) ;
55+ } finally {
56+ // Clean up the event listener to prevent memory leaks
57+ this . page . off ( 'dialog' , dialogHandler ) ;
58+ }
5259 }
5360
5461 async openCatalog ( ) {
You can’t perform that action at this time.
0 commit comments