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-05-14 15:30:50 +02:00
|
|
|
async function customizeGas (assert, price, limit, ethFee, usdFee) {
|
|
|
|
const sendGasOpenCustomizeModalButton = await queryAsync($, '.sliders-icon-container')
|
|
|
|
sendGasOpenCustomizeModalButton[0].click()
|
|
|
|
|
|
|
|
const customizeGasModal = await queryAsync($, '.send-v2__customize-gas')
|
|
|
|
assert.ok(customizeGasModal[0], 'should render the customize gas modal')
|
|
|
|
|
|
|
|
const customizeGasPriceInput = (await queryAsync($, '.send-v2__gas-modal-card')).first().find('input')
|
|
|
|
customizeGasPriceInput.val(price)
|
|
|
|
reactTriggerChange(customizeGasPriceInput[0])
|
|
|
|
const customizeGasLimitInput = (await queryAsync($, '.send-v2__gas-modal-card')).last().find('input')
|
|
|
|
customizeGasLimitInput.val(limit)
|
|
|
|
reactTriggerChange(customizeGasLimitInput[0])
|
|
|
|
|
|
|
|
const customizeGasSaveButton = await queryAsync($, '.send-v2__customize-gas__save')
|
|
|
|
customizeGasSaveButton[0].click()
|
|
|
|
const sendGasField = await queryAsync($, '.send-v2__gas-fee-display')
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
(await findAsync(sendGasField, '.currency-display__input-wrapper > input')).val(),
|
|
|
|
ethFee,
|
|
|
|
'send gas field should show customized gas total'
|
|
|
|
)
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
(await findAsync(sendGasField, '.currency-display__converted-value'))[0].textContent,
|
|
|
|
usdFee,
|
|
|
|
'send gas field should show customized gas total converted to USD'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
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-04-06 11:04:39 +02: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-05-31 16:37:23 +02:00
|
|
|
const sendAmountFieldInput = await findAsync(sendAmountField, '.currency-display__input')
|
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(),
|
2018-06-18 19:50:16 +02:00
|
|
|
'0.000021',
|
2018-01-30 02:24:53 +01:00
|
|
|
'send gas field should show estimated gas total'
|
|
|
|
)
|
|
|
|
assert.equal(
|
|
|
|
sendGasField.find('.currency-display__converted-value')[0].textContent,
|
2018-06-18 19:50:16 +02:00
|
|
|
'$0.03 USD',
|
2018-01-30 02:24:53 +01:00
|
|
|
'send gas field should show estimated gas total converted to USD'
|
|
|
|
)
|
|
|
|
|
2018-05-14 15:30:50 +02:00
|
|
|
await customizeGas(assert, 0, 21000, '0', '$0.00 USD')
|
2018-05-31 16:38:11 +02:00
|
|
|
await customizeGas(assert, 500, 60000, '0.03', '$36.03 USD')
|
2018-01-30 02:24:53 +01:00
|
|
|
|
2018-05-31 01:17:40 +02:00
|
|
|
const sendButton = await queryAsync($, 'button.btn-primary.btn--large.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]
|
2018-04-09 23:52:07 +02:00
|
|
|
assert.equal(confirmScreenGas.textContent, '$3.60 USD', 'confirm screen should show correct gas')
|
2018-03-14 15:58:26 +01:00
|
|
|
const confirmScreenTotal = confirmScreenRows.find('.confirm-screen-row-info')[2]
|
2018-04-09 23:52:07 +02:00
|
|
|
assert.equal(confirmScreenTotal.textContent, '$2,405.36 USD', 'confirm screen should show correct total')
|
2018-01-30 02:24:53 +01:00
|
|
|
|
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()
|
|
|
|
|
2018-05-31 19:23:38 +02:00
|
|
|
const sendAmountFieldInputInEdit = sendAmountFieldInEdit.find('.currency-display__input')
|
2018-01-30 02:24:53 +01:00
|
|
|
sendAmountFieldInputInEdit.val('1.0')
|
|
|
|
reactTriggerChange(sendAmountFieldInputInEdit[0])
|
|
|
|
|
2018-05-31 01:17:40 +02:00
|
|
|
const sendButtonInEdit = await queryAsync($, '.btn-primary.btn--large.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
|
|
|
|
2018-04-06 11:04:39 +02:00
|
|
|
selectState.val('send new ui')
|
2018-01-30 02:24:53 +01:00
|
|
|
reactTriggerChange(selectState[0])
|
|
|
|
|
2018-05-31 01:17:40 +02:00
|
|
|
const cancelButtonInEdit = await queryAsync($, '.btn-default.btn--large.page-container__footer-button')
|
2018-04-06 11:04:39 +02:00
|
|
|
cancelButtonInEdit[0].click()
|
|
|
|
// 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])
|
|
|
|
|
|
|
|
|
|
|
|
// const confirmScreenConfirmButton = await queryAsync($, '.btn-confirm.page-container__footer-button')
|
|
|
|
// console.log(`+++++++++++++++++++++++++++++++= confirmScreenConfirmButton[0]`, confirmScreenConfirmButton[0]);
|
|
|
|
// confirmScreenConfirmButton[0].click()
|
|
|
|
|
|
|
|
// await timeout(10000000)
|
|
|
|
|
|
|
|
// const txView = await queryAsync($, '.tx-view')
|
|
|
|
// console.log(`++++++++++++++++++++++++++++++++ txView[0]`, txView[0]);
|
2018-01-30 02:24:53 +01:00
|
|
|
|
2018-04-06 11:04:39 +02:00
|
|
|
// assert.ok(txView[0], 'Should return to the account details screen after confirming')
|
2018-01-30 02:24:53 +01:00
|
|
|
}
|