Skip to content

Commit 1b391d9

Browse files
fix(tests): dispatch logout deep-link and fix browser lifecycle
Windows: - Extract returnTo deep-link from logout URL - Write deep-link to Windows Registry for Unity to process - Fixes app crash by ensuring logout callback is received macOS: - Kill existing Brave processes before launching with debugging port - Prevents 'cannot connect to chrome at localhost:9222' error - Ensures controlled logout can connect to browser Both platforms now properly dispatch immutablerunner://logout deep-link back to Unity after browser logout completes.
1 parent dc755d5 commit 1b391d9

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

sample/Tests/test/test_mac.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,12 @@ def logout(cls):
172172
print("Logging out...")
173173
cls.launch_browser()
174174
bring_sample_app_to_foreground()
175-
176-
# Click logout button
177175
cls.altdriver.find_object(By.NAME, "LogoutBtn").tap()
178176
print("Logout button clicked")
179-
180-
# Use controlled browser to handle logout
177+
time.sleep(5)
178+
bring_sample_app_to_foreground()
181179
logout_with_controlled_browser()
182-
183-
# Bring app back to foreground after browser processes logout
184-
time.sleep(2)
185180
bring_sample_app_to_foreground()
186-
187-
# Wait for unauthenticated scene
188181
cls.altdriver.wait_for_current_scene_to_be("UnauthenticatedScene")
189182
time.sleep(2)
190183
cls.stop_browser()

sample/Tests/test/test_windows.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,9 @@ def test_7_reconnect_connect_imx(self):
308308
# Use controlled browser logout instead of waiting for scene change
309309
logout_with_controlled_browser()
310310

311-
# Bring Unity app to foreground immediately so it can receive the logout callback
312-
bring_sample_app_to_foreground()
313-
314311
# Give Unity time to process the logout callback
315312
time.sleep(5)
313+
bring_sample_app_to_foreground()
316314

317315
# Wait for unauthenticated screen
318316
self.get_altdriver().wait_for_current_scene_to_be("UnauthenticatedScene")

sample/Tests/test/test_windows_helpers.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,35 @@ def logout_with_controlled_browser():
370370
print(f"Navigating controlled browser to logout URL: {logout_url}")
371371
driver.get(logout_url)
372372

373-
# Wait for logout to complete (protocol is already configured, no dialogs expected)
373+
# Wait for logout page to load
374374
time.sleep(3)
375375
print("Logout completed in controlled browser")
376376

377377
# Check final page
378378
current_url = driver.current_url
379379
print(f"Final logout URL: {current_url}")
380380

381+
# Extract and dispatch the returnTo deep-link
382+
import re
383+
if 'returnTo=' in logout_url:
384+
from urllib.parse import unquote
385+
match = re.search(r'returnTo=([^&]+)', logout_url)
386+
if match:
387+
return_to = unquote(match.group(1))
388+
print(f"Extracted returnTo deep-link: {return_to}")
389+
390+
# Capture the deep-link and write to registry (same as login flow)
391+
print(f"Writing deep-link to Windows Registry: {return_to}")
392+
try:
393+
import winreg
394+
# Write the deep-link URL to the registry key that Unity monitors
395+
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, r"Software\Immutable\UnityDeepLink") as key:
396+
winreg.SetValueEx(key, "deeplink", 0, winreg.REG_SZ, return_to)
397+
print("Deep-link written to registry successfully")
398+
time.sleep(2) # Give Unity time to read from registry
399+
except Exception as reg_err:
400+
print(f"Warning: Could not write to registry: {reg_err}")
401+
381402
else:
382403
print("Could not find logout URL in Unity logs - logout may complete without browser interaction")
383404

0 commit comments

Comments
 (0)