@@ -175,14 +175,11 @@ def settings(self):
175175
176176 @property
177177 def welcome_back (self ):
178- class SimpleWelcomeBack :
179- def is_welcome_back_screen_displayed (self , timeout = 10 ):
180- return False
181-
182- def perform_login (self , password ):
183- return False
178+ if not self ._welcome_back :
179+ from pages .onboarding import WelcomeBackPage
184180
185- return SimpleWelcomeBack ()
181+ self ._welcome_back = WelcomeBackPage (self .driver )
182+ return self ._welcome_back
186183
187184 @property
188185 def user_service (self ) -> UserProfileService :
@@ -267,8 +264,15 @@ def restart_app_and_login(self) -> bool:
267264 self .logger .error ("App restart failed" )
268265 return False
269266
270- # Wait for app to stabilize and present either home or auth
271- self .wait_for_app_post_restart ()
267+ try :
268+ manager = self ._app_initialization or AppInitializationManager (self .driver )
269+ if not self ._app_initialization :
270+ self ._app_initialization = manager
271+ manager .perform_initial_activation (timeout = 3 )
272+ except Exception as activation_err :
273+ self .logger .debug (
274+ "Post-restart activation attempt failed: %s" , activation_err
275+ )
272276
273277 # Detect new state and handle authentication
274278 self .app_state_manager .detect_current_state ()
@@ -289,14 +293,18 @@ def get_home(self, ensure: bool = True, auto_create: bool = True) -> HomePage:
289293
290294 if not self .app_state .is_home_loaded :
291295 # Try existing-user login if authentication is required
292- if self .app_state .requires_authentication :
296+ if self .app_state .requires_authentication and self . user_service . current_user :
293297 try :
294298 self .logger .info (
295299 "Auth required - attempting existing user login"
296300 )
297301 self .login_existing_user ()
298302 except Exception as e :
299303 self .logger .warning (f"Existing user login failed: { e } " )
304+ elif self .app_state .requires_authentication :
305+ self .logger .info (
306+ "Auth required but no known test user; skipping auto-login"
307+ )
300308
301309 # If still not loaded and allowed, create a user
302310 if not self .app_state .is_home_loaded and auto_create :
@@ -347,6 +355,7 @@ def cleanup(self):
347355 self ._user_service = None
348356 self ._app_state_manager = None
349357 self ._app_initialization = None
358+ self ._welcome_back = None
350359
351360 self .logger .info ("✅ TestContext cleanup completed" )
352361
@@ -418,26 +427,6 @@ def _handle_post_restart_authentication(self) -> bool:
418427
419428 return False
420429
421- def wait_for_app_post_restart (
422- self , timeout : Optional [int ] = None , poll_interval : float = 0.5
423- ) -> bool :
424- """Public helper to wait for app readiness after a restart using YAML defaults."""
425- effective_timeout = timeout
426- try :
427- if (
428- effective_timeout is None
429- and self ._session_manager
430- and self ._session_manager .env_config
431- ):
432- effective_timeout = self ._session_manager .env_config .timeouts .get (
433- "default" , 30
434- )
435- except Exception :
436- effective_timeout = effective_timeout or 30
437- return self ._wait_for_app_ready (
438- timeout = int (effective_timeout or 30 ), poll_interval = poll_interval
439- )
440-
441430 def _wait_for_app_ready (
442431 self , timeout : int = 30 , poll_interval : float = 0.5
443432 ) -> bool :
0 commit comments