Merge pull request #5536 from whymarrh/add-token-help

Add clarifying text to the "Add Token" button
feature/default_network_editable
Whymarrh Whitby 6 years ago committed by GitHub
commit 03b0929a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/_locales/en/messages.json
  2. 4
      test/e2e/beta/metamask-beta-ui.spec.js
  3. 140
      test/integration/lib/add-token.js
  4. 34
      ui/app/components/add-token-button/add-token-button.component.js
  5. 1
      ui/app/components/add-token-button/index.js
  6. 26
      ui/app/components/add-token-button/index.scss
  7. 2
      ui/app/components/index.scss
  8. 30
      ui/app/components/wallet-view.js
  9. 12
      ui/app/css/itcss/components/newui-sections.scss

@ -140,6 +140,9 @@
"clickCopy": {
"message": "Click to Copy"
},
"clickToAdd": {
"message": "Click on $1 to add them to your account"
},
"close": {
"message": "Close"
},
@ -641,6 +644,9 @@
"min": {
"message": "Minimum"
},
"missingYourTokens": {
"message": "Don't see your tokens?"
},
"myAccounts": {
"message": "My Accounts"
},

@ -662,7 +662,7 @@ describe('MetaMask', function () {
})
it('clicks on the Add Token button', async () => {
const addToken = await driver.findElement(By.css('.wallet-view__add-token-button'))
const addToken = await driver.findElement(By.xpath(`//div[contains(text(), 'Add Token')]`))
await addToken.click()
await delay(regularDelayMs)
})
@ -1002,7 +1002,7 @@ describe('MetaMask', function () {
describe('Add existing token using search', () => {
it('clicks on the Add Token button', async () => {
const addToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Add Token')]`))
const addToken = await findElement(driver, By.xpath(`//div[contains(text(), 'Add Token')]`))
await addToken.click()
await delay(regularDelayMs)
})

@ -1,140 +0,0 @@
const reactTriggerChange = require('react-trigger-change')
const {
timeout,
queryAsync,
findAsync,
} = require('../../lib/util')
QUnit.module('Add token flow')
QUnit.test('successful add token flow', (assert) => {
const done = assert.async()
runAddTokenFlowTest(assert)
.then(done)
.catch(err => {
assert.notOk(err, `Error was thrown: ${err.stack}`)
done()
})
})
async function runAddTokenFlowTest (assert, done) {
const selectState = await queryAsync($, 'select')
selectState.val('add token')
reactTriggerChange(selectState[0])
// Used to set values on TextField input component
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
window.HTMLInputElement.prototype, 'value'
).set
// Check that no tokens have been added
assert.ok($('.token-list-item').length === 0, 'no tokens added')
// Go to Add Token screen
let addTokenButton = await queryAsync($, 'button.btn-primary.wallet-view__add-token-button')
assert.ok(addTokenButton[0], 'add token button present')
addTokenButton[0].click()
// Verify Add Token screen
let addTokenWrapper = await queryAsync($, '.page-container')
assert.ok(addTokenWrapper[0], 'add token wrapper renders')
let addTokenTitle = await queryAsync($, '.page-container__title')
assert.equal(addTokenTitle[0].textContent, 'Add Tokens', 'add token title is correct')
// Cancel Add Token
const cancelAddTokenButton = await queryAsync($, 'button.btn-default.btn--large.page-container__footer-button')
assert.ok(cancelAddTokenButton[0], 'cancel add token button present')
cancelAddTokenButton.click()
assert.ok($('.wallet-view')[0], 'cancelled and returned to account detail wallet view')
// Return to Add Token Screen
addTokenButton = await queryAsync($, 'button.btn-primary.wallet-view__add-token-button')
assert.ok(addTokenButton[0], 'add token button present')
addTokenButton[0].click()
// Verify Add Token Screen
addTokenWrapper = await queryAsync($, '.page-container')
addTokenTitle = await queryAsync($, '.page-container__title')
assert.ok(addTokenWrapper[0], 'add token wrapper renders')
assert.equal(addTokenTitle[0].textContent, 'Add Tokens', 'add token title is correct')
// Search for token
const searchInput = (await findAsync(addTokenWrapper, '#search-tokens'))[0]
searchInput.focus()
await timeout(1000)
nativeInputValueSetter.call(searchInput, 'a')
searchInput.dispatchEvent(new Event('input', { bubbles: true}))
// Click token to add
const tokenWrapper = await queryAsync($, 'div.token-list__token')
assert.ok(tokenWrapper[0], 'token found')
const tokenImageProp = tokenWrapper.find('.token-list__token-icon').css('background-image')
const tokenImageUrl = tokenImageProp.slice(5, -2)
tokenWrapper[0].click()
// Click Next button
const nextButton = await queryAsync($, 'button.btn-primary.btn--large')
assert.equal(nextButton[0].textContent, 'Next', 'next button rendered')
nextButton[0].click()
// Confirm Add token
const confirmAddToken = await queryAsync($, '.confirm-add-token')
assert.ok(confirmAddToken[0], 'confirm add token rendered')
assert.ok($('button.btn-primary.btn--large')[0], 'confirm add token button found')
$('button.btn-primary.btn--large')[0].click()
// Verify added token image
let heroBalance = await queryAsync($, '.transaction-view-balance__balance-container')
assert.ok(heroBalance, 'rendered hero balance')
assert.ok(tokenImageUrl.indexOf(heroBalance.find('img').attr('src')) > -1, 'token added')
// Return to Add Token Screen
addTokenButton = await queryAsync($, 'button.btn-primary.wallet-view__add-token-button')
assert.ok(addTokenButton[0], 'add token button present')
addTokenButton[0].click()
addTokenWrapper = await queryAsync($, '.page-container')
const addTokenTabs = await queryAsync($, '.page-container__tab')
assert.equal(addTokenTabs.length, 2, 'expected number of tabs')
assert.equal(addTokenTabs[1].textContent, 'Custom Token', 'Custom Token tab present')
assert.ok(addTokenTabs[1], 'add custom token tab present')
addTokenTabs[1].click()
await timeout(1000)
// Input token contract address
const customInput = (await findAsync(addTokenWrapper, '#custom-address'))[0]
customInput.focus()
await timeout(1000)
nativeInputValueSetter.call(customInput, '0x177af043D3A1Aed7cc5f2397C70248Fc6cDC056c')
customInput.dispatchEvent(new Event('input', { bubbles: true}))
// Click Next button
// nextButton = await queryAsync($, 'button.btn-primary--lg')
// assert.equal(nextButton[0].textContent, 'Next', 'next button rendered')
// nextButton[0].click()
// // Verify symbol length error since contract address won't return symbol
const errorMessage = await queryAsync($, '#custom-symbol-helper-text')
assert.ok(errorMessage[0], 'error rendered')
$('button.btn-default.btn--large')[0].click()
// await timeout(100000)
// Confirm Add token
// assert.equal(
// $('.page-container__subtitle')[0].textContent,
// 'Would you like to add these tokens?',
// 'confirm add token rendered'
// )
// assert.ok($('button.btn-primary--lg')[0], 'confirm add token button found')
// $('button.btn-primary--lg')[0].click()
// Verify added token image
heroBalance = await queryAsync($, '.transaction-view-balance__balance-container')
assert.ok(heroBalance, 'rendered hero balance')
assert.ok(heroBalance.find('.identicon')[0], 'token added')
}

@ -0,0 +1,34 @@
import PropTypes from 'prop-types'
import React, {PureComponent} from 'react'
export default class AddTokenButton extends PureComponent {
static contextTypes = {
t: PropTypes.func.isRequired,
}
static defaultProps = {
onClick: () => {},
}
static propTypes = {
onClick: PropTypes.func,
}
render () {
const { t } = this.context
const { onClick } = this.props
return (
<div className="add-token-button">
<h1 className="add-token-button__help-header">{t('missingYourTokens')}</h1>
<p className="add-token-button__help-desc">{t('clickToAdd', [t('addToken')])}</p>
<div
className="add-token-button__button"
onClick={onClick}
>
{t('addToken')}
</div>
</div>
)
}
}

@ -0,0 +1 @@
export { default } from './add-token-button.component'

@ -0,0 +1,26 @@
.add-token-button {
display: flex;
flex-direction: column;
color: lighten($scorpion, 25%);
width: 185px;
margin: 36px auto;
text-align: center;
&__help-header {
font-weight: bold;
font-size: 1rem;
}
&__help-desc {
font-size: 0.75rem;
margin-top: 1rem;
}
&__button {
font-size: 0.75rem;
margin: 1rem;
text-transform: uppercase;
color: $curious-blue;
cursor: pointer;
}
}

@ -1,5 +1,7 @@
@import './app-header/index';
@import './add-token-button/index';
@import './button-group/index';
@import './card/index';

@ -17,7 +17,7 @@ const TokenList = require('./token-list')
const selectors = require('../selectors')
const { ADD_TOKEN_ROUTE } = require('../routes')
import Button from './button'
import AddTokenButton from './add-token-button'
module.exports = compose(
withRouter,
@ -100,15 +100,30 @@ WalletView.prototype.renderWalletBalance = function () {
])
}
WalletView.prototype.renderAddToken = function () {
const {
sidebarOpen,
hideSidebar,
history,
} = this.props
return h(AddTokenButton, {
onClick () {
history.push(ADD_TOKEN_ROUTE)
if (sidebarOpen) {
hideSidebar()
}
},
})
}
WalletView.prototype.render = function () {
const {
responsiveDisplayClassname,
selectedAddress,
keyrings,
showAccountDetailModal,
sidebarOpen,
hideSidebar,
history,
identities,
} = this.props
// temporary logs + fake extra wallets
@ -201,14 +216,7 @@ WalletView.prototype.render = function () {
h(TokenList),
h(Button, {
type: 'primary',
className: 'wallet-view__add-token-button',
onClick: () => {
history.push(ADD_TOKEN_ROUTE)
sidebarOpen && hideSidebar()
},
}, this.context.t('addToken')),
this.renderAddToken(),
])
}

@ -120,18 +120,6 @@ $wallet-view-bg: $alabaster;
}
}
}
&__add-token-button {
flex: 0 0 auto;
margin: 36px auto;
background: none;
transition: border-color .3s ease;
width: 150px;
&:hover {
border-color: $curious-blue;
}
}
}
@media screen and (min-width: 576px) {

Loading…
Cancel
Save