Skip to content

Commit cc3dfdc

Browse files
chore(runway): cherry-pick fix(ramp): fixes order details bug cp-7.71.0 (#27801)
- fix(ramp): fixes order details bug cp-7.71.0 (#27755) <!-- 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** Fixes an order details UI bug where the title for bank transfer details was displaying for non bank-transfer orders. [TRAM 3359](https://consensyssoftware.atlassian.net/browse/TRAM-3359) <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **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: fixes an order details UI bug ## **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. --> ### * <img width="458" height="974" alt="Screenshot 2026-03-20 at 10 03 02 AM" src="https://github.com/user-attachments/assets/4d94ca14-1e17-401d-945b-5f38acf28e4a" /> *Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> <img width="451" height="976" alt="Screenshot 2026-03-20 at 11 39 11 AM" src="https://github.com/user-attachments/assets/19595c85-e138-4fdc-bb52-a57271593ff8" /> ## **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] > **Low Risk** > Low risk UI-only change that gates rendering of the bank details section; main risk is unintentionally hiding bank details if upstream field names/structure change. > > **Overview** > Fixes an order details UI bug where the bank-transfer section header could render for non-bank-transfer orders. > > `OrderContent` now returns `null` for `bankDetailFields` unless at least one expected bank detail field (e.g., amount, routing/account, IBAN/BIC) is present, and tests add coverage for absent/empty/non-matching `paymentDetails` vs. bank-transfer/SEPA scenarios. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 65f6cfc. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [7e9748e](7e9748e) Co-authored-by: George Weiler <georgejweiler@gmail.com>
1 parent 445b430 commit cc3dfdc

2 files changed

Lines changed: 99 additions & 1 deletion

File tree

app/components/UI/Ramp/Views/OrderDetails/OrderContent.test.tsx

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import { type RampsOrder, RampsOrderStatus } from '@metamask/ramps-controller';
77
import Clipboard from '@react-native-clipboard/clipboard';
88
import InAppBrowser from 'react-native-inappbrowser-reborn';
99

10+
type RampsOrderWithPaymentDetails = RampsOrder & {
11+
paymentDetails: {
12+
fiatCurrency: string;
13+
paymentMethod: string;
14+
fields: { name: string; id: string; value: string }[];
15+
}[];
16+
};
17+
1018
const mockNavigate = jest.fn();
1119
jest.mock('@react-navigation/native', () => ({
1220
...jest.requireActual('@react-navigation/native'),
@@ -177,6 +185,84 @@ describe('OrderContent', () => {
177185
).toBeOnTheScreen();
178186
});
179187

188+
it('does not render bank details section when paymentDetails is absent', () => {
189+
renderOrder(mockOrder);
190+
191+
expect(screen.queryByText('To complete your order')).toBeNull();
192+
});
193+
194+
it('does not render bank details section when paymentDetails has no matching fields', () => {
195+
const orderWithPaymentDetails: RampsOrderWithPaymentDetails = {
196+
...mockOrder,
197+
paymentDetails: [
198+
{
199+
fiatCurrency: 'USD',
200+
paymentMethod: 'credit_debit_card',
201+
fields: [],
202+
},
203+
],
204+
};
205+
206+
renderOrder(orderWithPaymentDetails);
207+
208+
expect(screen.queryByText('To complete your order')).toBeNull();
209+
});
210+
211+
it('renders bank details section when paymentDetails has bank transfer fields', () => {
212+
const orderWithPaymentDetails: RampsOrderWithPaymentDetails = {
213+
...mockOrder,
214+
paymentDetails: [
215+
{
216+
fiatCurrency: 'USD',
217+
paymentMethod: 'manual_bank_transfer',
218+
fields: [
219+
{ name: 'Amount', id: 'amount', value: '$100.00' },
220+
{
221+
name: 'Routing Number',
222+
id: 'routingNumber',
223+
value: '021000021',
224+
},
225+
{
226+
name: 'Account Number',
227+
id: 'accountNumber',
228+
value: '1234567890',
229+
},
230+
],
231+
},
232+
],
233+
};
234+
235+
renderOrder(orderWithPaymentDetails);
236+
237+
expect(screen.getByText('To complete your order')).toBeOnTheScreen();
238+
expect(screen.getByText(/Routing number/i)).toBeOnTheScreen();
239+
expect(screen.getByText('021000021')).toBeOnTheScreen();
240+
});
241+
242+
it('renders bank details section when paymentDetails only includes SEPA fields', () => {
243+
const orderWithPaymentDetails: RampsOrderWithPaymentDetails = {
244+
...mockOrder,
245+
paymentDetails: [
246+
{
247+
fiatCurrency: 'EUR',
248+
paymentMethod: 'sepa_bank_transfer',
249+
fields: [
250+
{ name: 'IBAN', id: 'iban', value: 'DE89370400440532013000' },
251+
{ name: 'BIC', id: 'bic', value: 'COBADEFFXXX' },
252+
],
253+
},
254+
],
255+
};
256+
257+
renderOrder(orderWithPaymentDetails);
258+
259+
expect(screen.getByText('To complete your order')).toBeOnTheScreen();
260+
expect(screen.getByText(/^IBAN$/i)).toBeOnTheScreen();
261+
expect(screen.getByText('DE89370400440532013000')).toBeOnTheScreen();
262+
expect(screen.getByText(/^BIC$/i)).toBeOnTheScreen();
263+
expect(screen.getByText('COBADEFFXXX')).toBeOnTheScreen();
264+
});
265+
180266
it('truncates long crypto amounts to 5 decimal places', () => {
181267
const longDecimalOrder: RampsOrder = {
182268
...mockOrder,
@@ -195,7 +281,7 @@ describe('OrderContent', () => {
195281
};
196282
renderOrder(tinyAmountOrder);
197283
const tokenAmount = screen.getByTestId('ramps-order-details-token-amount');
198-
// 0.00000614 has 5 leading zeros "0.0₅614"
284+
// 0.00000614 has 5 leading zeros -> "0.0₅614"
199285
expect(tokenAmount).toHaveTextContent('0.0₅614 ETH');
200286
});
201287

app/components/UI/Ramp/Views/OrderDetails/OrderContent.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,18 @@ const OrderContent: React.FC<OrderContentProps> = ({
280280
const iban = getFieldValue('IBAN');
281281
const bic = getFieldValue('BIC');
282282

283+
const hasAnyField =
284+
amount ||
285+
accountName ||
286+
accountType ||
287+
bankName ||
288+
routingNumber ||
289+
accountNumber ||
290+
iban ||
291+
bic;
292+
293+
if (!hasAnyField) return null;
294+
283295
return {
284296
amount,
285297
accountName,

0 commit comments

Comments
 (0)