File tree Expand file tree Collapse file tree
frontend/tests/test-variant-console-enterprise Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,8 +21,33 @@ async function dismissErrorModalIfPresent(page: Page): Promise<void> {
2121 }
2222}
2323
24+ /**
25+ * Navigates to the login page and waits for the username input to be visible.
26+ * Retries with page reload if the form doesn't appear (backend may not be fully ready yet).
27+ */
28+ async function navigateToLoginPage ( page : Page ) : Promise < void > {
29+ // Navigate directly to /login to avoid redirect timing issues from /
30+ await page . goto ( '/login' , { waitUntil : 'domcontentloaded' } ) ;
31+
32+ // Wait for login form with reload retry (backend auth system may need a moment)
33+ const usernameInput = page . getByTestId ( 'auth-username-input' ) ;
34+ const maxAttempts = 5 ;
35+
36+ for ( let attempt = 1 ; attempt <= maxAttempts ; attempt ++ ) {
37+ const isVisible = await usernameInput . isVisible ( { timeout : 8000 } ) . catch ( ( ) => false ) ;
38+ if ( isVisible ) {
39+ return ;
40+ }
41+
42+ if ( attempt < maxAttempts ) {
43+ // Reload the page and try again — the backend auth system may still be initializing
44+ await page . reload ( { waitUntil : 'domcontentloaded' } ) ;
45+ }
46+ }
47+ }
48+
2449setup ( 'authenticate' , async ( { page } ) => {
25- await page . goto ( '/' , { waitUntil : 'networkidle' } ) ;
50+ await navigateToLoginPage ( page ) ;
2651
2752 // Wait for login form to be visible
2853 await page . getByTestId ( 'auth-username-input' ) . waitFor ( { state : 'visible' , timeout : 30_000 } ) ;
You can’t perform that action at this time.
0 commit comments