Skip to content

Add android e2e setup + simulator run iOS e2e#546

Open
dewabisma wants to merge 14 commits into
mainfrom
beast/add-android-e2e-setup
Open

Add android e2e setup + simulator run iOS e2e#546
dewabisma wants to merge 14 commits into
mainfrom
beast/add-android-e2e-setup

Conversation

@dewabisma

@dewabisma dewabisma commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Added android emu and ios simu e2e test scripts.

The commit history shown here is buggy because I extend from other PR that already merged to main then I pull main to this branch. But the files changed should be correct. We can ignore and it will resolve it properly. Like how sometimes we have it before.


Note

Low Risk
Changes are limited to test automation (Gradle test runner settings, androidTest stub, and dev scripts); production app behavior is unaffected aside from standard instrumentation test dependencies.

Overview
Adds Patrol-native Android E2E wiring so patrol_test/ Dart tests run as instrumentation tests: PatrolJUnitRunner, clearPackageData between runs, AndroidX Test Orchestrator, and a parameterized MainActivityTest that lists and runs each Dart test.

Introduces patrol_android_emulator.sh and patrol_ios_simulator.sh for local runs—auto-pick or boot an emulator/simulator, optional single-file or full-suite targets, debug/release builds, and test secrets via .env.test or TEST_IMPORT_MNEMONIC (--dart-define, not bundled assets). Both invoke patrol test in one step (unlike the existing physical-iOS device script).

Reviewed by Cursor Bugbot for commit 7c38e21. Configure here.

@dewabisma dewabisma requested a review from n13 July 1, 2026 05:05

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7c38e21. Configure here.

xcrun simctl list devices available 2>/dev/null \
| grep -F " $name (" \
| tail -1 \
| sed -E 's/^[[:space:]]+[^(]+ \(([A-F0-9-]+)\).*/\1/'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong simulator runtime selected

Medium Severity

When several runtimes define the same simulator name, simulator_udid_for_name uses tail -1 on matching lines, which picks the last runtime block in simctl output. That usually maps to an older iOS runtime, not the newest one the comment describes, so -s can boot the wrong UDID and E2E runs on an unintended OS version.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7c38e21. Configure here.

exit 1
fi
start_emulator "$AVD_NAME"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reused emulator skips boot wait

Medium Severity

If a running emulator is auto-selected or chosen with -d, the script never calls wait_for_emulator_boot, unlike the path that starts a new AVD. Patrol can start while sys.boot_completed is still unset, leading to flaky or failed instrumentation runs.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7c38e21. Configure here.

@n13 n13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Solid, well-documented E2E addition. The Android native Patrol wiring is correct (PatrolJUnitRunner + clearPackageData + AndroidX Orchestrator + parameterized MainActivityTest), package placement matches applicationId/patrol android.package_name (com.quantus.wallet), MainActivity import from the namespace package is right, .env.test is already gitignored, and the empty-array expansions correctly guard set -u on macOS Bash 3.2.

Requesting changes for two confirmed correctness bugs + a DRY concern before merge.

Correctness (agree with Bugbot)

  1. Android reused emulator skips boot wait (patrol_android_emulator.sh). wait_for_emulator_boot only runs when a fresh AVD is booted. When an emulator is auto-selected or passed with -d, it's skipped. adb devices reports device before sys.boot_completed=1, so Patrol can start against a not-fully-booted emulator → flaky runs. Fix (also a DRY win): call wait_for_emulator_boot "$DEVICE_SERIAL" once after the serial is resolved, on every path.

  2. iOS wrong runtime selected (patrol_ios_simulator.sh). simulator_udid_for_name uses tail -1, but the comment claims "prefer the newest runtime" — simctl list devices section ordering isn't guaranteed, so -s can boot the wrong OS version (same non-determinism in default_simulator_name). More robust: parse xcrun simctl list devices available -j and pick the highest runtime version.

DRY (repo rule)

The three patrol scripts now triplicate large verbatim blocks: the .env.test/TEST_IMPORT_MNEMONICDART_DEFINES block (~16 lines), the TARGET_ARGS builder, SCRIPT_DIR/APP_ROOT resolution, and the common arg-parse loop. Recommend extracting scripts/lib/patrol_common.sh (e.g. patrol_resolve_app_root, patrol_collect_dart_defines, patrol_build_target_args) sourced by all three scripts.

Minor nits

  • Stale comment in MainActivityTest.java: "...run/filtered individually by xcodebuild's Android equivalent (the orchestrator)" — "xcodebuild" is an iOS copy-paste leftover.
  • patrol_ios_simulator.sh passes PATROL_DEVICE="${DEVICE_LABEL:-$DEVICE_ID}", preferring the possibly-ambiguous name over the already-resolved UDID; passing $DEVICE_ID is unambiguous when duplicate names exist.

Verdict: Request changes — prioritize the Android boot-wait fix and the DRY extraction; the iOS runtime selection and nits are quick follow-ups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants