Skip to content

Commit 0f50eef

Browse files
test(ramps): replace offramp-cashout e2e with unit test for OFFRAMP_PAYMENT_METHOD_SELECTED (MetaMask#26531)
## **Description** Removes the `offramp-cashout.failing.ts` e2e test and closes the coverage gap with a new unit test as part of [MMQA-1492](https://consensyssoftware.atlassian.net/browse/MMQA-1492). The e2e test was fully skipped (`describe.skip`) and covered two behaviors on the Aggregator offramp `BuildQuote` screen: 1. **Payment method selection** — tapping the payment method dropdown and switching from "Debit or Credit" to "SEPA Bank Transfer" 2. **Analytics event tracking** — `OFFRAMP_PAYMENT_METHOD_SELECTED` event fires with correct properties (`payment_method_id`, `available_payment_method_ids`, `region`, `location`) **Existing coverage** in `PaymentMethodSelectorModal.test.tsx`: - `'tracks RAMPS_PAYMENT_METHOD_SELECTED event when payment method is selected'` — fires the event with all required properties (buy flow) - `'does not track RAMPS_PAYMENT_METHOD_SELECTED event when the same payment method is selected'` — guards against duplicate events - `'renders for sell flow'` — snapshot test with `isBuy: false` **Coverage gap identified:** The existing analytics test only exercised `isBuy: true`, so the `OFFRAMP_PAYMENT_METHOD_SELECTED` event name branch was never tested. The payload shape was already covered since it's identical for both flows. **Gap closed:** Added a new unit test case with `isBuy: false` that asserts `OFFRAMP_PAYMENT_METHOD_SELECTED` fires with the correct payload. The `isBuy` ternary branch is now fully covered. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/MMQA-1492 ## **Manual testing steps** ```gherkin Feature: Ramps offramp-cashout e2e removal with coverage gap closed Scenario: user verifies offramp analytics event coverage Given the metamask-mobile repository is checked out on the PR branch When user runs yarn test app/components/UI/Ramp/Aggregator/components/PaymentMethodSelectorModal/PaymentMethodSelectorModal.test.tsx Then all unit tests pass And the test "tracks OFFRAMP_PAYMENT_METHOD_SELECTED event when payment method is selected in sell flow" passes And the test "tracks ONRAMP_PAYMENT_METHOD_SELECTED event when payment method is selected in buy flow" passes And the test "does not track ONRAMP_PAYMENT_METHOD_SELECTED event when the same payment method is selected" passes ``` ## **Screenshots/Recordings** ### **Before** 5 tests in `PaymentMethodSelectorModal.test.tsx`: - `renders correctly` - `renders without disclaimer when selected payment method has none` - `renders for sell flow` - `tracks RAMPS_PAYMENT_METHOD_SELECTED event when payment method is selected` — misnamed, only tested buy flow - `does not track RAMPS_PAYMENT_METHOD_SELECTED event when the same payment method is selected` — misnamed The `isBuy: false` branch (`OFFRAMP_PAYMENT_METHOD_SELECTED`) was never exercised. Test names did not match the actual events being asserted. ### **After** 6 tests in `PaymentMethodSelectorModal.test.tsx`: - `renders correctly` - `renders without disclaimer when selected payment method has none` - `renders for sell flow` - `tracks OFFRAMP_PAYMENT_METHOD_SELECTED event when payment method is selected in sell flow` — **new**, covers `isBuy: false` with realistic `location: 'Amount to Sell Screen'` - `tracks ONRAMP_PAYMENT_METHOD_SELECTED event when payment method is selected in buy flow` — **renamed** to match actual assertion - `does not track ONRAMP_PAYMENT_METHOD_SELECTED event when the same payment method is selected` — **renamed** to match actual assertion ## **Pre-merge author checklist** - [x] 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). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. [MMQA-1492]: https://consensyssoftware.atlassian.net/browse/MMQA-1492?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only changes: adds/renames unit tests for onramp/offramp analytics and removes a fully skipped smoke e2e, with no production logic changes. > > **Overview** > Adds unit test coverage in `PaymentMethodSelectorModal.test.tsx` to assert the sell flow fires `OFFRAMP_PAYMENT_METHOD_SELECTED`, and renames existing assertions to explicitly reference `ONRAMP_PAYMENT_METHOD_SELECTED`. > > Removes the fully skipped `offramp-cashout.failing.ts` smoke test that previously attempted to validate off-ramp payment method selection and analytics. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f166a54. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7f0ffc3 commit 0f50eef

2 files changed

Lines changed: 29 additions & 118 deletions

File tree

app/components/UI/Ramp/Aggregator/components/PaymentMethodSelectorModal/PaymentMethodSelectorModal.test.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,34 @@ describe('PaymentMethodSelectorModal', () => {
110110
expect(toJSON()).toMatchSnapshot();
111111
});
112112

113-
it('tracks RAMPS_PAYMENT_METHOD_SELECTED event when payment method is selected', () => {
113+
it('tracks OFFRAMP_PAYMENT_METHOD_SELECTED event when payment method is selected in sell flow', () => {
114+
mockUseParams.mockReturnValue({
115+
...defaultParams,
116+
location: 'Amount to Sell Screen' as const,
117+
});
118+
mockUseRampSDKValues = {
119+
...mockUseRampSDKInitialValues,
120+
rampType: RampType.SELL,
121+
isBuy: false,
122+
};
123+
124+
const { getByText } = render(PaymentMethodSelectorModal);
125+
126+
const paymentMethodElement = getByText('Bank Transfer');
127+
fireEvent.press(paymentMethodElement);
128+
129+
expect(mockTrackEvent).toHaveBeenCalledWith(
130+
'OFFRAMP_PAYMENT_METHOD_SELECTED',
131+
{
132+
payment_method_id: 'payment-method-2',
133+
available_payment_method_ids: ['payment-method-1', 'payment-method-2'],
134+
region: 'US',
135+
location: 'Amount to Sell Screen',
136+
},
137+
);
138+
});
139+
140+
it('tracks ONRAMP_PAYMENT_METHOD_SELECTED event when payment method is selected in buy flow', () => {
114141
const { getByText } = render(PaymentMethodSelectorModal);
115142

116143
const paymentMethodElement = getByText('Bank Transfer');
@@ -126,7 +153,7 @@ describe('PaymentMethodSelectorModal', () => {
126153
},
127154
);
128155
});
129-
it('does not track RAMPS_PAYMENT_METHOD_SELECTED event when the same payment method is selected', () => {
156+
it('does not track ONRAMP_PAYMENT_METHOD_SELECTED event when the same payment method is selected', () => {
130157
const { getByText } = render(PaymentMethodSelectorModal);
131158

132159
const paymentMethodElement = getByText('Credit Card');

tests/smoke/ramps/offramp-cashout.failing.ts

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)