test(e2e): mock signature-insights to remove from allowlist (MMQA-1779)#29601
Conversation
Adds a default POST mock for the signature decoding API used by @metamask/signature-controller during SignTypedDataV3/V4 flows, then removes the three corresponding allowlist entries. - POST signature-insights.api.cx.metamask.io/v1/signature?chainId=0x... → returns the SDK's own UNSUPPORTED_SIGNATURE error shape, which the wallet handles by rendering the simulation "unavailable" placeholder Regex matcher covers any chainId, so adding new chains to default fixtures won't reintroduce live requests. Tier 3 of MMQA-1364, scoped to signature-insights only. NFT API entries are deferred to follow-up tickets. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #29601 +/- ##
==========================================
- Coverage 82.15% 81.92% -0.24%
==========================================
Files 5178 5184 +6
Lines 137450 137830 +380
Branches 31079 31193 +114
==========================================
- Hits 112924 112919 -5
- Misses 16875 17237 +362
- Partials 7651 7674 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Why SmokeConfirmations: The Risk is LOW because:
No performance tests needed: These are purely test infrastructure changes with no impact on app rendering, data loading, or runtime performance. Performance Test Selection: |
|



Description
Tier 3 of MMQA-1364 (allowlist reduction), scoped to the
signature-insightsendpoint only. NFT API entries (/users/.../tokens,/collections,/explore/sites, prod/dev/uat hosts) are deferred to follow-up tickets in the same tier.^https://signature-insights\.api\.cx\.metamask\.io/v1/signature\?chainId=0x[0-9a-fA-F]+${ stateChanges: null, error: { message: 'Unsupported signature.', type: 'UNSUPPORTED_SIGNATURE' } }Why this response shape. The SDK's own
decodeSignature(@metamask/signature-controller/utils/decoding-api) returns this exact shape (type: 'UNSUPPORTED_SIGNATURE') when the signature method is anything other thanSignTypedDataV3/V4. The wallet'sTypedSignV3V4Simulation(app/components/Views/confirmations/components/info/typed-sign-v3v4/simulation/simulation.tsx:18-22) checksdecodingData?.errorand falls through to either the permit fallback or the "simulation unavailable" placeholder inDecodedSimulation. Returning the same shape keeps the wallet on a known-graceful code path with no errors logged.Why regex, not exact URLs. Same rationale as Tier 2: covers any future chainId without re-introducing live requests when a new chain is added to default fixtures. Sanity-checked against the 3 chainIds in the previous allowlist (
0x1,0x539,0xaa36a7), plus mixed-case hex, plus rejection cases (non-hex, extra query params, different host).Spec audit. Grepped E2E specs that exercise SignTypedDataV3/V4:
tests/smoke/confirmations/signatures/signatures-typed.spec.ts— V3/V4 cases onchainId=0x539. Will trigger the mock. Assertions are on row components (AccountNetwork,Message,OriginInfo); no asserts on decoded simulation content. Safe.tests/smoke/confirmations/signatures/alert-system.spec.ts— V1 only on Sepolia (0xaa36a7). V1 doesn't call the API per SDK code. Unrelated.No spec asserts on
decodingData.stateChangesrendering, so the default mock is safe across the codebase.Files changed
tests/api-mocking/mock-responses/defaults/signature-insights.ts— newtests/api-mocking/mock-responses/defaults/index.ts— import + spread intoDEFAULT_MOCKS.POSTtests/api-mocking/mock-e2e-allowlist.ts— removed 3 entriesOut of scope
/users/tokens,/collections,/explore/sites, prod/dev/uat hosts) — deferred to separate Tier 3 ticketsChangelog
CHANGELOG entry: null
Related issues
MMQA-1779 — parent epic MMQA-1364
Manual testing steps
Screenshots/Recordings
Before
Every
eth_signTypedData_v3/_v4exercised by smoke specs fired a live POST tosignature-insights.api.cx.metamask.io. The 3 chainId-specific allowlist entries silencedvalidateLiveRequests(), but the call still reached the live decoding API and whatever it returned was rendered as decoded state changes in the wallet UI.After
mockttp intercepts the POST and returns the SDK's own
UNSUPPORTED_SIGNATUREerror shape. The wallet'sTypedSignV3V4SimulationchecksdecodingData?.errorand falls through to theconfirm.simulation.unavailableplaceholder inDecodedSimulation— the same path the wallet takes when the API errors live. Spec assertions on row components (origin, message, account/network) continue to pass.validateLiveRequests()records zero leaks forsignature-insights.Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Low risk: test-only changes that replace live
signature-insightsrequests with a deterministic mock and tighten the E2E allowlist.Overview
E2E tests no longer rely on live calls to
signature-insights.api.cx.metamask.io: the PR removes the chainId-specific allowlisted URLs and adds a default POST mock that matches any hexchainIdand returns anUNSUPPORTED_SIGNATUREerror shape.The new
SIGNATURE_INSIGHTS_MOCKSis wired intoDEFAULT_MOCKS.POST, reducing network leakage during signature-related smoke tests.Reviewed by Cursor Bugbot for commit 8335a5e. Bugbot is set up for automated code reviews on this repo. Configure here.