diff --git a/package.json b/package.json index 0d51caef9..b735bb90f 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,6 @@ "react-dom": "^16.12.0", "react-idle-timer": "^4.2.5", "react-inspector": "^2.3.0", - "react-media": "^1.8.0", "react-popper": "^2.2.3", "react-redux": "^7.2.0", "react-router-dom": "^5.1.2", diff --git a/test/e2e/address-book.spec.js b/test/e2e/address-book.spec.js index 35a86a58d..72f194fa2 100644 --- a/test/e2e/address-book.spec.js +++ b/test/e2e/address-book.spec.js @@ -195,6 +195,7 @@ describe('MetaMask', function () { }) it('finds the transaction in the transactions list', async function () { + await driver.clickElement(By.css('[data-testid="home__history-tab"]')) await driver.wait(async () => { const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item')) return confirmedTxes.length === 1 diff --git a/test/e2e/benchmark.js b/test/e2e/benchmark.js index 86f8c9f9d..e8612065b 100644 --- a/test/e2e/benchmark.js +++ b/test/e2e/benchmark.js @@ -16,7 +16,7 @@ async function measurePage (pageName) { const passwordField = await driver.findElement(By.css('#password')) await passwordField.sendKeys('correct horse battery staple') await passwordField.sendKeys(Key.ENTER) - await driver.findElement(By.css('.account-details__account-name')) + await driver.findElement(By.css('.selected-account__name')) await driver.navigate(pageName) await driver.delay(1000) metrics = await driver.collectMetrics() diff --git a/test/e2e/ethereum-on.spec.js b/test/e2e/ethereum-on.spec.js index 9ec96c0e2..19bcb9e5d 100644 --- a/test/e2e/ethereum-on.spec.js +++ b/test/e2e/ethereum-on.spec.js @@ -84,8 +84,8 @@ describe('MetaMask', function () { await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`)) await driver.delay(regularDelayMs) - await driver.clickElement(By.css('.account-details__details-button')) - await driver.delay(regularDelayMs) + await driver.clickElement(By.css('[data-testid="account-options-menu-button"]')) + await driver.clickElement(By.css('[data-testid="account-options-menu__account-details"]')) }) it('gets the current accounts address', async function () { diff --git a/test/e2e/from-import-ui.spec.js b/test/e2e/from-import-ui.spec.js index f187cdf04..6771dfd6b 100644 --- a/test/e2e/from-import-ui.spec.js +++ b/test/e2e/from-import-ui.spec.js @@ -98,7 +98,8 @@ describe('Using MetaMask with an existing account', function () { describe('Show account information', function () { it('shows the correct account address', async function () { - await driver.clickElement(By.css('.account-details__details-button')) + await driver.clickElement(By.css('[data-testid="account-options-menu-button"]')) + await driver.clickElement(By.css('[data-testid="account-options-menu__account-details"]')) await driver.findVisibleElement(By.css('.qr-wrapper')) await driver.delay(regularDelayMs) @@ -110,7 +111,8 @@ describe('Using MetaMask with an existing account', function () { }) it('shows a QR code for the account', async function () { - await driver.clickElement(By.css('.account-details__details-button')) + await driver.clickElement(By.css('[data-testid="account-options-menu-button"]')) + await driver.clickElement(By.css('[data-testid="account-options-menu__account-details"]')) await driver.findVisibleElement(By.css('.qr-wrapper')) const detailModal = await driver.findElement(By.css('span .modal')) await driver.delay(regularDelayMs) @@ -167,7 +169,7 @@ describe('Using MetaMask with an existing account', function () { }) it('should show the correct account name', async function () { - const [accountName] = await driver.findElements(By.css('.account-details__account-name')) + const accountName = await driver.findElement(By.css('.selected-account__name')) assert.equal(await accountName.getText(), '2nd account') await driver.delay(regularDelayMs) }) @@ -214,6 +216,7 @@ describe('Using MetaMask with an existing account', function () { }) it('finds the transaction in the transactions list', async function () { + await driver.clickElement(By.css('[data-testid="home__history-tab"]')) await driver.wait(async () => { const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item')) return confirmedTxes.length === 1 @@ -243,23 +246,26 @@ describe('Using MetaMask with an existing account', function () { }) it('should show the correct account name', async function () { - const [accountName] = await driver.findElements(By.css('.account-details__account-name')) + const accountName = await driver.findElement(By.css('.selected-account__name')) assert.equal(await accountName.getText(), 'Account 4') await driver.delay(regularDelayMs) }) it('should show the imported label', async function () { - const [importedLabel] = await driver.findElements(By.css('.account-details__keyring-label')) + await driver.clickElement(By.css('.account-menu__icon')) + + // confirm 4th account is account 4, as expected + const accountMenuItemSelector = '.account-menu__account:nth-child(4)' + const accountName = await driver.findElement(By.css(`${accountMenuItemSelector} .account-menu__name`)) + assert.equal(await accountName.getText(), 'Account 4') + // confirm label is present on the same menu item + const importedLabel = await driver.findElement(By.css(`${accountMenuItemSelector} .keyring-label`)) assert.equal(await importedLabel.getText(), 'IMPORTED') - await driver.delay(regularDelayMs) }) }) describe('Imports and removes an account', function () { it('choose Create Account from the account menu', async function () { - await driver.clickElement(By.css('.account-menu__icon')) - await driver.delay(regularDelayMs) - await driver.clickElement(By.xpath(`//div[contains(text(), 'Import Account')]`)) await driver.delay(regularDelayMs) }) @@ -273,7 +279,7 @@ describe('Using MetaMask with an existing account', function () { }) it('should open the remove account modal', async function () { - const [accountName] = await driver.findElements(By.css('.account-details__account-name')) + const accountName = await driver.findElement(By.css('.selected-account__name')) assert.equal(await accountName.getText(), 'Account 5') await driver.delay(regularDelayMs) @@ -294,7 +300,7 @@ describe('Using MetaMask with an existing account', function () { await driver.delay(regularDelayMs) - const [accountName] = await driver.findElements(By.css('.account-details__account-name')) + const accountName = await driver.findElement(By.css('.selected-account__name')) assert.equal(await accountName.getText(), 'Account 1') await driver.delay(regularDelayMs) diff --git a/test/e2e/incremental-security.spec.js b/test/e2e/incremental-security.spec.js index 8def26110..7a3848925 100644 --- a/test/e2e/incremental-security.spec.js +++ b/test/e2e/incremental-security.spec.js @@ -90,8 +90,8 @@ describe('MetaMask', function () { await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`)) await driver.delay(regularDelayMs) - await driver.clickElement(By.css('.account-details__details-button')) - await driver.delay(regularDelayMs) + await driver.clickElement(By.css('[data-testid="account-options-menu-button"]')) + await driver.clickElement(By.css('[data-testid="account-options-menu__account-details"]')) }) it('gets the current accounts address', async function () { diff --git a/test/e2e/metamask-ui.spec.js b/test/e2e/metamask-ui.spec.js index bf1e9c6c2..871290156 100644 --- a/test/e2e/metamask-ui.spec.js +++ b/test/e2e/metamask-ui.spec.js @@ -119,7 +119,8 @@ describe('MetaMask', function () { describe('Show account information', function () { it('shows the QR code for the account', async function () { - await driver.clickElement(By.css('.account-details__details-button')) + await driver.clickElement(By.css('[data-testid="account-options-menu-button"]')) + await driver.clickElement(By.css('[data-testid="account-options-menu__account-details"]')) await driver.findVisibleElement(By.css('.qr-wrapper')) await driver.delay(regularDelayMs) @@ -169,7 +170,7 @@ describe('MetaMask', function () { }) it('should display correct account name', async function () { - const accountName = await driver.findElement(By.css('.account-details__account-name')) + const accountName = await driver.findElement(By.css('.selected-account__name')) assert.equal(await accountName.getText(), '2nd account') await driver.delay(regularDelayMs) }) @@ -265,6 +266,7 @@ describe('MetaMask', function () { }) it('finds the transaction in the transactions list', async function () { + await driver.clickElement(By.css('[data-testid="home__history-tab"]')) await driver.wait(async () => { const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item')) return confirmedTxes.length === 1 @@ -810,6 +812,7 @@ describe('MetaMask', function () { }) it('clicks on the Add Token button', async function () { + await driver.clickElement(By.css(`[data-testid="home__asset-tab"]`)) await driver.clickElement(By.xpath(`//button[contains(text(), 'Add Token')]`)) await driver.delay(regularDelayMs) }) @@ -900,6 +903,7 @@ describe('MetaMask', function () { }) it('finds the transaction in the transactions list', async function () { + await driver.clickElement(By.css(`[data-testid="home__history-tab"]`)) await driver.wait(async () => { const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item')) return confirmedTxes.length === 1 @@ -992,6 +996,8 @@ describe('MetaMask', function () { const txStatuses = await driver.findElements(By.css('.list-item__heading')) await driver.wait(until.elementTextMatches(txStatuses[0], /Send\sTST/), 10000) + await driver.clickElement(By.css('[data-testid="home__asset-tab"]')) + await driver.clickElement(By.css('[data-testid="wallet-balance"]')) await driver.clickElement(By.css('.token-cell')) @@ -1019,6 +1025,8 @@ describe('MetaMask', function () { await driver.switchToWindow(extension) await driver.delay(regularDelayMs) + await driver.clickElement(By.css('[data-testid="home__history-tab"]')) + await driver.wait(async () => { const pendingTxes = await driver.findElements(By.css('.transaction-list__pending-transactions .transaction-list-item')) return pendingTxes.length === 1 @@ -1219,6 +1227,8 @@ describe('MetaMask', function () { describe('Hide token', function () { it('hides the token when clicked', async function () { + await driver.clickElement(By.css('[data-testid="home__asset-tab"]')) + await driver.clickElement(By.css('.token-cell__ellipsis')) const byTokenMenuDropdownOption = By.css('.menu__item--clickable') diff --git a/test/e2e/permissions.spec.js b/test/e2e/permissions.spec.js index cfdcd22ee..4785b4fe8 100644 --- a/test/e2e/permissions.spec.js +++ b/test/e2e/permissions.spec.js @@ -85,8 +85,8 @@ describe('MetaMask', function () { await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`)) await driver.delay(regularDelayMs) - await driver.clickElement(By.css('.account-details__details-button')) - await driver.delay(regularDelayMs) + await driver.clickElement(By.css('[data-testid="account-options-menu-button"]')) + await driver.clickElement(By.css('[data-testid="account-options-menu__account-details"]')) }) it('gets the current accounts address', async function () { @@ -132,7 +132,8 @@ describe('MetaMask', function () { }) it('shows connected sites', async function () { - await driver.clickElement(By.xpath(`//button[contains(text(), 'Connected sites')]`)) + await driver.clickElement(By.css('[data-testid="account-options-menu-button"]')) + await driver.clickElement(By.css('[data-testid="account-options-menu__connected-sites"]')) await driver.findElement(By.xpath(`//h2[contains(text(), 'Connected sites')]`)) diff --git a/test/e2e/send-edit.spec.js b/test/e2e/send-edit.spec.js index d335d3a9a..d5b9f8e55 100644 --- a/test/e2e/send-edit.spec.js +++ b/test/e2e/send-edit.spec.js @@ -197,6 +197,7 @@ describe('Using MetaMask with an existing account', function () { }) it('finds the transaction in the transactions list', async function () { + await driver.clickElement(By.css('[data-testid="home__history-tab"]')) await driver.wait(async () => { const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item')) return confirmedTxes.length === 1 diff --git a/test/e2e/signature-request.spec.js b/test/e2e/signature-request.spec.js index de61d75f7..d76dbdfc9 100644 --- a/test/e2e/signature-request.spec.js +++ b/test/e2e/signature-request.spec.js @@ -120,7 +120,8 @@ describe('MetaMask', function () { }) it('gets the current accounts address', async function () { - await driver.clickElement(By.css('.account-details__details-button')) + await driver.clickElement(By.css('[data-testid="account-options-menu-button"]')) + await driver.clickElement(By.css('[data-testid="account-options-menu__account-details"]')) await driver.delay(regularDelayMs) const addressInput = await driver.findElement(By.css('.qr-ellip-address')) diff --git a/test/e2e/tests/simple-send.spec.js b/test/e2e/tests/simple-send.spec.js index 88f45b25b..d40ee8e8d 100644 --- a/test/e2e/tests/simple-send.spec.js +++ b/test/e2e/tests/simple-send.spec.js @@ -22,6 +22,7 @@ describe('MetaMask Browser Extension', function () { await amountField.sendKeys('1') await driver.clickElement(By.css('[data-testid="page-container-footer-next"]')) await driver.clickElement(By.css('[data-testid="page-container-footer-next"]')) + await driver.clickElement(By.css('[data-testid="home__history-tab"]')) await driver.findElement(By.css('.transaction-list-item')) }) }) diff --git a/test/integration/lib/tx-list-items.js b/test/integration/lib/tx-list-items.js deleted file mode 100644 index 0319276b9..000000000 --- a/test/integration/lib/tx-list-items.js +++ /dev/null @@ -1,67 +0,0 @@ -const reactTriggerChange = require('../../lib/react-trigger-change') -const { - queryAsync, - findAsync, -} = require('../../lib/util') -const fetchMockResponses = require('../../data/fetch-mocks.json') - -QUnit.module('tx list items') - -QUnit.test('renders list items successfully', (assert) => { - const done = assert.async() - runTxListItemsTest(assert).then(done).catch((err) => { - assert.notOk(err, `Error was thrown: ${err.stack}`) - done() - }) -}) - -global.ethQuery = global.ethQuery || {} -global.ethQuery.getTransactionCount = (_, cb) => { - cb(null, '0x4') -} - -async function runTxListItemsTest (assert) { - console.log('*** start runTxListItemsTest') - const selectState = await queryAsync($, 'select') - selectState.val('tx list items') - reactTriggerChange(selectState[0]) - - const realFetch = window.fetch.bind(window) - window.fetch = (...args) => { - if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') { - return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) }) - } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') { - return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) }) - } else if (args[0].match(/chromeextensionmm/)) { - return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) }) - } - return realFetch.fetch(...args) - } - - const metamaskLogo = await queryAsync($, '.app-header__logo-container') - assert.ok(metamaskLogo[0], 'metamask logo present') - metamaskLogo[0].click() - - const txListItems = await queryAsync($, '.transaction-list-item') - assert.equal(txListItems.length, 6, 'all tx list items are rendered') - - const unapprovedMsg = txListItems[0] - const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.transaction-list-item__status--unapproved') - assert.equal(unapprovedMsgDescription[0].textContent, 'Unapproved', 'unapprovedMsg has correct description') - - const approvedTx = txListItems[2] - const approvedTxRenderedStatus = await findAsync($(approvedTx), '.transaction-list-item__status--queued') - assert.equal(approvedTxRenderedStatus[0].textContent, 'Queued', 'approvedTx has correct label') - - const confirmedTokenTx1 = txListItems[4] - const confirmedTokenTx1Token = await findAsync($(confirmedTokenTx1), '.list-item__heading') - const confirmedTokenTx1Address = await findAsync($(confirmedTokenTx1), '.list-item__subheading') - assert.equal(confirmedTokenTx1Token[0].textContent, 'Send FTO ', 'Confirm token symbol is correct') - assert.equal(confirmedTokenTx1Address[0].textContent, 'Mar 29, 2018 · To: 0xe788...81a9', 'confirmedTokenTx has correct status') - - const confirmedTokenTx2 = txListItems[5] - const confirmedTokenTx2Address = await findAsync($(confirmedTokenTx2), '.list-item__subheading') - const confirmedTokenTx2Token = await findAsync($(confirmedTokenTx2), '.list-item__heading') - assert.equal(confirmedTokenTx2Token[0].textContent, 'Send FTT ', 'Confirm token symbol is correct') - assert.equal(confirmedTokenTx2Address[0].textContent, 'Mar 29, 2018 · To: 0xe788...81a9', 'confirmedTokenTx has correct status') -} diff --git a/ui/app/components/app/account-details/account-details.component.js b/ui/app/components/app/account-details/account-details.component.js deleted file mode 100644 index 172ea1868..000000000 --- a/ui/app/components/app/account-details/account-details.component.js +++ /dev/null @@ -1,106 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' -import classnames from 'classnames' -import Identicon from '../../ui/identicon' -import Tooltip from '../../ui/tooltip-v2' -import copyToClipboard from 'copy-to-clipboard' - -export default class AccountDetails extends Component { - static contextTypes = { - t: PropTypes.func.isRequired, - metricsEvent: PropTypes.func, - } - - static defaultProps = { - hideSidebar: () => {}, - showAccountDetailModal: () => {}, - } - - static propTypes = { - hideSidebar: PropTypes.func, - showAccountDetailModal: PropTypes.func, - showConnectedSites: PropTypes.func.isRequired, - label: PropTypes.string.isRequired, - checksummedAddress: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - } - - state = { - hasCopied: false, - copyToClipboardPressed: false, - } - - copyAddress () { - copyToClipboard(this.props.checksummedAddress) - this.context.metricsEvent({ - eventOpts: { - category: 'Navigation', - action: 'Home', - name: 'Copied Address', - }, - }) - this.setState({ hasCopied: true }) - setTimeout(() => this.setState({ hasCopied: false }), 3000) - } - - render () { - const { t } = this.context - - const { - hideSidebar, - showAccountDetailModal, - showConnectedSites, - label, - checksummedAddress, - name, - } = this.props - - const { - hasCopied, - copyToClipboardPressed, - } = this.state - - return ( -