Skip to content

test: add Trezor emulator tests#564

Open
ovitrif wants to merge 4 commits into
ovi/trezor-bridge-transportfrom
ovi/trezor-ai-device-tests
Open

test: add Trezor emulator tests#564
ovitrif wants to merge 4 commits into
ovi/trezor-bridge-transportfrom
ovi/trezor-ai-device-tests

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented May 21, 2026

Description

Note

AI Dev Tests
This class of tests are intended to aid in development using AI agents, they should stay free of requirements to run them during QA gating. There shouldn't be any constraint wrt. time it takes to run these tests if ran together. Personally, I would be in favour of them covering all possible user-facing functionalities of the app in time.

This PR:

  1. Adds an AI-only Trezor emulator UI-test suite for the dev settings dashboard.
  2. Adds stable accessibility identifiers and a guarded TEST_TREZOR_EMU=1 dashboard launch path for device automation.
  3. Adds a manual ai-device-tests workflow that runs only on workflow_dispatch against bitkit-docker main.
  4. Documents the local command for running the emulator-backed suite.

The test workflow uses a dedicated BitkitAITests scheme so the AI/device lane builds the app and UI-test bundle without pulling unrelated unit-test targets into the run.

Context: current iOS releases do not expose WebUSB-style access for devices like Trezor in Safari/WebKit, and Trezor's current connected-device path on iOS is Bluetooth for models that support it. The emulator suite keeps using Bridge because that is the transport currently exposed by Trezor User Env; if User Env later exposes a BLE peripheral compatible with CoreBluetooth, this suite should move to that transport while preserving the same dashboard coverage.

Verification Status

The Trezor emulator UI suite has been run successfully locally against the bitkit-docker compose stack, using the compose-owned Trezor User Env service and local Regtest Electrum. The full BitkitUITests/TrezorBridgeDashboardUITests class passed with 3 passed, 0 failed, 0 skipped in TestResults/TrezorBridgeDashboardUITests-full1.xcresult.

After the run, Bridge enumeration returned the emulator with session: null, confirming the test teardown released the Bridge session.

Linked Issues/Tasks

Screenshot / Video

N/A

QA Notes

Manual Tests

  • 1. bitkit-docker main → docker compose up -d./scripts/trezor-emulator start → run the documented local xcodebuild test command: Trezor dashboard emulator scenarios pass on Regtest.
  • 2. regression: normal app launch without TEST_TREZOR_EMU=1: the app follows the existing splash/onboarding/wallet routing and does not deep-link into the Trezor dashboard.

Automated Checks

  • git diff --check
  • swiftformat on touched Swift files
  • Build-for-testing verifies the dedicated AI test scheme compiles the app and UI-test bundle:
    xcodebuild build-for-testing \
      -workspace Bitkit.xcodeproj/project.xcworkspace \
      -scheme BitkitAITests \
      -configuration Debug \
      -destination 'platform=iOS Simulator,id=90203221-2CC7-46AA-8370-759E31ED06FC' \
      SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG E2E_BUILD' \
      -only-testing:BitkitUITests/TrezorBridgeDashboardUITests \
      -parallel-testing-enabled NO
  • Default skip behavior verifies the suite does not run without the emulator opt-in:
    xcodebuild test \
      -workspace Bitkit.xcodeproj/project.xcworkspace \
      -scheme BitkitAITests \
      -configuration Debug \
      -destination 'platform=iOS Simulator,id=90203221-2CC7-46AA-8370-759E31ED06FC' \
      SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG E2E_BUILD' \
      -only-testing:BitkitUITests/TrezorBridgeDashboardUITests \
      -parallel-testing-enabled NO
    Result: confirmed the suite skips by default when TEST_TREZOR_EMU=1 is absent.
  • Full emulator-backed dashboard suite against the bitkit-docker Trezor service and local Regtest Electrum:
    TREZOR_BRIDGE=true \
    TREZOR_BRIDGE_URL=http://127.0.0.1:21325 \
    TREZOR_ELECTRUM_URL=tcp://127.0.0.1:60001 \
    E2E=true \
    E2E_BACKEND=local \
    E2E_NETWORK=regtest \
    GEO=false \
    xcodebuild test \
      -workspace Bitkit.xcodeproj/project.xcworkspace \
      -scheme BitkitAITests \
      -configuration Debug \
      -destination 'platform=iOS Simulator,id=90203221-2CC7-46AA-8370-759E31ED06FC' \
      -resultBundlePath TestResults/TrezorBridgeDashboardUITests-full1.xcresult \
      SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG E2E_BUILD TEST_TREZOR_EMU' \
      -only-testing:BitkitUITests/TrezorBridgeDashboardUITests \
      -parallel-testing-enabled NO
    Result: passed locally with 3 passed, 0 failed, 0 skipped.
  • curl -fsS -X POST http://127.0.0.1:21325/enumerate after the suite showed the emulator with session: null, confirming teardown released the Bridge session.
  • ai-device-tests.yml workflow visibility and behavior must be verified (after merge) from the Actions tab because new workflow files are only dispatchable once present on the default branch.

@ovitrif ovitrif self-assigned this May 21, 2026
@ovitrif ovitrif marked this pull request as ready for review May 21, 2026 23:54
@ovitrif ovitrif mentioned this pull request May 21, 2026
3 tasks
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e3c9a13cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread BitkitUITests/TrezorBridgeDashboardUITests.swift Outdated
@ovitrif ovitrif added this to the 2.4.0 milestone May 22, 2026
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.

1 participant