Commit 0f50eef
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
- tests/smoke/ramps
Lines changed: 29 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
114 | 141 | | |
115 | 142 | | |
116 | 143 | | |
| |||
126 | 153 | | |
127 | 154 | | |
128 | 155 | | |
129 | | - | |
| 156 | + | |
130 | 157 | | |
131 | 158 | | |
132 | 159 | | |
| |||
This file was deleted.
0 commit comments