Skip to content

Commit dc3b6ec

Browse files
committed
fix(tests): verify authentication via Unity logs not scene changes
Instead of waiting for AuthenticatedScene transition (which can fail if app crashes), monitor Unity logs for actual authentication success indicators like COMPLETE_LOGIN_PKCE and LoginPKCESuccess.
1 parent 2984fe0 commit dc3b6ec

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

sample/Tests/test/test_windows_helpers.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,33 @@ def login():
253253
print("The immutablerunner:// callback was triggered but browser couldn't handle it")
254254
print("This means authentication was successful, just need to wait for Unity to process it")
255255

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")
256+
# Wait and check Unity logs for authentication success instead of relying on scene changes
257+
auth_success = False
258+
for check_attempt in range(20): # Check for 20 seconds
259+
try:
260+
with open("C:\\Users\\WindowsBuildsdkServi\\AppData\\LocalLow\\Immutable\\Immutable Sample\\Player.log", 'r', encoding='utf-8', errors='ignore') as f:
261+
content = f.read()
262+
# Look for signs of successful authentication in logs
263+
if any(phrase in content for phrase in [
264+
"AuthenticatedScene",
265+
"COMPLETE_LOGIN_PKCE",
266+
"LoginPKCESuccess",
267+
"HandleLoginPkceSuccess",
268+
"authentication successful",
269+
"logged in successfully"
270+
]):
271+
print("Authentication success detected in Unity logs!")
272+
auth_success = True
273+
break
274+
except:
275+
pass
276+
time.sleep(1)
277+
278+
if auth_success:
279+
print("Cached authentication confirmed successful via Unity logs")
280+
else:
281+
print("Could not confirm authentication success in Unity logs")
282+
259283
return
260284
else:
261285
print("Unexpected page state - handling as cached session...")

0 commit comments

Comments
 (0)