mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Fix tests
This commit is contained in:
parent
4f6b53c1aa
commit
c4e75a7075
@ -6,6 +6,9 @@ module.exports = function(config) {
|
|||||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||||
basePath: process.cwd(),
|
basePath: process.cwd(),
|
||||||
|
|
||||||
|
// Uncomment to allow for longer timeouts
|
||||||
|
// browserNoActivityTimeout: 100000000,
|
||||||
|
|
||||||
browserConsoleLogOptions: {
|
browserConsoleLogOptions: {
|
||||||
terminal: false,
|
terminal: false,
|
||||||
},
|
},
|
||||||
|
@ -22,6 +22,11 @@ async function runAddTokenFlowTest (assert, done) {
|
|||||||
selectState.val('add token')
|
selectState.val('add token')
|
||||||
reactTriggerChange(selectState[0])
|
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
|
// Check that no tokens have been added
|
||||||
assert.ok($('.token-list-item').length === 0, 'no tokens added')
|
assert.ok($('.token-list-item').length === 0, 'no tokens added')
|
||||||
|
|
||||||
@ -31,14 +36,14 @@ async function runAddTokenFlowTest (assert, done) {
|
|||||||
addTokenButton[0].click()
|
addTokenButton[0].click()
|
||||||
|
|
||||||
// Verify Add Token screen
|
// Verify Add Token screen
|
||||||
let addTokenWrapper = await queryAsync($, '.add-token__wrapper')
|
let addTokenWrapper = await queryAsync($, '.page-container')
|
||||||
assert.ok(addTokenWrapper[0], 'add token wrapper renders')
|
assert.ok(addTokenWrapper[0], 'add token wrapper renders')
|
||||||
|
|
||||||
let addTokenTitle = await queryAsync($, '.add-token__header__title')
|
let addTokenTitle = await queryAsync($, '.page-container__title')
|
||||||
assert.equal(addTokenTitle[0].textContent, 'Add Tokens', 'add token title is correct')
|
assert.equal(addTokenTitle[0].textContent, 'Add Tokens', 'add token title is correct')
|
||||||
|
|
||||||
// Cancel Add Token
|
// Cancel Add Token
|
||||||
const cancelAddTokenButton = await queryAsync($, 'button.btn-secondary--lg.add-token__cancel-button')
|
const cancelAddTokenButton = await queryAsync($, 'button.btn-secondary--lg.page-container__footer-button')
|
||||||
assert.ok(cancelAddTokenButton[0], 'cancel add token button present')
|
assert.ok(cancelAddTokenButton[0], 'cancel add token button present')
|
||||||
cancelAddTokenButton.click()
|
cancelAddTokenButton.click()
|
||||||
|
|
||||||
@ -50,20 +55,22 @@ async function runAddTokenFlowTest (assert, done) {
|
|||||||
addTokenButton[0].click()
|
addTokenButton[0].click()
|
||||||
|
|
||||||
// Verify Add Token Screen
|
// Verify Add Token Screen
|
||||||
addTokenWrapper = await queryAsync($, '.add-token__wrapper')
|
addTokenWrapper = await queryAsync($, '.page-container')
|
||||||
addTokenTitle = await queryAsync($, '.add-token__header__title')
|
addTokenTitle = await queryAsync($, '.page-container__title')
|
||||||
assert.ok(addTokenWrapper[0], 'add token wrapper renders')
|
assert.ok(addTokenWrapper[0], 'add token wrapper renders')
|
||||||
assert.equal(addTokenTitle[0].textContent, 'Add Tokens', 'add token title is correct')
|
assert.equal(addTokenTitle[0].textContent, 'Add Tokens', 'add token title is correct')
|
||||||
|
|
||||||
// Search for token
|
// Search for token
|
||||||
const searchInput = await queryAsync($, 'input.add-token__input')
|
const searchInput = (await findAsync(addTokenWrapper, '#search-tokens'))[0]
|
||||||
searchInput.val('a')
|
searchInput.focus()
|
||||||
reactTriggerChange(searchInput[0])
|
await timeout(1000)
|
||||||
|
nativeInputValueSetter.call(searchInput, 'a')
|
||||||
|
searchInput.dispatchEvent(new Event('input', { bubbles: true}))
|
||||||
|
|
||||||
// Click token to add
|
// Click token to add
|
||||||
const tokenWrapper = await queryAsync($, 'div.add-token__token-wrapper')
|
const tokenWrapper = await queryAsync($, 'div.token-list__token')
|
||||||
assert.ok(tokenWrapper[0], 'token found')
|
assert.ok(tokenWrapper[0], 'token found')
|
||||||
const tokenImageProp = tokenWrapper.find('.add-token__token-icon').css('background-image')
|
const tokenImageProp = tokenWrapper.find('.token-list__token-icon').css('background-image')
|
||||||
const tokenImageUrl = tokenImageProp.slice(5, -2)
|
const tokenImageUrl = tokenImageProp.slice(5, -2)
|
||||||
tokenWrapper[0].click()
|
tokenWrapper[0].click()
|
||||||
|
|
||||||
@ -73,11 +80,8 @@ async function runAddTokenFlowTest (assert, done) {
|
|||||||
nextButton[0].click()
|
nextButton[0].click()
|
||||||
|
|
||||||
// Confirm Add token
|
// Confirm Add token
|
||||||
assert.equal(
|
const confirmAddToken = await queryAsync($, '.confirm-add-token')
|
||||||
$('.add-token__description')[0].textContent,
|
assert.ok(confirmAddToken[0], 'confirm add token rendered')
|
||||||
'Token balance(s)',
|
|
||||||
'confirm add token rendered'
|
|
||||||
)
|
|
||||||
assert.ok($('button.btn-primary--lg')[0], 'confirm add token button found')
|
assert.ok($('button.btn-primary--lg')[0], 'confirm add token button found')
|
||||||
$('button.btn-primary--lg')[0].click()
|
$('button.btn-primary--lg')[0].click()
|
||||||
|
|
||||||
@ -91,39 +95,46 @@ async function runAddTokenFlowTest (assert, done) {
|
|||||||
assert.ok(addTokenButton[0], 'add token button present')
|
assert.ok(addTokenButton[0], 'add token button present')
|
||||||
addTokenButton[0].click()
|
addTokenButton[0].click()
|
||||||
|
|
||||||
const addTokenTabs = await queryAsync($, '.add-token__header__tabs__tab')
|
addTokenWrapper = await queryAsync($, '.page-container')
|
||||||
|
const addTokenTabs = await queryAsync($, '.page-container__tab')
|
||||||
assert.equal(addTokenTabs.length, 2, 'expected number of tabs')
|
assert.equal(addTokenTabs.length, 2, 'expected number of tabs')
|
||||||
assert.equal(addTokenTabs[1].textContent, 'Custom Token', 'Custom Token tab present')
|
assert.equal(addTokenTabs[1].textContent, 'Custom Token', 'Custom Token tab present')
|
||||||
assert.ok(addTokenTabs[1], 'add custom token tab present')
|
assert.ok(addTokenTabs[1], 'add custom token tab present')
|
||||||
addTokenTabs[1].click()
|
addTokenTabs[1].click()
|
||||||
|
await timeout(1000)
|
||||||
|
|
||||||
// Input token contract address
|
// Input token contract address
|
||||||
const customInput = await queryAsync($, 'input.add-token__add-custom-input')
|
const customInput = (await findAsync(addTokenWrapper, '#custom-address'))[0]
|
||||||
customInput.val('0x177af043D3A1Aed7cc5f2397C70248Fc6cDC056c')
|
customInput.focus()
|
||||||
reactTriggerChange(customInput[0])
|
await timeout(1000)
|
||||||
|
nativeInputValueSetter.call(customInput, '0x177af043D3A1Aed7cc5f2397C70248Fc6cDC056c')
|
||||||
|
customInput.dispatchEvent(new Event('input', { bubbles: true}))
|
||||||
|
|
||||||
|
|
||||||
// Click Next button
|
// Click Next button
|
||||||
nextButton = await queryAsync($, 'button.btn-primary--lg')
|
// nextButton = await queryAsync($, 'button.btn-primary--lg')
|
||||||
assert.equal(nextButton[0].textContent, 'Next', 'next button rendered')
|
// assert.equal(nextButton[0].textContent, 'Next', 'next button rendered')
|
||||||
nextButton[0].click()
|
// nextButton[0].click()
|
||||||
|
|
||||||
// Verify symbol length error since contract address won't return symbol
|
// // Verify symbol length error since contract address won't return symbol
|
||||||
const errorMessage = await queryAsync($, '.add-token__add-custom-error-message')
|
const errorMessage = await queryAsync($, '#custom-symbol-helper-text')
|
||||||
assert.ok(errorMessage[0], 'error rendered')
|
assert.ok(errorMessage[0], 'error rendered')
|
||||||
|
|
||||||
$('button.btn-secondary--lg')[0].click()
|
$('button.btn-secondary--lg')[0].click()
|
||||||
|
|
||||||
// // Confirm Add token
|
// await timeout(100000)
|
||||||
|
|
||||||
|
// Confirm Add token
|
||||||
// assert.equal(
|
// assert.equal(
|
||||||
// $('.add-token__description')[0].textContent,
|
// $('.page-container__subtitle')[0].textContent,
|
||||||
// 'Would you like to add these tokens?',
|
// 'Would you like to add these tokens?',
|
||||||
// 'confirm add token rendered'
|
// 'confirm add token rendered'
|
||||||
// )
|
// )
|
||||||
// assert.ok($('button.btn-primary--lg')[0], 'confirm add token button found')
|
// assert.ok($('button.btn-primary--lg')[0], 'confirm add token button found')
|
||||||
// $('button.btn-primary--lg')[0].click()
|
// $('button.btn-primary--lg')[0].click()
|
||||||
|
|
||||||
// // Verify added token image
|
// Verify added token image
|
||||||
// heroBalance = await queryAsync($, '.hero-balance')
|
heroBalance = await queryAsync($, '.hero-balance')
|
||||||
// assert.ok(heroBalance, 'rendered hero balance')
|
assert.ok(heroBalance, 'rendered hero balance')
|
||||||
// assert.ok(heroBalance.find('.identicon')[0], 'token added')
|
assert.ok(heroBalance.find('.identicon')[0], 'token added')
|
||||||
}
|
}
|
||||||
|
@ -139,17 +139,12 @@ class AddToken extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async attemptToAutoFillTokenParams (address) {
|
async attemptToAutoFillTokenParams (address) {
|
||||||
const { symbol, decimals } = await this.tokenInfoGetter(address)
|
const { symbol = '', decimals = 0 } = await this.tokenInfoGetter(address)
|
||||||
|
|
||||||
if (symbol && decimals) {
|
const autoFilled = Boolean(symbol && decimals)
|
||||||
this.setState({
|
this.setState({ autoFilled })
|
||||||
customSymbol: symbol,
|
this.handleCustomSymbolChange(symbol || '')
|
||||||
customDecimals: decimals,
|
this.handleCustomDecimalsChange(decimals)
|
||||||
customSymbolError: null,
|
|
||||||
customDecimalsError: null,
|
|
||||||
autoFilled: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCustomAddressChange (value) {
|
handleCustomAddressChange (value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user