test: improves mocks to allow plain text reponses#26625
Merged
Conversation
Contributor
|
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. |
amitabh94
previously approved these changes
Feb 26, 2026
a8c29d4 to
e070bcf
Compare
cortisiko
previously approved these changes
Feb 26, 2026
… toas has disappeared before tapping confirm on transaction
…ls from happening
Contributor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found All E2E tests pre-selected. |
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
cortisiko
approved these changes
Feb 27, 2026
gambinish
approved these changes
Feb 27, 2026
amitabh94
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses a gigantic mocking error on default mocks, specifically speaking the onramp geolocation. This issue was causing random flakiness due to a bad formatted url coming from a mock.
Example:
https://on-ramp-cache.uat-api.cx.metamask.io/regions/%7B%22id%22:%22/regions/us-ca%22,%22name%22:%22california%22,%22emoji%22:%22%F0%9F%87%BA%F0%9F%87%B8%22,%22detected%22:true%7D/tokens?action=deposit&sdk=2.1.5(see run reference)The reason for this is that the request for
https://on-ramp.<ENV>-api.cx.metamask.io/geolocationwas returningwhen in reality the geolocation endpoint returns plaintext containing the country code for the user's location. This PR adds the ability to the mock server to accept plain text instead of json as a response and fixes the mocking.
It then caused perps tests to fail due to region not available since the fallback country (US) is currently being blacklisted and this was the country used in the onramps default geolocation mock.
CI changes
refwas removed from the shard runner checkout as this was causing inconsistencies with the way every single workflow uses checkout. Builds do not contain a ref which results in building apps with a merge commit instead of the branch commit while tests would run with a different ref resulting in failed tests for changes that were already fixed on main.Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Moderate risk: changes test infrastructure by installing a lifecycle-wide
unhandledRejectionfilter and altering mock server shutdown behavior, which could mask unexpected promise rejections if the filter is too broad. Functional app code is untouched; impact is limited to E2E reliability and mocking fidelity.Overview
Fixes onramp geolocation mocking to return plain text region codes (matching the real API) and updates the mocking layer (
MockServerE2E,setupMockRequest) to return raw string bodies without JSON-serializing; adds a catch-all mock for legacy/regions/{region}/tokensto prevent live calls.Hardens E2E infra by adding
MockServerE2E.startDraining()(return 503 during cleanup) and installing a lifecycle-wide filter that suppresses mockttpError('Aborted')unhandled rejections, with cleanup integrated intowithFixtures.Stabilizes flaky Detox flows: waits for elements to stop moving before taps (wallet token rows, confirm button), relaxes a swap analytics assertion to min length, adjusts unified-buy analytics region assertions to expect a string, adds perps geolocation mocking (non-blocked region), and tweaks/simplifies a few smoke tests (mUSD sync timing, SOL send assertions).
Written by Cursor Bugbot for commit 27fc622. This will update automatically on new commits. Configure here.