2018-03-19 16:06:09 +01:00
|
|
|
const reactTriggerChange = require('../../lib/react-trigger-change')
|
2018-03-11 22:52:29 +01:00
|
|
|
const {
|
|
|
|
timeout,
|
|
|
|
queryAsync,
|
|
|
|
findAsync,
|
|
|
|
} = require('../../lib/util')
|
2018-01-30 02:24:53 +01:00
|
|
|
|
|
|
|
const PASSWORD = 'password123'
|
|
|
|
|
|
|
|
QUnit.module('new ui send flow')
|
|
|
|
|
|
|
|
QUnit.test('successful send flow', (assert) => {
|
|
|
|
const done = assert.async()
|
|
|
|
runSendFlowTest(assert).then(done).catch((err) => {
|
|
|
|
assert.notOk(err, `Error was thrown: ${err.stack}`)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
global.ethQuery = {
|
|
|
|
sendTransaction: () => {},
|
|
|
|
}
|
|
|
|
|
2018-03-26 15:30:54 +02:00
|
|
|
global.ethereumProvider = {}
|
|
|
|
|
2018-01-30 02:24:53 +01:00
|
|
|
async function runSendFlowTest(assert, done) {
|
|
|
|
console.log('*** start runSendFlowTest')
|
2018-03-11 22:52:29 +01:00
|
|
|
const selectState = await queryAsync($, 'select')
|
2018-01-30 02:24:53 +01:00
|
|
|
selectState.val('send new ui')
|
|
|
|
reactTriggerChange(selectState[0])
|
|
|
|
|
2018-03-26 07:19:42 +02:00
|
|
|
const sendScreenButton = await queryAsync($, 'button.btn-primary.hero-balance-button')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.ok(sendScreenButton[1], 'send screen button present')
|
|
|
|
sendScreenButton[1].click()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendTitle = await queryAsync($, '.page-container__title')
|
2018-02-07 06:07:00 +01:00
|
|
|
assert.equal(sendTitle[0].textContent, 'Send ETH', 'Send screen title is correct')
|
2018-01-30 02:24:53 +01:00
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendCopy = await queryAsync($, '.page-container__subtitle')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(sendCopy[0].textContent, 'Only send ETH to an Ethereum address.', 'Send screen has copy')
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendFromField = await queryAsync($, '.send-v2__form-field')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.ok(sendFromField[0], 'send screen has a from field')
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
let sendFromFieldItemAddress = await queryAsync($, '.account-list-item__account-name')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(sendFromFieldItemAddress[0].textContent, 'Send Account 4', 'send from field shows correct account name')
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendFromFieldItem = await queryAsync($, '.account-list-item')
|
|
|
|
sendFromFieldItem[0].click()
|
2018-01-30 02:24:53 +01:00
|
|
|
|
2018-03-12 02:52:27 +01:00
|
|
|
// this seems to fail if the firefox window is not in focus...
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendFromDropdownList = await queryAsync($, '.send-v2__from-dropdown__list')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(sendFromDropdownList.children().length, 4, 'send from dropdown shows all accounts')
|
|
|
|
sendFromDropdownList.children()[1].click()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
sendFromFieldItemAddress = await queryAsync($, '.account-list-item__account-name')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(sendFromFieldItemAddress[0].textContent, 'Send Account 2', 'send from field dropdown changes account name')
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
let sendToFieldInput = await queryAsync($, '.send-v2__to-autocomplete__input')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendToFieldInput[0].focus()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendToDropdownList = await queryAsync($, '.send-v2__from-dropdown__list')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(sendToDropdownList.children().length, 5, 'send to dropdown shows all accounts and address book accounts')
|
|
|
|
|
|
|
|
sendToDropdownList.children()[2].click()
|
|
|
|
|
|
|
|
const sendToAccountAddress = sendToFieldInput.val()
|
|
|
|
assert.equal(sendToAccountAddress, '0x2f8d4a878cfa04a6e60d46362f5644deab66572d', 'send to dropdown selects the correct address')
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendAmountField = await queryAsync($, '.send-v2__form-row:eq(2)')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendAmountField.find('.currency-display')[0].click()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendAmountFieldInput = await findAsync(sendAmountField, 'input:text')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendAmountFieldInput.val('5.1')
|
|
|
|
reactTriggerChange(sendAmountField.find('input')[0])
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
let errorMessage = await queryAsync($, '.send-v2__error')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(errorMessage[0].textContent, 'Insufficient funds.', 'send should render an insufficient fund error message')
|
|
|
|
|
|
|
|
sendAmountFieldInput.val('2.0')
|
|
|
|
reactTriggerChange(sendAmountFieldInput[0])
|
|
|
|
await timeout()
|
|
|
|
errorMessage = $('.send-v2__error')
|
|
|
|
assert.equal(errorMessage.length, 0, 'send should stop rendering amount error message after amount is corrected')
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendGasField = await queryAsync($, '.send-v2__gas-fee-display')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(
|
|
|
|
sendGasField.find('.currency-display__input-wrapper > input').val(),
|
|
|
|
'0.000198',
|
|
|
|
'send gas field should show estimated gas total'
|
|
|
|
)
|
|
|
|
assert.equal(
|
|
|
|
sendGasField.find('.currency-display__converted-value')[0].textContent,
|
|
|
|
'0.24 USD',
|
|
|
|
'send gas field should show estimated gas total converted to USD'
|
|
|
|
)
|
|
|
|
|
2018-03-14 15:58:26 +01:00
|
|
|
const sendGasOpenCustomizeModalButton = await queryAsync($, '.sliders-icon-container')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendGasOpenCustomizeModalButton[0].click()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const customizeGasModal = await queryAsync($, '.send-v2__customize-gas')
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.ok(customizeGasModal[0], 'should render the customize gas modal')
|
2018-02-07 06:07:00 +01:00
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const customizeGasPriceInput = (await queryAsync($, '.send-v2__gas-modal-card')).first().find('input')
|
2018-01-30 02:24:53 +01:00
|
|
|
customizeGasPriceInput.val(50)
|
|
|
|
reactTriggerChange(customizeGasPriceInput[0])
|
2018-03-11 22:52:29 +01:00
|
|
|
const customizeGasLimitInput = (await queryAsync($, '.send-v2__gas-modal-card')).last().find('input')
|
2018-01-30 02:24:53 +01:00
|
|
|
customizeGasLimitInput.val(60000)
|
|
|
|
reactTriggerChange(customizeGasLimitInput[0])
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const customizeGasSaveButton = await queryAsync($, '.send-v2__customize-gas__save')
|
2018-01-30 02:24:53 +01:00
|
|
|
customizeGasSaveButton[0].click()
|
|
|
|
|
|
|
|
assert.equal(
|
2018-03-11 22:52:29 +01:00
|
|
|
(await findAsync(sendGasField, '.currency-display__input-wrapper > input')).val(),
|
2018-01-30 02:24:53 +01:00
|
|
|
'0.003',
|
|
|
|
'send gas field should show customized gas total'
|
|
|
|
)
|
|
|
|
assert.equal(
|
2018-03-11 22:52:29 +01:00
|
|
|
(await findAsync(sendGasField, '.currency-display__converted-value'))[0].textContent,
|
2018-01-30 02:24:53 +01:00
|
|
|
'3.60 USD',
|
|
|
|
'send gas field should show customized gas total converted to USD'
|
|
|
|
)
|
|
|
|
|
2018-03-26 07:19:42 +02:00
|
|
|
const sendButton = await queryAsync($, 'button.btn-primary--lg.page-container__footer-button')
|
2018-02-07 06:07:00 +01:00
|
|
|
assert.equal(sendButton[0].textContent, 'Next', 'next button rendered')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendButton[0].click()
|
2018-03-11 22:52:29 +01:00
|
|
|
await timeout()
|
2018-01-30 02:24:53 +01:00
|
|
|
|
|
|
|
selectState.val('send edit')
|
|
|
|
reactTriggerChange(selectState[0])
|
|
|
|
|
2018-03-20 00:12:09 +01:00
|
|
|
const confirmFromName = (await queryAsync($, '.sender-to-recipient__sender-name')).first()
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(confirmFromName[0].textContent, 'Send Account 2', 'confirm screen should show correct from name')
|
|
|
|
|
2018-03-20 00:12:09 +01:00
|
|
|
const confirmToName = (await queryAsync($, '.sender-to-recipient__recipient-name')).last()
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(confirmToName[0].textContent, 'Send Account 3', 'confirm screen should show correct to name')
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const confirmScreenRows = await queryAsync($, '.confirm-screen-rows')
|
2018-03-14 15:58:26 +01:00
|
|
|
const confirmScreenGas = confirmScreenRows.find('.currency-display__converted-value')[0]
|
|
|
|
assert.equal(confirmScreenGas.textContent, '3.60 USD', 'confirm screen should show correct gas')
|
|
|
|
const confirmScreenTotal = confirmScreenRows.find('.confirm-screen-row-info')[2]
|
2018-01-30 02:24:53 +01:00
|
|
|
assert.equal(confirmScreenTotal.textContent, '2405.36 USD', 'confirm screen should show correct total')
|
|
|
|
|
2018-03-20 00:12:09 +01:00
|
|
|
const confirmScreenBackButton = await queryAsync($, '.page-container__back-button')
|
2018-01-30 02:24:53 +01:00
|
|
|
confirmScreenBackButton[0].click()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendFromFieldItemInEdit = await queryAsync($, '.account-list-item')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendFromFieldItemInEdit[0].click()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendFromDropdownListInEdit = await queryAsync($, '.send-v2__from-dropdown__list')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendFromDropdownListInEdit.children()[2].click()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendToFieldInputInEdit = await queryAsync($, '.send-v2__to-autocomplete__input')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendToFieldInputInEdit[0].focus()
|
|
|
|
sendToFieldInputInEdit.val('0xd85a4b6a394794842887b8284293d69163007bbb')
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const sendAmountFieldInEdit = await queryAsync($, '.send-v2__form-row:eq(2)')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendAmountFieldInEdit.find('.currency-display')[0].click()
|
|
|
|
|
|
|
|
const sendAmountFieldInputInEdit = sendAmountFieldInEdit.find('input:text')
|
|
|
|
sendAmountFieldInputInEdit.val('1.0')
|
|
|
|
reactTriggerChange(sendAmountFieldInputInEdit[0])
|
|
|
|
|
2018-03-26 07:19:42 +02:00
|
|
|
const sendButtonInEdit = await queryAsync($, '.btn-primary--lg.page-container__footer-button')
|
2018-02-07 06:07:00 +01:00
|
|
|
assert.equal(sendButtonInEdit[0].textContent, 'Next', 'next button in edit rendered')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendButtonInEdit[0].click()
|
|
|
|
|
|
|
|
// TODO: Need a way to mock background so that we can test correct transition from editing to confirm
|
|
|
|
selectState.val('confirm new ui')
|
|
|
|
reactTriggerChange(selectState[0])
|
2018-03-17 00:39:00 +01:00
|
|
|
const confirmScreenConfirmButton = await queryAsync($, '.btn-confirm.page-container__footer-button')
|
2018-01-30 02:24:53 +01:00
|
|
|
console.log(`+++++++++++++++++++++++++++++++= confirmScreenConfirmButton[0]`, confirmScreenConfirmButton[0]);
|
|
|
|
confirmScreenConfirmButton[0].click()
|
|
|
|
|
2018-03-11 22:52:29 +01:00
|
|
|
const txView = await queryAsync($, '.tx-view')
|
2018-01-30 02:24:53 +01:00
|
|
|
console.log(`++++++++++++++++++++++++++++++++ txView[0]`, txView[0]);
|
|
|
|
|
|
|
|
assert.ok(txView[0], 'Should return to the account details screen after confirming')
|
|
|
|
}
|