aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-06-11 21:04:27 +0800
committerDan <danjm.com@gmail.com>2018-06-27 21:31:23 +0800
commit1d8f257832a91757a874bd4221c3a3494aba0f7b (patch)
treeb266701eeb7d90614479de809a5a222586155ef8 /test
parent9734e6ffb8d45cf5268e73a76c29948fad129205 (diff)
downloadtangerine-wallet-browser-1d8f257832a91757a874bd4221c3a3494aba0f7b.tar
tangerine-wallet-browser-1d8f257832a91757a874bd4221c3a3494aba0f7b.tar.gz
tangerine-wallet-browser-1d8f257832a91757a874bd4221c3a3494aba0f7b.tar.bz2
tangerine-wallet-browser-1d8f257832a91757a874bd4221c3a3494aba0f7b.tar.lz
tangerine-wallet-browser-1d8f257832a91757a874bd4221c3a3494aba0f7b.tar.xz
tangerine-wallet-browser-1d8f257832a91757a874bd4221c3a3494aba0f7b.tar.zst
tangerine-wallet-browser-1d8f257832a91757a874bd4221c3a3494aba0f7b.zip
Add test for importing from private key to from-import-beta-ui.spec.js, and remove non-import related tests from that file.
Diffstat (limited to 'test')
-rw-r--r--test/e2e/beta/from-import-beta-ui.spec.js142
-rwxr-xr-xtest/e2e/beta/run-all.sh2
2 files changed, 19 insertions, 125 deletions
diff --git a/test/e2e/beta/from-import-beta-ui.spec.js b/test/e2e/beta/from-import-beta-ui.spec.js
index 8af654319..dea963a73 100644
--- a/test/e2e/beta/from-import-beta-ui.spec.js
+++ b/test/e2e/beta/from-import-beta-ui.spec.js
@@ -26,6 +26,7 @@ describe('Using MetaMask with an existing account', function () {
const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'
const testAddress = '0xE18035BF8712672935FDB4e5e431b1a0183d2DFC'
+ const testPrivateKey2 = '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6'
const regularDelayMs = 1000
const largeDelayMs = regularDelayMs * 2
const waitingNewPageDelayMs = regularDelayMs * 10
@@ -289,143 +290,36 @@ describe('Using MetaMask with an existing account', function () {
})
})
- describe('Send ETH from Faucet', () => {
- it('starts a send transaction inside Faucet', async () => {
- await driver.executeScript('window.open("https://faucet.metamask.io")')
- await delay(waitingNewPageDelayMs)
-
- const [extension, faucet] = await driver.getAllWindowHandles()
- await driver.switchTo().window(faucet)
- await delay(regularDelayMs)
-
- const send1eth = await findElement(driver, By.xpath(`//button[contains(text(), '10 ether')]`), 14000)
- await send1eth.click()
- await delay(regularDelayMs)
-
- await driver.switchTo().window(extension)
- await loadExtension(driver, extensionId)
- await delay(regularDelayMs)
-
- const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 14000)
- await confirmButton.click()
- await delay(regularDelayMs)
-
- await driver.switchTo().window(faucet)
- await delay(regularDelayMs)
- await driver.close()
- await delay(regularDelayMs)
- await driver.switchTo().window(extension)
- await delay(regularDelayMs)
- await loadExtension(driver, extensionId)
- await delay(regularDelayMs)
- })
- })
-
- describe('Add existing token using search', () => {
- it('clicks on the Add Token button', async () => {
- const addToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Add Token')]`))
- await addToken.click()
- await delay(regularDelayMs)
- })
-
- it('picks an existing token', async () => {
- const tokenSearch = await findElement(driver, By.css('#search-tokens'))
- await tokenSearch.sendKeys('BAT')
- await delay(regularDelayMs)
-
- const token = await findElement(driver, By.xpath("//span[contains(text(), 'BAT')]"))
- await token.click()
- await delay(regularDelayMs)
-
- const nextScreen = await findElement(driver, By.xpath(`//button[contains(text(), 'Next')]`))
- await nextScreen.click()
+ describe('Imports an account with private key', () => {
+ it('choose Create Account from the account menu', async () => {
+ await driver.findElement(By.css('.account-menu__icon')).click()
await delay(regularDelayMs)
- const addTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Add Tokens')]`))
- await addTokens.click()
- await delay(largeDelayMs)
- })
-
- it('renders the balance for the new token', async () => {
- const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
- await driver.wait(until.elementTextMatches(balance, /^0\s*BAT\s*$/), 10000)
- const tokenAmount = await balance.getText()
- assert.ok(/^0\s*BAT\s*$/.test(tokenAmount))
+ const [importAccount] = await findElements(driver, By.xpath(`//div[contains(text(), 'Import Account')]`))
+ await importAccount.click()
await delay(regularDelayMs)
})
- })
- describe('Add a custom token from TokenFactory', () => {
- it('creates a new token', async () => {
- await driver.executeScript('window.open("https://tokenfactory.surge.sh/#/factory")')
- await delay(waitingNewPageDelayMs)
-
- const [extension, tokenFactory] = await driver.getAllWindowHandles()
- await driver.switchTo().window(tokenFactory)
- const [
- totalSupply,
- tokenName,
- tokenDecimal,
- tokenSymbol,
- ] = await findElements(driver, By.css('.form-control'))
-
- await totalSupply.sendKeys('100')
- await tokenName.sendKeys('Test')
- await tokenDecimal.sendKeys('0')
- await tokenSymbol.sendKeys('TST')
-
- const createToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Create Token')]`))
- await createToken.click()
+ it('enter private key', async () => {
+ const privateKeyInput = await findElement(driver, By.css('#private-key-box'))
+ await privateKeyInput.sendKeys(testPrivateKey2)
await delay(regularDelayMs)
-
- await driver.switchTo().window(extension)
- await loadExtension(driver, extensionId)
- await delay(regularDelayMs)
-
- const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
- await confirmButton.click()
- await delay(regularDelayMs)
-
- await driver.switchTo().window(tokenFactory)
- await delay(regularDelayMs)
- const tokenContactAddress = await driver.findElement(By.css('div > div > div:nth-child(2) > span:nth-child(3)'))
- tokenAddress = await tokenContactAddress.getText()
- await driver.close()
- await driver.switchTo().window(extension)
- await loadExtension(driver, extensionId)
- await delay(regularDelayMs)
- })
-
- it('clicks on the Add Token button', async () => {
- const addToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Add Token')]`))
- await addToken.click()
+ const importButtons = await findElements(driver, By.xpath(`//button[contains(text(), 'Import')]`))
+ await importButtons[0].click()
await delay(regularDelayMs)
})
- it('picks the new Test token', async () => {
- const addCustomToken = await findElement(driver, By.xpath("//div[contains(text(), 'Custom Token')]"))
- await addCustomToken.click()
- await delay(regularDelayMs)
-
- const newTokenAddress = await findElement(driver, By.css('#custom-address'))
- await newTokenAddress.sendKeys(tokenAddress)
- await delay(regularDelayMs)
-
- const nextScreen = await findElement(driver, By.xpath(`//button[contains(text(), 'Next')]`))
- await nextScreen.click()
- await delay(regularDelayMs)
-
- const addTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Add Tokens')]`))
- await addTokens.click()
+ it('should show the correct account name', async () => {
+ const [accountName] = await findElements(driver, By.css('.account-name'))
+ assert.equal(await accountName.getText(), 'Account 3')
await delay(regularDelayMs)
})
- it('renders the balance for the new token', async () => {
- const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
- await driver.wait(until.elementTextMatches(balance, /^100\s*TST\s*$/), 10000)
- const tokenAmount = await balance.getText()
- assert.ok(/^100\s*TST\s*$/.test(tokenAmount))
+ it('should show the imported label', async () => {
+ const [importedLabel] = await findElements(driver, By.css('.wallet-view__keyring-label'))
+ assert.equal(await importedLabel.getText(), 'IMPORTED')
await delay(regularDelayMs)
})
})
+
})
diff --git a/test/e2e/beta/run-all.sh b/test/e2e/beta/run-all.sh
index 5916d5614..b0b6ecca8 100755
--- a/test/e2e/beta/run-all.sh
+++ b/test/e2e/beta/run-all.sh
@@ -7,4 +7,4 @@ set -o pipefail
export PATH="$PATH:./node_modules/.bin"
shell-parallel -s 'npm run ganache:start' -x 'sleep 5 && mocha test/e2e/beta/metamask-beta-ui.spec'
-shell-parallel -s 'npm run ganache:start' -x 'sleep 5 && mocha test/e2e/beta/from-import-beta-ui.spec'
+shell-parallel -s 'npm run ganache:start -- -d' -x 'sleep 5 && mocha test/e2e/beta/from-import-beta-ui.spec'