-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Adds a privacy mode toggle (an eye icon next to the main balance) that hides all sensitive information/token balances **UPDATE** Here is feedback from @amandaye0h and has been currently implemented in this PR [Figma](https://www.figma.com/design/aMYisczaJyEsYl1TYdcPUL/Portfolio-View?node-id=6219-62460&t=aeTv5cenoUPUrg1c-4) [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28021?quickstart=1) ## **Related issues** Fixes: MetaMask/MetaMask-planning#3416 MetaMask/MetaMask-planning#3418 MetaMask/MetaMask-planning#3419 ## **Manual testing steps** 1. Go to the Wallet page 2. Click on the new Eye icon next to the balance 3. All balances should be hidden 4. Click on the Eye icon once again 5. All balances should be shown ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/2950ac0c-593d-4daa-aa5d-3e6c3a2d5598 https://github.com/user-attachments/assets/6371c2a2-04fa-48a3-8744-991a1540d5f2 <img width="496" alt="Screenshot 2024-10-22 at 18 43 19" src="https://github.com/user-attachments/assets/d7c2f681-75c7-4be0-921b-f3c5186f8d4a"> ## **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. --------- Co-authored-by: vinnyhoward <vincenguyenhoward@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com>
- Loading branch information
1 parent
62cc460
commit 05da3f7
Showing
39 changed files
with
284 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
const { strict: assert } = require('assert'); | ||
const { | ||
withFixtures, | ||
unlockWallet, | ||
defaultGanacheOptions, | ||
} = require('../../helpers'); | ||
const FixtureBuilder = require('../../fixture-builder'); | ||
|
||
describe('Privacy Mode', function () { | ||
it('should activate privacy mode, then deactivate it', async function () { | ||
await withFixtures( | ||
{ | ||
dapp: true, | ||
fixtures: new FixtureBuilder().withPreferencesController().build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test.fullTitle(), | ||
}, | ||
async ({ driver }) => { | ||
async function checkForHeaderValue(value) { | ||
const balanceElement = await driver.findElement( | ||
'[data-testid="eth-overview__primary-currency"] .currency-display-component__text', | ||
); | ||
const surveyText = await balanceElement.getText(); | ||
assert.equal( | ||
surveyText, | ||
value, | ||
`Header balance should be "${value}"`, | ||
); | ||
} | ||
|
||
async function checkForTokenValue(value) { | ||
const balanceElement = await driver.findElement( | ||
'[data-testid="multichain-token-list-item-secondary-value"]', | ||
); | ||
const surveyText = await balanceElement.getText(); | ||
assert.equal(surveyText, value, `Token balance should be "${value}"`); | ||
} | ||
|
||
async function checkForPrivacy() { | ||
await checkForHeaderValue('••••••'); | ||
await checkForTokenValue('•••••••••'); | ||
} | ||
|
||
async function checkForNoPrivacy() { | ||
await checkForHeaderValue('25'); | ||
await checkForTokenValue('25 ETH'); | ||
} | ||
|
||
async function togglePrivacy() { | ||
const balanceElement = await driver.findElement( | ||
'[data-testid="eth-overview__primary-currency"] .currency-display-component__text', | ||
); | ||
const initialText = await balanceElement.getText(); | ||
|
||
await driver.clickElement('[data-testid="sensitive-toggle"]'); | ||
await driver.wait(async () => { | ||
const currentText = await balanceElement.getText(); | ||
return currentText !== initialText; | ||
}, 2e3); | ||
} | ||
|
||
await unlockWallet(driver); | ||
await checkForNoPrivacy(); | ||
await togglePrivacy(); | ||
await checkForPrivacy(); | ||
await togglePrivacy(); | ||
await checkForNoPrivacy(); | ||
}, | ||
); | ||
}); | ||
|
||
it('should hide fiat balance and token balance when privacy mode is activated', async function () { | ||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder().withPreferencesController().build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test.fullTitle(), | ||
}, | ||
async ({ driver }) => { | ||
await unlockWallet(driver); | ||
|
||
async function togglePrivacy() { | ||
const balanceElement = await driver.findElement( | ||
'[data-testid="eth-overview__primary-currency"] .currency-display-component__text', | ||
); | ||
const initialText = await balanceElement.getText(); | ||
|
||
await driver.clickElement('[data-testid="sensitive-toggle"]'); | ||
await driver.wait(async () => { | ||
const currentText = await balanceElement.getText(); | ||
return currentText !== initialText; | ||
}, 2e3); | ||
} | ||
|
||
await togglePrivacy(); | ||
await driver.clickElement('[data-testid="account-menu-icon"]'); | ||
const valueText = await driver.findElement( | ||
'[data-testid="account-value-and-suffix"]', | ||
); | ||
const valueTextContent = await valueText.getText(); | ||
|
||
assert.equal(valueTextContent, '••••••'); | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.