From 367050f4351f76a18a71ca2c916eea77e73dc67a Mon Sep 17 00:00:00 2001 From: Christopher Ferreira Date: Wed, 4 Feb 2026 15:07:05 +0000 Subject: [PATCH 1/2] chore: adds call redirect from iab to mockServer --- .../Views/BrowserTab/BrowserTab.tsx | 20 +- app/core/EntryScriptProxyE2E.ts | 263 ++++++++++++++++++ tests/api-mocking/MockServerE2E.ts | 2 +- 3 files changed, 282 insertions(+), 3 deletions(-) create mode 100644 app/core/EntryScriptProxyE2E.ts diff --git a/app/components/Views/BrowserTab/BrowserTab.tsx b/app/components/Views/BrowserTab/BrowserTab.tsx index 81d8af2fa43b..604b1d4c1496 100644 --- a/app/components/Views/BrowserTab/BrowserTab.tsx +++ b/app/components/Views/BrowserTab/BrowserTab.tsx @@ -77,7 +77,8 @@ import { useMetrics } from '../../../components/hooks/useMetrics'; import { trackDappViewedEvent } from '../../../util/metrics'; import trackErrorAsAnalytics from '../../../util/metrics/TrackError/trackErrorAsAnalytics'; import { selectPermissionControllerState } from '../../../selectors/snaps/permissionController'; -import { isTest } from '../../../util/test/utils.js'; +import { isTest, isE2E } from '../../../util/test/utils.js'; +import EntryScriptProxyE2E from '../../../core/EntryScriptProxyE2E'; import { EXTERNAL_LINK_TYPE } from '../../../constants/browser'; import { useNavigation } from '@react-navigation/native'; import { useStyles } from '../../hooks/useStyles'; @@ -519,8 +520,14 @@ export const BrowserTab: React.FC = React.memo( const getEntryScriptWeb3 = async () => { const entryScriptWeb3Fetched = await EntryScriptWeb3.get(); + + // In E2E mode, inject the proxy script FIRST to intercept all fetch/XHR calls + // This must run before any page scripts to ensure all requests are proxied + const e2eProxyScript = isE2E ? EntryScriptProxyE2E.get() : ''; + setEntryScriptWeb3( - entryScriptWeb3Fetched + + e2eProxyScript + + entryScriptWeb3Fetched + SPA_urlChangeListener + SCROLL_TRACKER_SCRIPT, ); @@ -1554,6 +1561,15 @@ export const BrowserTab: React.FC = React.memo( onFileDownload={handleOnFileDownload} webviewDebuggingEnabled={isTest} paymentRequestEnabled + // E2E Testing: Enable native request interception on Android + // @ts-expect-error - Custom E2E props not in WebView types + e2eMode={isE2E} + // @ts-expect-error - Custom E2E props not in WebView types + mockServerUrl={ + isE2E + ? EntryScriptProxyE2E.getMockServerUrl() + : undefined + } /> {ipfsBannerVisible && ( Date: Wed, 4 Feb 2026 15:22:35 +0000 Subject: [PATCH 2/2] chore: linting --- app/components/Views/BrowserTab/BrowserTab.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/components/Views/BrowserTab/BrowserTab.tsx b/app/components/Views/BrowserTab/BrowserTab.tsx index 604b1d4c1496..9ea8ba551aca 100644 --- a/app/components/Views/BrowserTab/BrowserTab.tsx +++ b/app/components/Views/BrowserTab/BrowserTab.tsx @@ -1564,7 +1564,6 @@ export const BrowserTab: React.FC = React.memo( // E2E Testing: Enable native request interception on Android // @ts-expect-error - Custom E2E props not in WebView types e2eMode={isE2E} - // @ts-expect-error - Custom E2E props not in WebView types mockServerUrl={ isE2E ? EntryScriptProxyE2E.getMockServerUrl()