Skip to content

fix(deposit): correct OTP resend error localization key and test#24264

Merged
wachunei merged 2 commits intomainfrom
fix/otp-code-resend-error-localization
Jan 7, 2026
Merged

fix(deposit): correct OTP resend error localization key and test#24264
wachunei merged 2 commits intomainfrom
fix/otp-code-resend-error-localization

Conversation

@wachunei
Copy link
Copy Markdown
Member

@wachunei wachunei commented Jan 6, 2026

Description

This PR fixes two related issues in the OTP Code screen for the Deposit flow:

Issue 1: Missing Localization Key

The ResendButton component was referencing a non-existent localization key deposit.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.json is deposit.otp_code.resend_code_error with 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:

  1. The test pressed the button but didn't await the async operation
  2. The snapshot was taken before the mockSendUserOtp.mockRejectedValue() promise rejection was processed
  3. Therefore, the snapshot showed resendButtonState === 'cooldown' instead of resendButtonState === 'resendError'

Detailed Changes

Fix 1: Localization Key (OtpCode.tsx)

View diff

- text="deposit.otp_code.resend_error"
+ text="deposit.otp_code.resend_code_error"

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:

-                               Resend code in 30 seconds
+                               Error resending code.
                              </Text>
+                             <TouchableOpacity
+                               onPress={[Function]}
+                             >
+                               <Text ...>
+                                 Contact support
+                               </Text>
+                             </TouchableOpacity>

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

Feature: OTP Code Resend Error State

  Scenario: user sees error message when OTP resend fails
    Given user is on the OTP Code screen in the Deposit flow
    And the network request to resend OTP will fail

    When user taps "Resend it" button
    Then user sees "Error resending code." text
    And user sees "Contact support" link

Screenshots/Recordings

Before

before

After

after

Pre-merge author checklist

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.

Note

Resolves incorrect error messaging and ensures tests validate the actual resend failure UI state.

  • Update OtpCode.tsx to use existing i18n key deposit.otp_code.resend_code_error for the resend failure state
  • Fix OtpCode.test.tsx by awaiting the async resend action (act + waitFor) and asserting "Error resending code." before snapshot
  • Refresh snapshots to display the error message with the "Contact support" link instead of the cooldown text

Written by Cursor Bugbot for commit 1757cf9. This will update automatically on new commits. Configure here.

@metamaskbot metamaskbot added the team-money-movement issues related to Money Movement features label Jan 6, 2026
@github-actions github-actions bot added the size-S label Jan 6, 2026
@wachunei wachunei marked this pull request as ready for review January 6, 2026 13:26
@wachunei wachunei requested a review from a team as a code owner January 6, 2026 13:26
- 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
@wachunei wachunei force-pushed the fix/otp-code-resend-error-localization branch from d94c6d5 to bc2dddb Compare January 6, 2026 13:38
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 6, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeRamps
  • Risk Level: low
  • AI Confidence: 92%
click to see 🤖 AI reasoning details

The changes are isolated to the Ramp/Deposit OTP code verification flow:

  1. OtpCode.tsx: A minor i18n key fix changing "deposit.otp_code.resend_error" to "deposit.otp_code.resend_code_error" - this corrects the localization key for the resend error message.

  2. OtpCode.test.tsx: Test improvements adding proper async handling with act() and waitFor() to ensure the error state is properly rendered before snapshot comparison.

  3. Snapshot update: Updated to correctly capture the error state UI with "Error resending code." text and "Contact support" button.

These changes are:

  • Purely UI text and test improvements
  • No business logic changes
  • Well-contained within the Ramp Deposit feature
  • Low risk as they don't affect core functionality

The SmokeRamps tag is the appropriate choice as it covers on/off ramp features including deposit flows where OTP verification is used.

View GitHub Actions results

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.28%. Comparing base (c4ed238) to head (1757cf9).
⚠️ Report is 9 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jan 6, 2026

@wachunei wachunei added this pull request to the merge queue Jan 7, 2026
Merged via the queue into main with commit 595c510 Jan 7, 2026
91 checks passed
@wachunei wachunei deleted the fix/otp-code-resend-error-localization branch January 7, 2026 15:52
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
@metamaskbot metamaskbot added the release-7.62.0 Issue or pull request that will be included in release 7.62.0 label Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.62.0 Issue or pull request that will be included in release 7.62.0 size-S team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants