mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix send token tests in beta ui e2e tests.
This commit is contained in:
parent
bdf9cd8e3a
commit
f5d43404dc
@ -378,9 +378,8 @@ describe('MetaMask', function () {
|
|||||||
const transactions = await findElements(driver, By.css('.tx-list-item'))
|
const transactions = await findElements(driver, By.css('.tx-list-item'))
|
||||||
assert.equal(transactions.length, 1)
|
assert.equal(transactions.length, 1)
|
||||||
|
|
||||||
const txValues = await findElements(driver, By.css('.tx-list-value'))
|
const txValues = await findElement(driver, By.css('.tx-list-value'))
|
||||||
assert.equal(txValues.length, 1)
|
await driver.wait(until.elementTextMatches(txValues, /1\sETH/), 10000)
|
||||||
assert.equal(await txValues[0].getText(), '1 ETH')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -524,6 +523,8 @@ describe('MetaMask', function () {
|
|||||||
describe('Add a custom token from TokenFactory', () => {
|
describe('Add a custom token from TokenFactory', () => {
|
||||||
it('creates a new token', async () => {
|
it('creates a new token', async () => {
|
||||||
openNewPage(driver, 'https://tokenfactory.surge.sh/#/factory')
|
openNewPage(driver, 'https://tokenfactory.surge.sh/#/factory')
|
||||||
|
|
||||||
|
await delay(regularDelayMs * 10)
|
||||||
const [extension, tokenFactory] = await driver.getAllWindowHandles()
|
const [extension, tokenFactory] = await driver.getAllWindowHandles()
|
||||||
|
|
||||||
const [
|
const [
|
||||||
@ -552,12 +553,15 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
await driver.switchTo().window(tokenFactory)
|
await driver.switchTo().window(tokenFactory)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const tokenContactAddress = await driver.findElement(By.css('div > div > div:nth-child(2) > span:nth-child(3)'))
|
const tokenContactAddress = await driver.findElement(By.css('div > div > div:nth-child(2) > span:nth-child(3)'))
|
||||||
tokenAddress = await tokenContactAddress.getText()
|
tokenAddress = await tokenContactAddress.getText()
|
||||||
|
|
||||||
await driver.close()
|
await driver.close()
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
await loadExtension(driver, extensionId)
|
await loadExtension(driver, extensionId)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks on the Add Token button', async () => {
|
it('clicks on the Add Token button', async () => {
|
||||||
@ -641,6 +645,7 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const txValues = await findElements(driver, By.css('.tx-list-value'))
|
const txValues = await findElements(driver, By.css('.tx-list-value'))
|
||||||
assert.equal(txValues.length, 1)
|
assert.equal(txValues.length, 1)
|
||||||
|
await delay(regularDelayMs)
|
||||||
assert.equal(await txValues[0].getText(), '50 TST')
|
assert.equal(await txValues[0].getText(), '50 TST')
|
||||||
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
||||||
const tx = await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed|Failed/))
|
const tx = await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed|Failed/))
|
||||||
@ -684,16 +689,24 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.customize-gas-input'))
|
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.customize-gas-input'))
|
||||||
await gasPriceInput.clear()
|
await gasPriceInput.clear()
|
||||||
|
await delay(tinyDelayMs)
|
||||||
await gasPriceInput.sendKeys('10')
|
await gasPriceInput.sendKeys('10')
|
||||||
|
await delay(tinyDelayMs)
|
||||||
await gasLimitInput.clear()
|
await gasLimitInput.clear()
|
||||||
|
await delay(tinyDelayMs)
|
||||||
|
await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a'))
|
||||||
await gasLimitInput.sendKeys('60000')
|
await gasLimitInput.sendKeys('60000')
|
||||||
|
await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'e'))
|
||||||
|
if (process.env.SELENIUM_BROWSER === 'firefox') {
|
||||||
|
await gasLimitInput.sendKeys(Key.BACK_SPACE)
|
||||||
|
}
|
||||||
|
await delay(tinyDelayMs)
|
||||||
|
|
||||||
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
|
const save = await findElement(driver, By.css('.send-v2__customize-gas__save'))
|
||||||
await save.click()
|
await save.click()
|
||||||
await driver.wait(until.stalenessOf(gasModal))
|
await driver.wait(until.stalenessOf(gasModal))
|
||||||
|
|
||||||
const gasFeeInput = await findElement(driver, By.css('.currency-display__input'))
|
const gasFeeInput = await findElement(driver, By.css('.currency-display__input'))
|
||||||
await delay(regularDelayMs)
|
|
||||||
assert.equal(await gasFeeInput.getAttribute('value'), 0.0006)
|
assert.equal(await gasFeeInput.getAttribute('value'), 0.0006)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -22,12 +22,16 @@ function isValidInput (text) {
|
|||||||
return re.test(text)
|
return re.test(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeLeadingZeroes (str) {
|
||||||
|
return str.replace(/^0*(?=\d)/, '')
|
||||||
|
}
|
||||||
|
|
||||||
InputNumber.prototype.setValue = function (newValue) {
|
InputNumber.prototype.setValue = function (newValue) {
|
||||||
|
newValue = removeLeadingZeroes(newValue)
|
||||||
if (newValue && !isValidInput(newValue)) return
|
if (newValue && !isValidInput(newValue)) return
|
||||||
const { fixed, min = -1, max = Infinity, onChange } = this.props
|
const { fixed, min = -1, max = Infinity, onChange } = this.props
|
||||||
|
|
||||||
newValue = fixed ? newValue.toFixed(4) : newValue
|
newValue = fixed ? newValue.toFixed(4) : newValue
|
||||||
|
|
||||||
const newValueGreaterThanMin = conversionGTE(
|
const newValueGreaterThanMin = conversionGTE(
|
||||||
{ value: newValue || '0', fromNumericBase: 'dec' },
|
{ value: newValue || '0', fromNumericBase: 'dec' },
|
||||||
{ value: min, fromNumericBase: 'hex' },
|
{ value: min, fromNumericBase: 'hex' },
|
||||||
@ -47,7 +51,7 @@ InputNumber.prototype.setValue = function (newValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InputNumber.prototype.render = function () {
|
InputNumber.prototype.render = function () {
|
||||||
const { unitLabel, step = 1, placeholder, value = 0 } = this.props
|
const { unitLabel, step = 1, placeholder, value } = this.props
|
||||||
|
|
||||||
return h('div.customize-gas-input-wrapper', {}, [
|
return h('div.customize-gas-input-wrapper', {}, [
|
||||||
h('input', {
|
h('input', {
|
||||||
@ -63,11 +67,11 @@ InputNumber.prototype.render = function () {
|
|||||||
h('span.gas-tooltip-input-detail', {}, [unitLabel]),
|
h('span.gas-tooltip-input-detail', {}, [unitLabel]),
|
||||||
h('div.gas-tooltip-input-arrows', {}, [
|
h('div.gas-tooltip-input-arrows', {}, [
|
||||||
h('i.fa.fa-angle-up', {
|
h('i.fa.fa-angle-up', {
|
||||||
onClick: () => this.setValue(addCurrencies(value, step)),
|
onClick: () => this.setValue(addCurrencies(value, step, { toNumericBase: 'dec' })),
|
||||||
}),
|
}),
|
||||||
h('i.fa.fa-angle-down', {
|
h('i.fa.fa-angle-down', {
|
||||||
style: { cursor: 'pointer' },
|
style: { cursor: 'pointer' },
|
||||||
onClick: () => this.setValue(subtractCurrencies(value, step)),
|
onClick: () => this.setValue(subtractCurrencies(value, step, { toNumericBase: 'dec' })),
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
Loading…
Reference in New Issue
Block a user