You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## **Description**
This PR implements the `BalanceEmptyState` component on the homepage
when users have a zero balance across all mainnet networks. It is hidden
behind the `homepageRedesignV1Key` feature flag which will be used for
full page scroll of the homepage.
- Shows `BalanceEmptyState` component for accounts with an aggregated
balance of zero across mainnets(excludes testnets)
- Applies to only `AccountGroupBalance` component.
- Replaces the regular balance display with an empty state component
when total aggregated balance is zero
- Replaces previous `TokenListFooter`(Removed in this PR:
#21490)
- Hidden behind the `homepageRedesignV1Key` feature flag
- Adds new `selectWalletBalanceForEmptyState` to get balance across all
networks
- Adds e2e tests
## **Changelog**
CHANGELOG entry: Updating zero balance display to "Add funds" card
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/DSYS-153
## **Manual testing steps**
```gherkin
Feature: Balance Empty State on Homepage
Background:
Given the homepageRedesignV1Key feature flag is enabled
Scenario: User with zero balance across all aggregated networks sees empty state
Given user has a wallet with zero balance across all aggregated networks (Evm and nonEvm)
When user navigates to the homepage
Then user should see the BalanceEmptyState component with illustration and "Add funds" button
And user should not see the regular balance display showing "$0.00"
Scenario: User with positive balance on all aggregated networks sees positive balance
Given user has a wallet with positive balance across aggregated networks (EVM and non EVM)
When user navigates to the homepage
Then user should see the normal balance display showing the actual dollar amount
And user should not see the BalanceEmptyState component
Scenario: User changes to network with empty balance sees zero balance
Given user has positive balance on some networks but zero on others
When user switches to a network where they have zero balance (EVM and non EVM)
Then user should see "$0.00" balance display
Scenario: User changes to network with positive balance sees positive balance (including test networks)
Given user has zero balance on some networks but positive on others
When user switches to a network where they have positive balance (mainnet, Sepolia, Goerli, etc.)
Then user should see the normal balance display with actual amount
And user should not see the BalanceEmptyState component
And this behavior should be consistent across mainnet and test networks
Scenario: User taps "Add funds" button from empty state
Given user sees the BalanceEmptyState on homepage
When user taps the "Add funds" button
Then user should be navigated to the buy crypto page (not deposit flow)
And appropriate analytics events should be tracked
Scenario: Feature flag disabled - no empty state shown
Given the homepageRedesignV1Key feature flag is disabled
And user has zero balance
When user navigates to the homepage
Then user should see the regular "$0.00" balance display
And user should not see the BalanceEmptyState component
Scenario: Privacy mode interaction with empty state
Given user has zero balance and sees BalanceEmptyState
When user toggles privacy mode
Then the BalanceEmptyState should remain visible (not affected by privacy toggle)
Scenario: Loading states
Given user navigates to homepage
When balance data is still loading
Then user should see skeleton/loader components
And user should not see BalanceEmptyState or balance display until data loads
```
## **Screenshots/Recordings**
### **Before**
Empty balance showed a `0` balance and footer CTA to go to deposit
https://github.com/user-attachments/assets/022fa47d-b567-41a8-a1f7-d85ac3164701
Loading balance on first import of an account with zero balance
https://github.com/user-attachments/assets/a91cca57-31a2-4317-b741-206884f9a2db
### **After**
Empty balance now shows BalanceEmptyState component
https://github.com/user-attachments/assets/44b9c855-d9fb-4c96-bcac-72b62a82b862
The flicker between a zero balance(now empty state) still exists and is
an architectural issue outside of the scope of this PR. This is being
worked on by the @MetaMask/metamask-assets team
https://github.com/user-attachments/assets/de262384-ebdf-4bc6-8f94-b5ab39aec928
## **Pre-merge author checklist**
- [x] 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).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] 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 recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Show BalanceEmptyState in `AccountGroupBalance` when aggregated
mainnet balance is zero (feature-flagged), with new selector and
comprehensive tests.
>
> - **UI (Wallet)**:
> - Display `BalanceEmptyState` in `AccountGroupBalance` when aggregated
mainnet balance is zero; hide on testnets; keep skeleton while loading;
gated by `selectHomepageRedesignV1Enabled`.
> - Uses `TEST_NETWORK_IDS` and `selectEvmChainId` to suppress empty
state on test networks.
> - **Selectors**:
> - Add `selectAccountGroupBalanceForEmptyState` to compute selected
group balance across mainnet networks only, using CAIP utilities and
excluding `TEST_NETWORK_IDS` and `NON_EVM_TESTNET_IDS`.
> - **Tests**:
> - Unit: update `AccountGroupBalance.test.tsx` to cover empty state
rendering; add selector tests for network filtering, no selection, and
missing group fallbacks.
> - E2E: add `balance-empty-state.spec.ts` validating visibility on
mainnet vs testnets, navigation to buy flow, and persistence after
restart; extend page object `WalletView` and selectors with
`BALANCE_EMPTY_STATE_*` IDs.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2078f33. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
0 commit comments