Skip to content

test: enhance DeFiSection tests with error handling and retry logic#26773

Merged
PatrykLucka merged 1 commit into
mainfrom
TMCU-496-fix-de-fi-section-not-propagating-retry-on-api-response-failure
Mar 2, 2026
Merged

test: enhance DeFiSection tests with error handling and retry logic#26773
PatrykLucka merged 1 commit into
mainfrom
TMCU-496-fix-de-fi-section-not-propagating-retry-on-api-response-failure

Conversation

@PatrykLucka

@PatrykLucka PatrykLucka commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Description

The DeFi homepage section was returning null (hiding entirely) when the API responded with an error (e.g. 501). This matched the behavior for the empty-data case, but the acceptance criteria requires showing a retry UI on API failure — consistent with how the Predictions and Tokens sections handle errors.

This PR:

  • Separates error and empty handling in DeFiSection: errors now render the shared ErrorState component with a retry button, while empty data (200 with 0 positions) still hides the section.

  • Replaces the no-op refresh function with a real one that calls DeFiPositionsController._executePoll(), so both the retry button and pull-to-refresh actually re-fetch.

  • Updates tests to assert the new error UI behavior and verify retry triggers _executePoll.

Changelog

CHANGELOG entry: Fixed DeFi homepage section to show retry UI when API request fails instead of hiding the section

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TMCU-496

Manual testing steps

Feature: DeFi section error handling on homepage

  Scenario: user sees retry UI when DeFi API fails
    Given the DeFi positions API returns a 501 error
    And the user navigates to the homepage

    When the homepage loads
    Then the DeFi section displays with a "Unable to load" message and a "Retry" button

  Scenario: user retries after API failure
    Given the DeFi section is showing the error/retry UI

    When user taps the "Retry" button
    Then the DeFi positions are re-fetched from the API

  Scenario: DeFi section hidden when no positions exist
    Given the DeFi positions API returns 200 with no positions

    When the homepage loads
    Then the DeFi section is not displayed

Screenshots/Recordings

Before

After

Screenshot 2026-03-02 at 13 21 18

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

Medium Risk
Changes homepage DeFi rendering and refresh behavior to call DeFiPositionsController._executePoll(), which could affect polling frequency and error-handling paths. Uses a controller internal method, so regressions are possible if controller APIs change.

Overview
DeFi homepage section no longer disappears on API errors: when hasError (and not loading) it now renders the shared ErrorState with a Retry button while still hiding the section for the empty data case.

The section’s refresh handler (used by pull-to-refresh and Retry) is wired to Engine.context.DeFiPositionsController._executePoll() to actively re-fetch positions.

Tests were updated to validate the new error UI and to assert that both Retry and the exposed ref.refresh() call _executePoll().

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

@PatrykLucka PatrykLucka self-assigned this Mar 2, 2026
@PatrykLucka PatrykLucka marked this pull request as ready for review March 2, 2026 12:27
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-mobile-ux Mobile UX team label Mar 2, 2026
@github-actions github-actions Bot added the size-S label Mar 2, 2026
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeNetworkAbstractions
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes modify the DeFiSection component on the Homepage to add error handling with a retry button. Key changes:

  1. Added ErrorState component import and Engine import
  2. Modified refresh callback to call Engine.context.DeFiPositionsController._executePoll() instead of being a no-op
  3. Changed error handling from returning null to showing an ErrorState UI with retry functionality

The existing E2E test for DeFi (tests/smoke/assets/defi/view-defi-details.spec.ts) is tagged with SmokeNetworkAbstractions and tests viewing DeFi position details. This test should validate that the DeFi section still renders correctly in the happy path scenario.

The changes are well-contained to the DeFi section's error handling behavior and don't affect:

  • Core wallet functionality
  • Transaction flows
  • Other Homepage sections (Tokens, Perps, Predictions, NFTs)
  • Navigation or critical user paths

The unit tests have been updated to cover the new error state and retry functionality. This is a low-risk UI enhancement that improves user experience when DeFi data fails to load.

Performance Test Selection:
The changes are limited to error handling UI in the DeFi section. The modification adds an ErrorState component display when there's an error and implements a retry mechanism. This doesn't impact: app launch performance, asset loading performance (the data fetching mechanism remains the same), account list rendering, or any other performance-critical paths. The _executePoll call is only triggered on user-initiated retry, not on initial load. No performance tests are needed for this UI enhancement.

View GitHub Actions results

@PatrykLucka PatrykLucka added this pull request to the merge queue Mar 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 2, 2026
@PatrykLucka PatrykLucka added this pull request to the merge queue Mar 2, 2026
Merged via the queue into main with commit 1a0ed51 Mar 2, 2026
176 of 178 checks passed
@PatrykLucka PatrykLucka deleted the TMCU-496-fix-de-fi-section-not-propagating-retry-on-api-response-failure branch March 2, 2026 13:51
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 2, 2026
@metamaskbot metamaskbot added the release-7.69.0 Issue or pull request that will be included in release 7.69.0 label Mar 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.69.0 Issue or pull request that will be included in release 7.69.0 size-S team-mobile-ux Mobile UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants