From ba11881e3f1a7963db6d54534c647e60a834ea85 Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Thu, 21 Nov 2024 13:23:10 +0100 Subject: [PATCH] fix: fix account list item for portfolio view (#28598) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Fixes account list item wit Portfolio view feature flag. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28598?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/metamask-extension/issues/28592 ## **Manual testing steps** Make sure you run the steps with AND without the PORTFOLIO_VIEW flag 1. Go to settings => Security and privacy => and disable "Show balance and token price checker" 2. Open account picker make sure you see crypto values 3. Enable the setting again and you should see Fiat values ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] 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-extension/blob/develop/.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 screenshots. --- .../tests/settings/account-token-list.spec.js | 37 +++++++++++++++++++ .../account-list-item/account-list-item.js | 4 +- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/test/e2e/tests/settings/account-token-list.spec.js b/test/e2e/tests/settings/account-token-list.spec.js index ddd905501f50..ec24119dd44b 100644 --- a/test/e2e/tests/settings/account-token-list.spec.js +++ b/test/e2e/tests/settings/account-token-list.spec.js @@ -116,4 +116,41 @@ describe('Settings', function () { }, ); }); + + it('Should show crypto value when price checker setting is off', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withConversionRateEnabled() + .withShowFiatTestnetEnabled() + .withPreferencesControllerShowNativeTokenAsMainBalanceDisabled() + .withConversionRateDisabled() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + testSpecificMock: mockInfuraResponses, + }, + async ({ driver }) => { + await unlockWallet(driver); + + await driver.clickElement('[data-testid="popover-close"]'); + await driver.clickElement( + '[data-testid="account-overview__asset-tab"]', + ); + + const tokenListAmount = await driver.findElement( + '.eth-overview__primary-container', + ); + await driver.delay(1000); + assert.equal(await tokenListAmount.getText(), '25\nETH'); + + await driver.clickElement('[data-testid="account-menu-icon"]'); + const accountTokenValue = await driver.waitForSelector( + '.multichain-account-list-item .multichain-account-list-item__asset', + ); + + assert.equal(await accountTokenValue.getText(), '25ETH'); + }, + ); + }); }); diff --git a/ui/components/multichain/account-list-item/account-list-item.js b/ui/components/multichain/account-list-item/account-list-item.js index 6be8e3f67f0b..207b8fa0fe58 100644 --- a/ui/components/multichain/account-list-item/account-list-item.js +++ b/ui/components/multichain/account-list-item/account-list-item.js @@ -143,7 +143,7 @@ const AccountListItem = ({ let balanceToTranslate; if (isEvmNetwork) { balanceToTranslate = - shouldShowFiat || isTestnet || !process.env.PORTFOLIO_VIEW + !shouldShowFiat || isTestnet || !process.env.PORTFOLIO_VIEW ? account.balance : totalFiatBalance; } else { @@ -345,7 +345,7 @@ const AccountListItem = ({ type={PRIMARY} showFiat={showFiat} isAggregatedFiatOverviewBalance={ - !isTestnet && process.env.PORTFOLIO_VIEW + !isTestnet && process.env.PORTFOLIO_VIEW && shouldShowFiat } data-testid="first-currency-display" privacyMode={privacyMode}