test(e2e-mobile): add Borrow Detox E2E coverage (LIVE-35015) - #20367
test(e2e-mobile): add Borrow Detox E2E coverage (LIVE-35015)#20367alexstapenka-ledger wants to merge 4 commits into
Conversation
Add mobile cold start, open loan, repay, and withdraw flows with Speculos signing fixes needed for on-chain borrow scenarios.
Scope pnl and Speculos recycle to borrow-only, improve on-chain failure messages, and clear stale DEVICE_PROXY_URL after deregister.
Make afterAll loan cleanup best-effort, align repay setup with desktop, and add explicit Jest timeouts for the cold-start describe.
Web Tools Build Status
|
ed6e533 to
d792307
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds Detox E2E coverage for the Borrow feature on mobile (cold start + on-chain open/repay/withdraw flows) and extends the mobile E2E Speculos/bridge utilities to better support DMK signing and Speculos reuse/recycling.
Changes:
- Add a new Borrow mobile Detox test suite with supporting page objects, constants, and portfolio entry helpers.
- Improve Speculos handling for on-chain signing (DMK session release, Speculos refresh/reuse, bridge env syncing).
- Add Borrow-specific feature-flag presets for consistent E2E configuration (including analytics consent disabled).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
e2e/mobile/utils/speculosUtils.ts |
Adds DMK session release + Speculos refresh/registration helpers and strengthens bridge env waiting logic. |
e2e/mobile/utils/initUtil.ts |
Adds optional Speculos recycling after CLI-on-app setup and ensures DMK sessions are released before app connection/signing. |
e2e/mobile/utils/featureFlagUtils.ts |
Introduces Borrow-focused and “no analytics consent” feature-flag presets for E2E. |
e2e/mobile/specs/borrow/borrow.ts |
Implements Borrow test runners for cold start, open-loan, repay, and withdraw flows. |
e2e/mobile/specs/borrow/borrow.spec.ts |
New Borrow spec entrypoint orchestrating the three Borrow describe blocks in-order. |
e2e/mobile/specs/borrow/borrow.constants.ts |
Centralizes Borrow timeouts and merges Borrow-specific feature flags. |
e2e/mobile/page/wallet/portfolio.page.ts |
Adds Portfolio page-object helpers for the Borrow entry point CTA. |
e2e/mobile/page/trade/borrow.page.ts |
Adds a full Borrow webview page object, including flaky-state recovery and signing orchestration. |
e2e/mobile/page/index.ts |
Wires the new Borrow page object into the global Application page registry. |
e2e/mobile/page/common.page.ts |
Improves known-device selection by falling back to the active Speculos address. |
e2e/mobile/helpers/commonHelpers.ts |
Adds ensureBridgeReady() to relaunch the app when the E2E bridge becomes unresponsive. |
.changeset/borrow-mobile-e2e-LIVE-35015.md |
Changeset documenting the added mobile Borrow E2E coverage. |
| export async function ensureBridgeReady(): Promise<void> { | ||
| const envs = await getEnvs(); | ||
| if (envs) return; | ||
|
|
||
| log.warn("E2E Bridge not responding — relaunching app to restore WebSocket"); | ||
| const port = await launchApp({ newInstance: true }); | ||
| await device.reverseTcpPort(port); | ||
|
|
||
| const envsAfterRelaunch = await getEnvs(); | ||
| if (!envsAfterRelaunch) { | ||
| throw new Error( | ||
| "E2E bridge not responding after app relaunch. Restart the emulator, stop stale Speculos containers, then retry.", | ||
| ); | ||
| } | ||
| } |
| import { Step } from "jest-allure2-reporter/api"; | ||
| import { Account } from "@ledgerhq/live-e2e-shared/enum/Account"; | ||
| import { isAndroid } from "../../helpers/commonHelpers"; | ||
| import { prepareSpeculosForSigning, refreshSpeculosForSigning } from "../../utils/speculosUtils"; |
Poll bridge envs after relaunch, drop redundant Speculos signing steps, and reuse WebElementHelpers for enabled checks to fix mobile E2E typecheck.
| if (recycleSpeculosAfterCliOnApp && mainApp?.name === app.name) { | ||
| // Desktop parity: liveData runs on a temporary Speculos, then a fresh instance is used for signing. | ||
| log.info(`[${app.name}] Recycling Speculos after CLI (desktop cleanSpeculos parity)`); | ||
| await releaseSpeculosDmkSessions(); | ||
| const reusePort = entryMap[app.name].speculosPort; | ||
| await removeSpeculosAndDeregisterKnownSpeculos(entryMap[app.name].deviceId); | ||
| const device = await launchSpeculos(app.name, reusePort); | ||
| entryMap[app.name] = { | ||
| name: app.name, | ||
| speculosPort: device.port, | ||
| deviceId: device.id, | ||
| }; | ||
| } else if (mainApp?.name !== app.name) { | ||
| await deleteSpeculos(entry.deviceId); | ||
| } |
Rsdoctor Bundle Diff AnalysisFound 7 projects in monorepo, 7 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 desktop-mainPath:
📁 desktop-preloaderPath:
📁 desktop-rendererPath:
📁 desktop-webviewDappPreloaderPath:
📁 desktop-webviewPreloaderPath:
📁 desktop-workersPath:
📁 mobilePath:
Generated by Rsdoctor GitHub Action |
|




✅ Checklist
npx changesetwas attached.📝 Description
Problem: Desktop Borrow E2E (cold start, open loan, repay, withdraw) was merged, but mobile had no equivalent Detox coverage for LIVE-35015 / TMS cases B2CQA-6062, B2CQA-6065, B2CQA-6073, B2CQA-6080.
Solution: Add a single mobile spec file (desktop parity) with shared runners, page object, and portfolio entry helpers. On-chain flows reuse @ledgerhq/live-e2e-shared/borrow/borrowSetup for chain state setup/teardown.
Key mobile-specific work:
Run locally:
❓ Context
🧐 Checklist for the PR Reviewers