test: enhance DeFiSection tests with error handling and retry logic#26773
Conversation
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
The existing E2E test for DeFi ( The changes are well-contained to the DeFi section's error handling behavior and don't affect:
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: |
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
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
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 sharedErrorStatewith a Retry button while still hiding the section for the empty data case.The section’s
refreshhandler (used by pull-to-refresh and Retry) is wired toEngine.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.