@@ -56,33 +56,32 @@ export class DashboardPage {
5656 await this . dashboardTitle . waitFor ( { state : 'visible' , timeout : 60000 } ) ;
5757 await this . ensureMenuVisible ( ) ;
5858
59- // Ensure the PIM menu is attached and visible with longer timeouts for mobile
6059 await this . pimMenu . waitFor ( { state : 'attached' , timeout : 20000 } ) ;
6160 await this . pimMenu . scrollIntoViewIfNeeded ( ) ;
6261
63- // Try up to 3 times in case of menu animation delays (especially in mobile)
6462 for ( let attempt = 0 ; attempt < 3 ; attempt ++ ) {
6563 try {
6664 await this . pimMenu . waitFor ( { state : 'visible' , timeout : 20000 } ) ;
67- await Promise . all ( [
68- this . page . waitForURL ( / .* p i m / , { timeout : 60000 } ) ,
69- this . pimMenu . click ( { force : true } ) ,
70- ] ) ;
71- // Confirm heading appears
65+ // Add explicit visibility check before clicking
66+ if ( ! ( await this . pimMenu . isVisible ( ) ) ) {
67+ throw new Error ( 'PIM menu not visible after wait' ) ;
68+ }
69+ await this . pimMenu . click ( { force : true } ) ;
70+ // Increase timeout to match test timeout
71+ await this . page . waitForURL ( / .* p i m / , { timeout : 90000 } ) ;
7272 await this . page . getByRole ( 'heading' , { name : 'PIM' } ) . waitFor ( { state : 'visible' , timeout : 60000 } ) ;
7373 return ;
7474 } catch ( e ) {
75- // If click fails, try to open hamburger menu again and retry
76- await this . ensureMenuVisible ( ) ;
77- // Check if page is still active before waiting
78- if ( this . page . isClosed && this . page . isClosed ( ) ) {
79- throw new Error ( 'Browser/page was closed unexpectedly during PIM navigation' ) ;
75+ if ( this . page . isClosed ( ) ) {
76+ throw new Error ( `Browser/page was closed unexpectedly during PIM navigation. Original error: ${ e . message } ` ) ;
8077 }
81- // Small wait before retrying
82- await this . page . waitForTimeout ( 1000 ) ;
78+ if ( attempt === 2 ) {
79+ throw new Error ( `Could not navigate to PIM menu after 3 attempts. Last error: ${ e . message } ` ) ;
80+ }
81+ await this . ensureMenuVisible ( ) ;
82+ await this . page . waitForTimeout ( 3000 ) ; // Increased from 2000ms for better mobile stability
8383 }
8484 }
85- throw new Error ( 'Could not navigate to PIM menu in mobile view after several attempts' ) ;
8685 }
8786
8887 async navigateToLeave ( ) {
0 commit comments