Skip to content

Commit 0f10c44

Browse files
committed
fix(tests): handle cached session redirect to new tab
When cached Auth0 session exists, browser redirects immediately to immutablerunner:// callback but can't handle it, resulting in chrome://newtab/. Added detection for this successful scenario.
1 parent 3e7f996 commit 0f10c44

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

sample/Tests/test/test_windows_helpers.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def login():
236236
driver.get(auth_url)
237237

238238
# Debug: Check what page we landed on
239-
time.sleep(3) # Let page load
239+
time.sleep(5) # Give more time for potential redirects
240240
print(f"After navigation - URL: {driver.current_url}")
241241
print(f"After navigation - Title: {driver.title}")
242242

@@ -245,8 +245,21 @@ def login():
245245
email_field = driver.find_element(By.CSS_SELECTOR, '[data-testid="TextInput__input"]')
246246
print("Found email field via Unity log method - proceeding with login flow")
247247
except:
248-
print("No email field found - likely cached session, handling deep link...")
249-
return handle_cached_authentication(driver)
248+
print("No email field found - checking if we got redirected to new tab...")
249+
250+
# If we ended up on chrome://newtab/ or similar, the redirect already happened
251+
if 'newtab' in driver.current_url or 'about:blank' in driver.current_url:
252+
print("Browser was redirected to new tab - cached session completed redirect automatically!")
253+
print("The immutablerunner:// callback was triggered but browser couldn't handle it")
254+
print("This means authentication was successful, just need to wait for Unity to process it")
255+
256+
# Give Unity time to process the deep link callback that already happened
257+
time.sleep(10)
258+
print("Cached authentication should be complete - Unity should have received the callback")
259+
return
260+
else:
261+
print("Unexpected page state - handling as cached session...")
262+
return handle_cached_authentication(driver)
250263
else:
251264
print("Could not find auth URL in Unity logs either!")
252265
driver.quit()

0 commit comments

Comments
 (0)