Skip to content

Commit 8e8d86f

Browse files
authored
test: structure ramps mocks (#26635)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** The purpose of this PR is to clean up and restructure the mock responses for ramps ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Test-only change, but it rewires the on-ramp E2E mocking layer and alters mocked quote/checkout/order-polling behavior, so it could cause widespread test flakiness or failures if any endpoints/patterns don’t match real calls. > > **Overview** > Refactors the ramps/on-ramp E2E mocks into **modular, region-aware helpers** and splits the previously monolithic `ramps-mocks.ts` data into dedicated `ramps/responses/*` fixtures. > > The new `setupRegionAwareOnRampMocks` now composes mocks for geolocation/eligibility, catalog endpoints, quote polling, checkout (buy + callback), token icon assets, and a **stateful order-status** endpoint that transitions `PENDING` → `COMPLETED` during polling. > > Updates default mocks and multiple ramps smoke/regression specs (and cardholder mocks) to import the new response modules and to use `setupRegionAwareOnRampMocks` from `ramps-mocks`, while removing the old `ramps-region-aware-mock-setup.ts` and the oversized quotes fixture in favor of a **single-quote** response. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 160bb1f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent ed2fb6c commit 8e8d86f

22 files changed

Lines changed: 1161 additions & 3154 deletions

tests/api-mocking/mock-responses/cardholder-mocks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { TestSpecificMock } from '../../framework/types.ts';
22
import { DEFAULT_FIXTURE_ACCOUNT } from '../../framework/fixtures/FixtureBuilder.ts';
33
import { setupMockRequest } from '../helpers/mockHelpers.ts';
4-
import { createGeolocationResponse } from './ramps/ramps-geolocation.ts';
5-
import { RAMPS_NETWORKS_RESPONSE } from './ramps/ramps-mocks.ts';
4+
import { createGeolocationResponse } from './ramps/responses/ramps-geolocation.ts';
5+
import { RAMPS_NETWORKS_RESPONSE } from './ramps/responses/ramps-networks-response.ts';
66
import { RampsRegions, RampsRegionsEnum } from '../../framework/Constants.ts';
77
import { ethers } from 'ethers';
88

tests/api-mocking/mock-responses/defaults/onramp-apis.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ import {
33
RampsRegions,
44
RampsRegionsEnum,
55
} from '../../../framework/Constants.ts';
6-
import {
7-
RAMPS_NETWORKS_RESPONSE,
8-
RAMPS_TOP_TOKENS_RESPONSE,
9-
RAMPS_PROVIDERS_RESPONSE,
10-
RAMPS_PAYMENTS_V2_RESPONSE,
11-
} from '../ramps/ramps-mocks.ts';
12-
import { createGeolocationResponse } from '../ramps/ramps-geolocation.ts';
6+
import { RAMPS_NETWORKS_RESPONSE } from '../ramps/responses/ramps-networks-response.ts';
7+
import { RAMPS_TOP_TOKENS_RESPONSE } from '../ramps/responses/ramps-tokens-response.ts';
8+
import { RAMPS_PROVIDERS_RESPONSE } from '../ramps/responses/ramps-providers-response.ts';
9+
import { RAMPS_PAYMENTS_V2_RESPONSE } from '../ramps/responses/ramps-payments-response.ts';
10+
import { createGeolocationResponse } from '../ramps/responses/ramps-geolocation.ts';
1311

1412
/**
1513
* Mock data for on-ramp API endpoints used in E2E testing.

0 commit comments

Comments
 (0)