Skip to content

test(e2e-mobile): add Borrow Detox E2E coverage (LIVE-35015) - #20367

Open
alexstapenka-ledger wants to merge 4 commits into
developfrom
support/LIVE-35015-borrow-mobile-e2e
Open

test(e2e-mobile): add Borrow Detox E2E coverage (LIVE-35015)#20367
alexstapenka-ledger wants to merge 4 commits into
developfrom
support/LIVE-35015-borrow-mobile-e2e

Conversation

@alexstapenka-ledger

@alexstapenka-ledger alexstapenka-ledger commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • Mobile Borrow Detox E2E only (e2e/mobile/specs/borrow/) — no production app UI changes
    • Speculos/DMK signing infra used by on-chain mobile E2E (initUtil, speculosUtils) — borrow opts into Speculos recycle via recycleSpeculosAfterCliOnApp
    • On-chain scenarios require DISABLE_TRANSACTION_BROADCAST=0, mainnet ETH_4, and Borrow staging API availability

📝 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:

  • Borrow webview stays mounted when navigating away — recovery via portfolio deeplink, hot-start intro dismiss, and stale-state loops in borrow.page.ts
  • Speculos signing parity with swap/borrow desktop (refreshSpeculosForSigning, DMK session release, opt-in CLI Speculos recycle)
  • Best-effort afterAll loan cleanup so staging Borrow API flakes (403/timeout) do not fail a green suite
  • Borrow-only feature flags (pnl, analytics consent off) scoped to BORROW_FEATURE_FLAGS

Run locally:

cd e2e/mobile
export MOCK=0 DISABLE_TRANSACTION_BROADCAST=0 SPECULOS_DEVICE=nanoX
pnpm test:android specs/borrow/

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

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.
Copilot AI review requested due to automatic review settings August 3, 2026 21:50
@alexstapenka-ledger
alexstapenka-ledger marked this pull request as ready for review August 3, 2026 21:50
@alexstapenka-ledger
alexstapenka-ledger requested a review from a team as a code owner August 3, 2026 21:50
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Web Tools Build Status

Build Status Deployment
Web Tools Build ⏭️ Skipped
Native Storybook Build ⏭️ Skipped
React Storybook Build ⏭️ Skipped

@alexstapenka-ledger
alexstapenka-ledger force-pushed the support/LIVE-35015-borrow-mobile-e2e branch from ed6e533 to d792307 Compare August 3, 2026 21:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +98 to +112
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.",
);
}
}
Comment thread e2e/mobile/utils/speculosUtils.ts
Comment thread e2e/mobile/page/trade/borrow.page.ts
Copilot AI review requested due to automatic review settings August 3, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread e2e/mobile/page/trade/borrow.page.ts Outdated
Comment on lines +1 to +4
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.
Copilot AI review requested due to automatic review settings August 3, 2026 22:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment on lines +193 to 207
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);
}
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 7 projects in monorepo, 7 projects with changes.

📊 Quick Summary
Project Total Size Change
desktop-main 2.3 MB -
desktop-preloader 7.1 KB -
desktop-renderer 80.7 MB -
desktop-webviewDappPreloader 36.9 KB -
desktop-webviewPreloader 0 B -
desktop-workers 36.8 KB -
mobile 261.6 MB -
📋 Detailed Reports (Click to expand)

📁 desktop-main

Path: rsdoctor/desktop-main/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.3 MB - -
📄 JavaScript 2.2 MB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 135.3 KB - -

📁 desktop-preloader

Path: rsdoctor/desktop-preloader/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 7.1 KB - -
📄 JavaScript 5.3 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 1.8 KB - -

📁 desktop-renderer

Path: rsdoctor/desktop-renderer/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 80.7 MB - -
📄 JavaScript 29.3 MB - -
🎨 CSS 183.2 KB - -
🌐 HTML 1.8 KB - -
📁 Other Assets 51.2 MB - -

📁 desktop-webviewDappPreloader

Path: rsdoctor/desktop-webviewDappPreloader/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 36.9 KB - -
📄 JavaScript 36.9 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 desktop-webviewPreloader

Path: rsdoctor/desktop-webviewPreloader/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 0 B - -
📄 JavaScript 0 B - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 desktop-workers

Path: rsdoctor/desktop-workers/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 36.8 KB - -
📄 JavaScript 36.8 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 mobile

Path: rsdoctor/mobile/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 261.6 MB - -
📄 JavaScript 110.5 MB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 151.1 MB - -

Generated by Rsdoctor GitHub Action

@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3 New Code Smells (required ≤ 1)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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