@@ -56,38 +56,19 @@ 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
60- await this . pimMenu . waitFor ( { state : 'attached' , timeout : 20000 } ) ;
61- await this . pimMenu . scrollIntoViewIfNeeded ( ) ;
62-
63- // Try up to 3 times in case of menu animation delays (especially in mobile)
64- for ( let attempt = 0 ; attempt < 3 ; attempt ++ ) {
65- try {
66- await this . pimMenu . waitFor ( { state : 'visible' , timeout : 20000 } ) ;
67- // Explicit visibility check before clicking
68- if ( ! ( await this . pimMenu . isVisible ( ) ) ) {
69- throw new Error ( 'PIM menu not visible before click attempt' ) ;
70- }
71- // Click without force to ensure stable interaction
72- await this . pimMenu . click ( ) ;
73- // Wait for either URL change OR heading visibility (whichever comes first)
74- await Promise . race ( [
75- this . page . waitForURL ( / .* p i m / , { timeout : 90000 } ) ,
76- this . page . getByRole ( 'heading' , { name : 'PIM' } ) . waitFor ( { state : 'visible' , timeout : 90000 } )
77- ] ) ;
78- return ;
79- } catch ( e ) {
80- // If click fails, try to open hamburger menu again and retry
81- await this . ensureMenuVisible ( ) ;
82- // Check if page is still active before waiting
83- if ( this . page . isClosed && this . page . isClosed ( ) ) {
84- throw new Error ( 'Browser/page was closed unexpectedly during PIM navigation' ) ;
85- }
86- // Small wait before retrying
87- await this . page . waitForTimeout ( 1000 ) ;
88- }
59+ try {
60+ await this . pimMenu . scrollIntoViewIfNeeded ( ) ;
61+ await this . pimMenu . waitFor ( { state : 'visible' , timeout : 15000 } ) ;
62+ await this . pimMenu . click ( ) ;
63+ await this . page . waitForURL ( / .* p i m / , { timeout : 30000 } ) ;
64+ } catch ( e ) {
65+ // Fallback: navigate directly via URL if menu click fails
66+ await this . page . goto ( '/web/index.php/pim/viewEmployeeList' ) ;
67+ await this . page . waitForURL ( / .* p i m / , { timeout : 30000 } ) ;
8968 }
90- throw new Error ( 'Could not navigate to PIM menu in mobile view after several attempts' ) ;
69+
70+ // Verify PIM page loaded
71+ await this . page . getByRole ( 'heading' , { name : 'PIM' } ) . waitFor ( { state : 'visible' , timeout : 30000 } ) ;
9172 }
9273
9374 async navigateToLeave ( ) {
0 commit comments