Skip to content

Commit 6a4e655

Browse files
authored
fix: Windows UI test automation (#550)
* feat(tests): implement reliable CI authentication automation - Add browser process isolation workaround for Unity Passport authentication - Configure protocol associations and browser permissions programmatically - Handle both full login flows and cached session scenarios - Fix MailSlurp API URL configuration for OTP retrieval - Implement controlled logout process to prevent app crashes - Increase AltDriver timeouts for CI stability * fix(ci): prevent parallel UI tests from competing for same email inbox - Change concurrency group from per-platform to shared 'ui-tests-email-inbox' - Ensures macOS and Windows tests run sequentially to avoid MailSlurp race conditions - Prevents OTP emails being consumed by wrong test when tests run in parallel * revert: remove unrelated gitignore and package changes from CI test PR * ci: prevent unnecessary test cancellations in UI workflow - Add cancel-in-progress: false to ui-tests-email-inbox concurrency group - Allows queued tests to complete rather than being canceled by new runs - Improves CI resource utilization and debugging experience - Maintains existing protection against MailSlurp OTP race conditions * fix: implement smart login with state-aware authentication flow * ci: skipping imx transfer tests * ci: skip imx tests for mac * ci: debug login button * test: force clean Unity state on test startup * chore: uncomment imx transfer tests * ci: switch to passport logger * docs: add ui logging requirements
1 parent a91a6d0 commit 6a4e655

File tree

7 files changed

+893
-104
lines changed

7 files changed

+893
-104
lines changed

.github/workflows/ui-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ jobs:
9191
# runs-on: [ self-hosted, macOS ]
9292
# test_script: browserstack-sdk pytest -s ./test/test_android.py --browserstack.config "browserstack.android.yml"
9393
concurrency:
94-
group: test-${{ matrix.targetPlatform }}
94+
group: ui-tests-email-inbox
95+
cancel-in-progress: false # Let tests complete rather than canceling
9596
runs-on: ${{ matrix.runs-on }}
9697
steps:
9798
- uses: actions/checkout@v3
@@ -146,7 +147,7 @@ jobs:
146147
security list-keychains
147148
build-ios: #test-ios:
148149
name: Run iOS build #UI tests 🧪
149-
needs:
150+
needs:
150151
- build
151152
- test
152153
runs-on: [ self-hosted, macOS ]
@@ -170,4 +171,3 @@ jobs:
170171
# BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
171172
# working-directory: sample/Tests/test/ios
172173
# run: browserstack-sdk pytest -xs ./test_ios.py --browserstack.config "browserstack.ios.yml"
173-

sample/Tests/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# UI Tests
2+
3+
## Prerequisites
4+
5+
### Passport SDK Log Level Configuration
6+
7+
For the authentication flow tests to work properly, the Passport SDK must be configured with an appropriate log level that enables auth URL capture. The test automation relies on capturing authentication URLs from Unity's Player.log.
8+
9+
**Required Configuration:**
10+
11+
In your Unity project's Passport initialisation script, ensure the log level is set to `Info` or `Debug`:
12+
13+
**File:** `src/Packages/Passport/Runtime/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs`
14+
15+
```csharp
16+
// Set the log level for the SDK (required for test automation)
17+
Passport.LogLevel = LogLevel.Info; // or LogLevel.Debug
18+
```
19+
20+
**Why This Is Required:**
21+
22+
- The test framework captures authentication URLs from Unity logs using `PassportLogger.Info()` calls
23+
- Without proper logging, authentication URL interception will fail
24+
- This enables the workaround for browser process isolation issues in automated testing environments
25+
26+
**Log Patterns Captured:**
27+
28+
The tests monitor Unity's `Player.log` for these patterns:
29+
30+
- `[Immutable] PASSPORT_AUTH_URL: <url>`
31+
- `[Immutable] [Browser Communications Manager] LaunchAuthURL : <url>`
32+
33+
If authentication tests fail to capture URLs, verify that:
34+
35+
1. The Passport SDK log level is set correctly
36+
2. Unity's Player.log is being written to the expected location
37+
3. The authentication flow is actually being triggered

sample/Tests/src/fetch_otp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
def get_mailslurp_client():
1010
configuration = mailslurp_client.Configuration()
1111
configuration.api_key['x-api-key'] = os.getenv('MAILSLURP_API_KEY')
12+
# Use the correct API base URL as per official docs
13+
configuration.host = "https://api.mailslurp.com"
1214
api_client = mailslurp_client.ApiClient(configuration)
1315
waitfor_controller = WaitForControllerApi(api_client)
1416
return waitfor_controller
@@ -23,7 +25,7 @@ def extract_otp_from_email(email_body):
2325

2426
def fetch_code():
2527
waitfor_controller = get_mailslurp_client()
26-
email = waitfor_controller.wait_for_latest_email(inbox_id=INBOX_ID, timeout=30000, unread_only=True)
28+
email = waitfor_controller.wait_for_latest_email(inbox_id=INBOX_ID, timeout=60000, unread_only=True)
2729
if email:
2830
otp = extract_otp_from_email(email.body)
2931
return otp

0 commit comments

Comments
 (0)