diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/data/mock-state.json | 3 | ||||
-rw-r--r-- | test/e2e/from-import-ui.spec.js | 9 | ||||
-rw-r--r-- | test/e2e/metamask-responsive-ui.spec.js | 9 | ||||
-rw-r--r-- | test/e2e/metamask-ui.spec.js | 65 | ||||
-rwxr-xr-x | test/e2e/run-all.sh | 8 | ||||
-rw-r--r-- | test/e2e/send-edit.spec.js | 288 | ||||
-rw-r--r-- | test/integration/lib/send-new-ui.js | 168 | ||||
-rw-r--r-- | test/unit/ui/app/actions.spec.js | 2 | ||||
-rw-r--r-- | test/unit/ui/app/reducers/metamask.spec.js | 22 |
9 files changed, 391 insertions, 183 deletions
diff --git a/test/data/mock-state.json b/test/data/mock-state.json index 671697182..122945ec1 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -119,7 +119,8 @@ "addressBook": [ { "address": "0xc42edfcc21ed14dda456aa0756c153f7985d8813", - "name": "" + "name": "", + "chainId": 4 } ], "selectedTokenAddress": "0x108cf70c7d384c552f42c07c41c0e1e46d77ea0d", diff --git a/test/e2e/from-import-ui.spec.js b/test/e2e/from-import-ui.spec.js index 31a858cf1..82e811c86 100644 --- a/test/e2e/from-import-ui.spec.js +++ b/test/e2e/from-import-ui.spec.js @@ -255,9 +255,14 @@ describe('Using MetaMask with an existing account', function () { await sendButton.click() await delay(regularDelayMs) - const inputAddress = await findElement(driver, By.css('input[placeholder="Recipient Address"]')) - const inputAmount = await findElement(driver, By.css('.unit-input__input')) + const inputAddress = await findElement(driver, By.css('input[placeholder="Search, public address (0x), or ENS"]')) await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + + const recipientRow = await findElement(driver, By.css('.send__select-recipient-wrapper__group-item')) + await recipientRow.click() + await delay(regularDelayMs) + + const inputAmount = await findElement(driver, By.css('.unit-input__input')) await inputAmount.sendKeys('1') // Set the gas limit diff --git a/test/e2e/metamask-responsive-ui.spec.js b/test/e2e/metamask-responsive-ui.spec.js index 007b5cbf6..720cac333 100644 --- a/test/e2e/metamask-responsive-ui.spec.js +++ b/test/e2e/metamask-responsive-ui.spec.js @@ -276,9 +276,14 @@ describe('MetaMask', function () { await sendButton.click() await delay(regularDelayMs) - const inputAddress = await findElement(driver, By.css('input[placeholder="Recipient Address"]')) - const inputAmount = await findElement(driver, By.css('.unit-input__input')) + const inputAddress = await findElement(driver, By.css('input[placeholder="Search, public address (0x), or ENS"]')) await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + + const recipientRow = await findElement(driver, By.css('.send__select-recipient-wrapper__group-item')) + await recipientRow.click() + await delay(regularDelayMs) + + const inputAmount = await findElement(driver, By.css('.unit-input__input')) await inputAmount.sendKeys('1') const inputValue = await inputAmount.getAttribute('value') diff --git a/test/e2e/metamask-ui.spec.js b/test/e2e/metamask-ui.spec.js index f9f52670b..006d8af60 100644 --- a/test/e2e/metamask-ui.spec.js +++ b/test/e2e/metamask-ui.spec.js @@ -322,12 +322,44 @@ describe('MetaMask', function () { await sendButton.click() await delay(regularDelayMs) - const inputAddress = await findElement(driver, By.css('input[placeholder="Recipient Address"]')) - const inputAmount = await findElement(driver, By.css('.unit-input__input')) + const inputAddress = await findElement(driver, By.css('input[placeholder="Search, public address (0x), or ENS"]')) await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + + const recipientRow = await findElement(driver, By.css('.send__select-recipient-wrapper__group-item')) + await recipientRow.click() + await delay(regularDelayMs) + + const inputAmount = await findElement(driver, By.css('.unit-input__input')) + await inputAmount.sendKeys('1000') + + const errorAmount = await findElement(driver, By.css('.send-v2__error-amount')) + assert.equal(await errorAmount.getText(), 'Insufficient funds.', 'send screen should render an insufficient fund error message') + + await inputAmount.sendKeys(Key.BACK_SPACE) + await delay(50) + await inputAmount.sendKeys(Key.BACK_SPACE) + await delay(50) + await inputAmount.sendKeys(Key.BACK_SPACE) + await delay(tinyDelayMs) + + await assertElementNotPresent(webdriver, driver, By.css('.send-v2__error-amount')) + + const amountMax = await findElement(driver, By.css('.send-v2__amount-max')) + await amountMax.click() + + assert.equal(await inputAmount.isEnabled(), false) + + let inputValue = await inputAmount.getAttribute('value') + + assert(Number(inputValue) > 99) + + await amountMax.click() + + assert.equal(await inputAmount.isEnabled(), true) + await inputAmount.sendKeys('1') - const inputValue = await inputAmount.getAttribute('value') + inputValue = await inputAmount.getAttribute('value') assert.equal(inputValue, '1') await delay(regularDelayMs) @@ -360,9 +392,14 @@ describe('MetaMask', function () { await sendButton.click() await delay(regularDelayMs) - const inputAddress = await findElement(driver, By.css('input[placeholder="Recipient Address"]')) - const inputAmount = await findElement(driver, By.css('.unit-input__input')) + const inputAddress = await findElement(driver, By.css('input[placeholder="Search, public address (0x), or ENS"]')) await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + + const recipientRow = await findElement(driver, By.css('.send__select-recipient-wrapper__group-item')) + await recipientRow.click() + await delay(regularDelayMs) + + const inputAmount = await findElement(driver, By.css('.unit-input__input')) await inputAmount.sendKeys('1') const inputValue = await inputAmount.getAttribute('value') @@ -402,9 +439,14 @@ describe('MetaMask', function () { await sendButton.click() await delay(regularDelayMs) - const inputAddress = await findElement(driver, By.css('input[placeholder="Recipient Address"]')) - const inputAmount = await findElement(driver, By.css('.unit-input__input')) + const inputAddress = await findElement(driver, By.css('input[placeholder="Search, public address (0x), or ENS"]')) await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + + const recipientRow = await findElement(driver, By.css('.send__select-recipient-wrapper__group-item')) + await recipientRow.click() + await delay(regularDelayMs) + + const inputAmount = await findElement(driver, By.css('.unit-input__input')) await inputAmount.sendKeys('1') const inputValue = await inputAmount.getAttribute('value') @@ -1005,9 +1047,14 @@ describe('MetaMask', function () { await sendButton.click() await delay(regularDelayMs) - const inputAddress = await findElement(driver, By.css('input[placeholder="Recipient Address"]')) - const inputAmount = await findElement(driver, By.css('.unit-input__input')) + const inputAddress = await findElement(driver, By.css('input[placeholder="Search, public address (0x), or ENS"]')) await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + + const recipientRow = await findElement(driver, By.css('.send__select-recipient-wrapper__group-item')) + await recipientRow.click() + await delay(regularDelayMs) + + const inputAmount = await findElement(driver, By.css('.unit-input__input')) await inputAmount.sendKeys('1') // Set the gas limit diff --git a/test/e2e/run-all.sh b/test/e2e/run-all.sh index 0ffa06735..b527f0025 100755 --- a/test/e2e/run-all.sh +++ b/test/e2e/run-all.sh @@ -31,3 +31,11 @@ concurrently --kill-others \ --success first \ 'yarn ganache:start' \ 'sleep 5 && mocha test/e2e/from-import-ui.spec' + +export GANACHE_ARGS="$GANACHE_ARGS --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" +concurrently --kill-others \ + --names 'ganache,e2e' \ + --prefix '[{time}][{name}]' \ + --success first \ + 'npm run ganache:start' \ + 'sleep 5 && mocha test/e2e/send-edit.spec' diff --git a/test/e2e/send-edit.spec.js b/test/e2e/send-edit.spec.js new file mode 100644 index 000000000..b04e52f7f --- /dev/null +++ b/test/e2e/send-edit.spec.js @@ -0,0 +1,288 @@ +const path = require('path') +const assert = require('assert') +const webdriver = require('selenium-webdriver') +const { By, Key, until } = webdriver +const { + delay, + buildChromeWebDriver, + buildFirefoxWebdriver, + installWebExt, + getExtensionIdChrome, + getExtensionIdFirefox, +} = require('./func') +const { + checkBrowserForConsoleErrors, + closeAllWindowHandlesExcept, + verboseReportOnFailure, + findElement, + findElements, +} = require('./helpers') +const fetchMockResponses = require('./fetch-mocks.js') + + +describe('Using MetaMask with an existing account', function () { + let extensionId + let driver + + const testSeedPhrase = 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress' + const tinyDelayMs = 200 + const regularDelayMs = 1000 + const largeDelayMs = regularDelayMs * 2 + + this.timeout(0) + this.bail(true) + + before(async function () { + let extensionUrl + switch (process.env.SELENIUM_BROWSER) { + case 'chrome': { + const extensionPath = path.resolve('dist/chrome') + driver = buildChromeWebDriver(extensionPath) + extensionId = await getExtensionIdChrome(driver) + await delay(regularDelayMs) + extensionUrl = `chrome-extension://${extensionId}/home.html` + break + } + case 'firefox': { + const extensionPath = path.resolve('dist/firefox') + driver = buildFirefoxWebdriver() + await installWebExt(driver, extensionPath) + await delay(regularDelayMs) + extensionId = await getExtensionIdFirefox(driver) + extensionUrl = `moz-extension://${extensionId}/home.html` + break + } + } + // Depending on the state of the application built into the above directory (extPath) and the value of + // METAMASK_DEBUG we will see different post-install behaviour and possibly some extra windows. Here we + // are closing any extraneous windows to reset us to a single window before continuing. + const [tab1] = await driver.getAllWindowHandles() + await closeAllWindowHandlesExcept(driver, [tab1]) + await driver.switchTo().window(tab1) + await driver.get(extensionUrl) + }) + + beforeEach(async function () { + await driver.executeScript( + 'window.origFetch = window.fetch.bind(window);' + + 'window.fetch = ' + + '(...args) => { ' + + 'if (args[0] === "https://ethgasstation.info/json/ethgasAPI.json") { return ' + + 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.ethGasBasic + '\')) }); } else if ' + + '(args[0] === "https://ethgasstation.info/json/predictTable.json") { return ' + + 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.ethGasPredictTable + '\')) }); } else if ' + + '(args[0].match(/chromeextensionmm/)) { return ' + + 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' + + '(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' + + 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' + + 'return window.origFetch(...args); };' + + 'function cancelInfuraRequest(requestDetails) {' + + 'console.log("Canceling: " + requestDetails.url);' + + 'return {' + + 'cancel: true' + + '};' + + ' }' + + 'window.chrome && window.chrome.webRequest && window.chrome.webRequest.onBeforeRequest.addListener(' + + 'cancelInfuraRequest,' + + '{urls: ["https://*.infura.io/*"]},' + + '["blocking"]' + + ');' + ) + }) + + afterEach(async function () { + if (process.env.SELENIUM_BROWSER === 'chrome') { + const errors = await checkBrowserForConsoleErrors(driver) + if (errors.length) { + const errorReports = errors.map(err => err.message) + const errorMessage = `Errors found in browser console:\n${errorReports.join('\n')}` + console.error(new Error(errorMessage)) + } + } + if (this.currentTest.state === 'failed') { + await verboseReportOnFailure(driver, this.currentTest) + } + }) + + after(async function () { + await driver.quit() + }) + + describe('First time flow starting from an existing seed phrase', () => { + it('clicks the continue button on the welcome screen', async () => { + await findElement(driver, By.css('.welcome-page__header')) + const welcomeScreenBtn = await findElement(driver, By.css('.first-time-flow__button')) + welcomeScreenBtn.click() + await delay(largeDelayMs) + }) + + it('clicks the "Import Wallet" option', async () => { + const customRpcButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Import Wallet')]`)) + customRpcButton.click() + await delay(largeDelayMs) + }) + + it('clicks the "No thanks" option on the metametrics opt-in screen', async () => { + const optOutButton = await findElement(driver, By.css('.btn-default')) + optOutButton.click() + await delay(largeDelayMs) + }) + + it('imports a seed phrase', async () => { + const [seedTextArea] = await findElements(driver, By.css('textarea.first-time-flow__textarea')) + await seedTextArea.sendKeys(testSeedPhrase) + await delay(regularDelayMs) + + const [password] = await findElements(driver, By.id('password')) + await password.sendKeys('correct horse battery staple') + const [confirmPassword] = await findElements(driver, By.id('confirm-password')) + confirmPassword.sendKeys('correct horse battery staple') + + const tosCheckBox = await findElement(driver, By.css('.first-time-flow__checkbox')) + await tosCheckBox.click() + + const [importButton] = await findElements(driver, By.xpath(`//button[contains(text(), 'Import')]`)) + await importButton.click() + await delay(regularDelayMs) + }) + + it('clicks through the success screen', async () => { + await findElement(driver, By.xpath(`//div[contains(text(), 'Congratulations')]`)) + const doneButton = await findElement(driver, By.css('button.first-time-flow__button')) + await doneButton.click() + await delay(regularDelayMs) + }) + }) + + describe('Send ETH from inside MetaMask', () => { + it('starts a send transaction', async function () { + const sendButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Send')]`)) + await sendButton.click() + await delay(regularDelayMs) + + const inputAddress = await findElement(driver, By.css('input[placeholder="Search, public address (0x), or ENS"]')) + await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + + const recipientRow = await findElement(driver, By.css('.send__select-recipient-wrapper__group-item')) + await recipientRow.click() + await delay(regularDelayMs) + + const inputAmount = await findElement(driver, By.css('.unit-input__input')) + await inputAmount.sendKeys('1') + + // Set the gas limit + const configureGas = await findElement(driver, By.css('.advanced-gas-options-btn')) + await configureGas.click() + await delay(regularDelayMs) + + const gasModal = await driver.findElement(By.css('span .modal')) + + const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) + await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) + await delay(50) + + + await gasPriceInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasPriceInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasPriceInput.sendKeys('10') + await delay(50) + await delay(tinyDelayMs) + await delay(50) + await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a')) + await delay(50) + + await gasLimitInput.sendKeys('25000') + + const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`)) + await save.click() + await driver.wait(until.stalenessOf(gasModal)) + await delay(regularDelayMs) + + // Continue to next screen + const nextScreen = await findElement(driver, By.xpath(`//button[contains(text(), 'Next')]`)) + await nextScreen.click() + await delay(regularDelayMs) + }) + + it('has correct value and fee on the confirm screen the transaction', async function () { + const transactionAmounts = await findElements(driver, By.css('.currency-display-component__text')) + const transactionAmount = transactionAmounts[0] + assert.equal(await transactionAmount.getText(), '1') + + const transactionFee = transactionAmounts[1] + assert.equal(await transactionFee.getText(), '0.00025') + }) + + it('edits the transaction', async function () { + const editButton = await findElement(driver, By.css('.confirm-page-container-header__back-button')) + await editButton.click() + + await delay(regularDelayMs) + + const inputAmount = await findElement(driver, By.css('.unit-input__input')) + await inputAmount.sendKeys(Key.chord(Key.CONTROL, 'a')) + await delay(50) + await inputAmount.sendKeys(Key.BACK_SPACE) + await delay(50) + await inputAmount.sendKeys('2.2') + + const configureGas = await findElement(driver, By.css('.advanced-gas-options-btn')) + await configureGas.click() + await delay(regularDelayMs) + + const gasModal = await driver.findElement(By.css('span .modal')) + + const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input')) + await gasPriceInput.sendKeys(Key.chord(Key.CONTROL, 'a')) + await delay(50) + + await gasPriceInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasPriceInput.sendKeys(Key.BACK_SPACE) + await delay(50) + await gasPriceInput.sendKeys('8') + await delay(50) + await delay(tinyDelayMs) + await delay(50) + await gasLimitInput.sendKeys(Key.chord(Key.CONTROL, 'a')) + await delay(50) + + await gasLimitInput.sendKeys('100000') + + const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`)) + await save.click() + await driver.wait(until.stalenessOf(gasModal)) + await delay(regularDelayMs) + + const nextScreen = await findElement(driver, By.xpath(`//button[contains(text(), 'Next')]`)) + await nextScreen.click() + await delay(regularDelayMs) + }) + + it('has correct updated value on the confirm screen the transaction', async function () { + const transactionAmounts = await findElements(driver, By.css('.currency-display-component__text')) + const transactionAmount = transactionAmounts[0] + assert.equal(await transactionAmount.getText(), '2.2') + + const transactionFee = transactionAmounts[1] + assert.equal(await transactionFee.getText(), '0.0008') + }) + + it('confirms the transaction', async function () { + const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`)) + await confirmButton.click() + await delay(regularDelayMs) + }) + + it('finds the transaction in the transactions list', async function () { + const transactions = await findElements(driver, By.css('.transaction-list-item')) + assert.equal(transactions.length, 1) + + const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary')) + assert.equal(txValues.length, 1) + assert.ok(/-2.2\s*ETH/.test(await txValues[0].getText())) + }) + }) +}) diff --git a/test/integration/lib/send-new-ui.js b/test/integration/lib/send-new-ui.js deleted file mode 100644 index 7c3bf7c21..000000000 --- a/test/integration/lib/send-new-ui.js +++ /dev/null @@ -1,168 +0,0 @@ -const reactTriggerChange = require('../../lib/react-trigger-change') -const { - timeout, - queryAsync, - findAsync, -} = require('../../lib/util') -const fetchMockResponses = require('../../e2e/fetch-mocks.js') - -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: () => {}, -} - -global.ethereumProvider = {} - -async function runSendFlowTest (assert) { - const tempFetch = global.fetch - - const realFetch = window.fetch.bind(window) - global.fetch = (...args) => { - if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') { - return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) }) - } else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') { - return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) }) - } else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') { - return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) }) - } else if (args[0].match(/chromeextensionmm/)) { - return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) }) - } - return realFetch.fetch(...args) - } - - console.log('*** start runSendFlowTest') - const selectState = await queryAsync($, 'select') - selectState.val('send new ui') - reactTriggerChange(selectState[0]) - - const sendScreenButton = await queryAsync($, 'button.btn-secondary.transaction-view-balance__button') - assert.ok(sendScreenButton[1], 'send screen button present') - sendScreenButton[1].click() - - const sendTitle = await queryAsync($, '.page-container__title') - assert.equal(sendTitle[0].textContent, 'Send ETH', 'Send screen title is correct') - - const sendFromField = await queryAsync($, '.send-v2__form-field') - assert.ok(sendFromField[0], 'send screen has a from field') - - const sendFromFieldItemAddress = await queryAsync($, '.account-list-item__account-name') - assert.equal(sendFromFieldItemAddress[0].textContent, 'Send Account 2', 'send from field shows correct account name') - - const sendToFieldInput = await queryAsync($, '.send-v2__to-autocomplete__input') - sendToFieldInput[0].focus() - - await timeout(1000) - - const sendToDropdownList = await queryAsync($, '.send-v2__from-dropdown__list') - 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') - - const sendAmountField = await queryAsync($, '.send-v2__form-row:eq(3)') - const sendAmountFieldInput = await findAsync(sendAmountField, '.unit-input__input') - - const amountMaxButton = await queryAsync($, '.send-v2__amount-max') - amountMaxButton.click() - reactTriggerChange(sendAmountField.find('input')[1]) - assert.equal(sendAmountFieldInput.is(':disabled'), true, 'disabled the send amount input when max mode is on') - - const gasPriceButtonGroup = await queryAsync($, '.gas-price-button-group--small') - const gasPriceButton = await gasPriceButtonGroup.find('button')[0] - const valueBeforeGasPriceChange = sendAmountFieldInput.prop('value') - gasPriceButton.click() - reactTriggerChange(sendAmountField.find('input')[1]) - - await timeout(1000) - - assert.notEqual(valueBeforeGasPriceChange, sendAmountFieldInput.prop('value'), 'send amount value changes when gas price changes') - - amountMaxButton.click() - reactTriggerChange(sendAmountField.find('input')[1]) - - sendAmountField.find('.unit-input').click() - sendAmountFieldInput.val('5.1') - reactTriggerChange(sendAmountField.find('input')[1]) - - let errorMessage = await queryAsync($, '.send-v2__error') - 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') - - const sendButton = await queryAsync($, 'button.btn-secondary.btn--large.page-container__footer-button') - assert.equal(sendButton[0].textContent, 'Next', 'next button rendered') - sendButton[0].click() - await timeout() - - selectState.val('send edit') - reactTriggerChange(selectState[0]) - - const confirmFromName = (await queryAsync($, '.sender-to-recipient__name')).first() - assert.equal(confirmFromName[0].textContent, 'Send Account 2', 'confirm screen should show correct from name') - - const confirmToName = (await queryAsync($, '.sender-to-recipient__name')).last() - assert.equal(confirmToName[0].textContent, 'Send Account 3', 'confirm screen should show correct to name') - - const confirmScreenRowFiats = await queryAsync($, '.confirm-detail-row__secondary') - const confirmScreenGas = confirmScreenRowFiats[0] - assert.equal(confirmScreenGas.textContent, '$3.60', 'confirm screen should show correct gas') - const confirmScreenTotal = confirmScreenRowFiats[1] - assert.equal(confirmScreenTotal.textContent, '$2,405.37', 'confirm screen should show correct total') - - const confirmScreenBackButton = await queryAsync($, '.confirm-page-container-header__back-button') - confirmScreenBackButton[0].click() - - const sendToFieldInputInEdit = await queryAsync($, '.send-v2__to-autocomplete__input') - sendToFieldInputInEdit[0].focus() - sendToFieldInputInEdit.val('0xd85a4b6a394794842887b8284293d69163007bbb') - - const sendAmountFieldInEdit = await queryAsync($, '.send-v2__form-row:eq(3)') - sendAmountFieldInEdit.find('.unit-input')[0].click() - - const sendAmountFieldInputInEdit = sendAmountFieldInEdit.find('.unit-input__input') - sendAmountFieldInputInEdit.val('1.0') - reactTriggerChange(sendAmountFieldInputInEdit[0]) - - const sendButtonInEdit = await queryAsync($, '.btn-secondary.btn--large.page-container__footer-button') - assert.equal(sendButtonInEdit[0].textContent, 'Next', 'next button in edit rendered') - - selectState.val('send new ui') - reactTriggerChange(selectState[0]) - - const cancelButtonInEdit = await queryAsync($, '.btn-default.btn--large.page-container__footer-button') - cancelButtonInEdit[0].click() - - global.fetch = tempFetch - // 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]); - - // assert.ok(txView[0], 'Should return to the account details screen after confirming') -} diff --git a/test/unit/ui/app/actions.spec.js b/test/unit/ui/app/actions.spec.js index 392321481..919bd81a6 100644 --- a/test/unit/ui/app/actions.spec.js +++ b/test/unit/ui/app/actions.spec.js @@ -869,7 +869,7 @@ describe('Actions', () => { }) it('', () => { - const store = mockStore() + const store = mockStore({ metamask: devState }) store.dispatch(actions.addToAddressBook('test')) assert(addToAddressBookSpy.calledOnce) }) diff --git a/test/unit/ui/app/reducers/metamask.spec.js b/test/unit/ui/app/reducers/metamask.spec.js index 39caf3e6a..714bd476a 100644 --- a/test/unit/ui/app/reducers/metamask.spec.js +++ b/test/unit/ui/app/reducers/metamask.spec.js @@ -309,6 +309,8 @@ describe('MetaMask Reducers', () => { errors: {}, editingTransactionId: 22, forceGasMin: '0xGas', + ensResolution: null, + ensResolutionError: '', } const sendState = reduceMetamask({}, { @@ -492,4 +494,24 @@ describe('MetaMask Reducers', () => { assert.deepEqual(state.pendingTokens, {}) }) + + it('update ensResolution', () => { + const state = reduceMetamask({}, { + type: actions.UPDATE_SEND_ENS_RESOLUTION, + payload: '0x1337', + }) + + assert.deepEqual(state.send.ensResolution, '0x1337') + assert.deepEqual(state.send.ensResolutionError, '') + }) + + it('update ensResolutionError', () => { + const state = reduceMetamask({}, { + type: actions.UPDATE_SEND_ENS_RESOLUTION_ERROR, + payload: 'ens name not found', + }) + + assert.deepEqual(state.send.ensResolutionError, 'ens name not found') + assert.deepEqual(state.send.ensResolution, null) + }) }) |