fix(deposit): correct OTP resend error localization key and test#24264
fix(deposit): correct OTP resend error localization key and test#24264
Conversation
- Fix missing localization key: changed 'deposit.otp_code.resend_error' to 'deposit.otp_code.resend_code_error' which exists in en.json - Fix test to properly await async operation and capture error state - Update snapshot to reflect correct error UI state
d94c6d5 to
bc2dddb
Compare
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsThe changes are isolated to the Ramp/Deposit OTP code verification flow:
These changes are:
The SmokeRamps tag is the appropriate choice as it covers on/off ramp features including deposit flows where OTP verification is used. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24264 +/- ##
=======================================
Coverage 79.28% 79.28%
=======================================
Files 4059 4060 +1
Lines 106950 106955 +5
Branches 21701 21720 +19
=======================================
+ Hits 84798 84803 +5
+ Misses 16231 16230 -1
- Partials 5921 5922 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|



Description
This PR fixes two related issues in the OTP Code screen for the Deposit flow:
Issue 1: Missing Localization Key
The
ResendButtoncomponent was referencing a non-existent localization keydeposit.otp_code.resend_error, which would display the raw key string to users instead of the intended error message.The correct key that exists in
en.jsonisdeposit.otp_code.resend_code_errorwith the value "Error resending code."Issue 2: Test Not Capturing Error State
The test case "renders resend error snapshot when resend fails" was not properly testing the error state. It was taking a snapshot immediately after pressing the resend button, capturing the cooldown state ("Resend code in 30 seconds") instead of the error state ("Error resending code.").
This happened because:
mockSendUserOtp.mockRejectedValue()promise rejection was processedresendButtonState === 'cooldown'instead ofresendButtonState === 'resendError'Detailed Changes
Fix 1: Localization Key (OtpCode.tsx)
View diff
Fix 2: Test Case (OtpCode.test.tsx)
View diff
it('renders resend error snapshot when resend fails', async () => { mockSendUserOtp.mockRejectedValue(new Error('Failed to resend')); render(OtpCode); const resendButton = screen.getByText('Resend it'); - fireEvent.press(resendButton); + + await act(async () => { + fireEvent.press(resendButton); + }); + + await waitFor(() => { + expect(screen.getByText('Error resending code.')).toBeOnTheScreen(); + }); + expect(screen.toJSON()).toMatchSnapshot(); });Fix 3: Updated Snapshot
View snapshot diff
The snapshot now correctly captures the error state UI:
Changelog
CHANGELOG entry: Fixes a small localization key bug in the OTP code screen for Buy (deposit)
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-2950
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Resolves incorrect error messaging and ensures tests validate the actual resend failure UI state.
OtpCode.tsxto use existing i18n keydeposit.otp_code.resend_code_errorfor the resend failure stateOtpCode.test.tsxby awaiting the async resend action (act+waitFor) and asserting"Error resending code."before snapshotWritten by Cursor Bugbot for commit 1757cf9. This will update automatically on new commits. Configure here.