Skip to content

Commit 7f0ffc3

Browse files
authored
test: setup full ramps e2e flow using ramps provider (MetaMask#26951)
<!-- 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 add E2E smoke test coverage for the Unified Buy V2 flow, validating both routing paths a user can take when purchasing crypto through the ramps experience. - Two smoke test scenarios: new user (no prior completed orders) routes through the native Transak deposit flow (KYC/OTP + bank transfer); returning user (prior non-Transak aggregator order) routes through the aggregator WebView buy flow - New page objects: KYCScreen, OrderDetailsView, ActivitiesView, ToastModal, extended BuildQuoteView - Full Transak native flow mocking: auth/login, auth/verify, quotes, user details, KYC requirements, user limits, create order - Ramps mock infrastructure refactor: introduced setupDepositOnRampMocks and setupBuyOnRampMocks as single-purpose helpers; - setupRegionAwareOnRampMocks retained as the base for build-quote-only tests; default providerType corrected from native to aggregator - TestID additions: crypto/fiat amount testIDs moved to DisplayOrderListItem (the actually-rendered component), testIDs added to EnterEmail, OtpCode, VerifyIdentity, and ActivitiesView; removed dead OrdersListTestIds aggregate export ## **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** > Mostly E2E test, selector, and mock refactors, but it substantially changes the on-ramp mocking setup and fixtures used across ramps smoke tests, which could cause test flakiness or broken flows if assumptions drift. > > **Overview** > Adds end-to-end smoke coverage for Unified Buy V2 across both routing paths: **new users** go through the native Transak KYC/OTP deposit flow, while **returning users** go through the aggregator (widget/WebView) buy flow, including verification of the resulting order in the Activity transfers list and basic analytics assertions. > > Refactors ramps API mocking to provide dedicated helpers (`setupDepositOnRampMocks`, `setupBuyOnRampMocks`) and expands mocked endpoints for the native Transak flow (auth, quotes, user/KYC/limits, order creation, translation, and stateful order polling), while splitting buy vs deposit order-status mocking. > > Improves Detox automation by adding/centralizing `testID` selectors for ramps screens (`EnterEmail`, `OtpCode`, `VerifyIdentity`, `OrderDetails`) and for `OrdersList` rows/amounts, plus new page objects (`KYCScreen`, `OrderDetailsView`) and enhanced page object actions (e.g., wait-for-enabled Continue). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 0b768fe. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2ffae0c commit 7f0ffc3

36 files changed

Lines changed: 1023 additions & 111 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export type RampsOrderTypeSlug = 'buy' | 'sell' | 'deposit';
2+
3+
export const getOrderRowTestId = (type: RampsOrderTypeSlug, index: number) =>
4+
`orders-list-row-${type}-${index}`;
5+
6+
export const getOrderRowCryptoAmountTestId = (
7+
type: RampsOrderTypeSlug,
8+
index: number,
9+
) => `orders-list-crypto-amount-${type}-${index}`;
10+
11+
export const getOrderRowFiatAmountTestId = (
12+
type: RampsOrderTypeSlug,
13+
index: number,
14+
) => `orders-list-fiat-amount-${type}-${index}`;

app/components/UI/Ramp/Aggregator/Views/OrdersList/OrdersList.tsx

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ import ListItemColumn, {
4141
WidthType,
4242
} from '../../../../../../component-library/components/List/ListItemColumn';
4343
import ListItemColumnEnd from '../../components/ListItemColumnEnd';
44+
import {
45+
getOrderRowTestId,
46+
getOrderRowCryptoAmountTestId,
47+
getOrderRowFiatAmountTestId,
48+
type RampsOrderTypeSlug,
49+
} from './OrdersList.testIds';
4450

4551
type filterType = 'ALL' | 'PURCHASE' | 'SELL';
4652

@@ -92,12 +98,25 @@ function getStatusColorAndText(
9298
return [statusColor, statusText];
9399
}
94100

95-
function DisplayOrderListItem({ item }: { item: DisplayOrder }) {
101+
function getOrderTypeSlug(orderType: string): RampsOrderTypeSlug {
102+
if (orderType === 'DEPOSIT') return 'deposit';
103+
if (orderType === 'SELL') return 'sell';
104+
return 'buy';
105+
}
106+
107+
function DisplayOrderListItem({
108+
item,
109+
index,
110+
}: {
111+
item: DisplayOrder;
112+
index: number;
113+
}) {
96114
const isBuy = item.orderType === 'BUY' || item.orderType === 'DEPOSIT';
97115
const [statusColor, statusText] = getStatusColorAndText(
98116
item.status,
99117
item.orderType,
100118
);
119+
const typeSlug = getOrderTypeSlug(item.orderType);
101120

102121
const title = item.providerName
103122
? `${item.providerName}: ${strings(
@@ -128,10 +147,17 @@ function DisplayOrderListItem({ item }: { item: DisplayOrder }) {
128147
</ListItemColumn>
129148

130149
<ListItemColumnEnd>
131-
<Text variant={TextVariant.BodyMD}>
150+
<Text
151+
testID={getOrderRowCryptoAmountTestId(typeSlug, index)}
152+
variant={TextVariant.BodyMD}
153+
>
132154
{item.cryptoAmount} {item.cryptoCurrencySymbol}
133155
</Text>
134-
<Text variant={TextVariant.BodySM} color={TextColor.Alternative}>
156+
<Text
157+
testID={getOrderRowFiatAmountTestId(typeSlug, index)}
158+
variant={TextVariant.BodySM}
159+
color={TextColor.Alternative}
160+
>
135161
{item.fiatAmount == null
136162
? '...'
137163
: addCurrencySymbol(
@@ -256,16 +282,23 @@ function OrdersList() {
256282
],
257283
);
258284

259-
const renderItem = ({ item }: { item: DisplayOrder }) => (
285+
const renderItem = ({
286+
item,
287+
index,
288+
}: {
289+
item: DisplayOrder;
290+
index: number;
291+
}) => (
260292
<TouchableHighlight
293+
testID={getOrderRowTestId(getOrderTypeSlug(item.orderType), index + 1)}
261294
accessibilityRole="button"
262295
accessible
263296
style={styles.row}
264297
onPress={() => handleItemPress(item)}
265298
underlayColor={colors.background.alternative}
266299
activeOpacity={1}
267300
>
268-
<DisplayOrderListItem item={item} />
301+
<DisplayOrderListItem item={item} index={index + 1} />
269302
</TouchableHighlight>
270303
);
271304

0 commit comments

Comments
 (0)