Skip to content

Commit

Permalink
Merge pull request #235 from dennis00010011b/e2e-copy-abi
Browse files Browse the repository at this point in the history
e2e check clipboard
  • Loading branch information
vbaranov authored Dec 21, 2018
2 parents 2f60ab6 + ae29b27 commit 0d67f7f
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/e2e/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = {

},
executeMethod: {

copy: By.className('clipboard cursor-pointer'),
title: By.className('flex-center send-header'),
titleText: 'Execute Method',
selectArrow: By.className('Select-arrow-zone'),
Expand Down
110 changes: 99 additions & 11 deletions test/e2e/metamask.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const mkdirp = require('mkdirp')
const path = require('path')
const assert = require('assert')
const pify = require('pify')
const clipboardy = require('clipboardy')
const webdriver = require('selenium-webdriver')
const { By, Key } = webdriver
const { delay, buildChromeWebDriver, buildFirefoxWebdriver, installWebExt, getExtensionIdChrome, getExtensionIdFirefox } = require('./func')
Expand All @@ -16,6 +17,7 @@ const eventsEmitter = 'https://vbaranov.github.io/event-listener-dapp/'
describe('Metamask popup page', async function () {
let driver, accountAddress, tokenAddress, extensionId
let password = '123456789'
let abiClipboard
const newPassword = {
correct: 'abcDEF123!@#',
short: '123',
Expand Down Expand Up @@ -140,6 +142,11 @@ describe('Metamask popup page', async function () {
assert.notEqual(field, false, 'copy icon doesn\'t present')
})

it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.length, 42, "address account wasn't copied to clipboard")
})

it('open \'Account name\' change dialog', async () => {
const menu = await waitUntilShowUp(menus.dot.menu)
await menu.click()
Expand Down Expand Up @@ -222,6 +229,11 @@ describe('Metamask popup page', async function () {
assert.notEqual(field, false, 'copy icon doesn\'t present')
})

it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.length, 42, "address account wasn't copied to clipboard")
})

it('close QR code screen by clicking button arrow', async () => {
const button = await waitUntilShowUp(screens.QRcode.buttonArrow)
await click(button)
Expand Down Expand Up @@ -266,6 +278,7 @@ describe('Metamask popup page', async function () {
})

it("Select type 'Contract'", async function () {
await delay(1000)
const field = await waitUntilShowUp(screens.importAccounts.selectArrow)
await field.click()
const item = await waitUntilShowUp(screens.importAccounts.itemContract)
Expand Down Expand Up @@ -295,12 +308,7 @@ describe('Metamask popup page', async function () {
assert.notEqual(field, false, "field 'ABI' isn't displayed")
})

it('icon copy is displayed for ABI ', async function () {
const field = await waitUntilShowUp(screens.importAccounts.iconCopy)
assert.notEqual(field, false, "icon copy isn't displayed")
})

it("Field 'ABI' is empty if contract isn't verified in current network", async function () {
it("Field 'ABI' is empty if contract isn't verified in current network", async function () {
const field = await waitUntilShowUp(screens.importAccounts.contractABI)
assert.equal(await field.getText(), '', "field 'ABI' isn't displayed")
})
Expand Down Expand Up @@ -330,8 +338,19 @@ describe('Metamask popup page', async function () {

it('ABI is fetched ', async function () {
const field = await waitUntilShowUp(screens.importAccounts.contractABI)
const abi = await field.getText()
assert.equal(abi.length, 4457, "ABI isn't fetched")
abiClipboard = await field.getText()
assert.equal(abiClipboard.length, 4457, "ABI isn't fetched")
})

it('icon copy is displayed for ABI ', async function () {
const field = await waitUntilShowUp(screens.importAccounts.iconCopy)
assert.notEqual(field, false, "icon copy isn't displayed")
await field.click()
})

it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text, abiClipboard, "address account wasn't copied to clipboard")
})

it("Click button 'Import', main screen opens", async function () {
Expand Down Expand Up @@ -363,8 +382,12 @@ describe('Metamask popup page', async function () {
const menu = await waitUntilShowUp(menus.dot.item, 20)
assert.equal(menu, false, "3dot menu wasn't closed")
})
})

it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text, abiClipboard, "ABI wasn't copied to clipboard")
})
})

describe('Execute Method screen', () => {
const notContractAddress = '0x56B2e3C3cFf7f3921Dc2e0F8B8e20d1eEc29216b'
Expand Down Expand Up @@ -438,6 +461,16 @@ describe('Metamask popup page', async function () {
assert.equal(text.toLowerCase(), address.toLowerCase(), 'incorrect value was returned')
})

it('icon copy cliboard is displayed and clickable', async function () {
const icon = await waitUntilShowUp(screens.executeMethod.copy)
assert.notEqual(icon, false, 'icon copy isn\'t displayed')
await icon.click()
})
it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.toLowerCase(), address.toLowerCase(), "output wasn't copied to clipboard")
})

it("2nd call doesn't throw the error", async function () {
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
assert.notEqual(button, false, "button 'Call data' isn't displayed")
Expand Down Expand Up @@ -484,6 +517,15 @@ describe('Metamask popup page', async function () {
const text = await waitUntilHasValue(fields[1])
assert.equal(text, stringValue, 'incorrect value was returned')
})
it('icon copy cliboard is displayed and clickable', async function () {
const icon = await waitUntilShowUp(screens.executeMethod.copy)
assert.notEqual(icon, false, 'icon copy isn\'t displayed')
await icon.click()
})
it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.toLowerCase(), stringValue.toLowerCase(), "output wasn't copied to clipboard")
})
})
describe('Check output for data type : BOOLEAN', () => {
it("Select method 'returnBoolean'", async function () {
Expand Down Expand Up @@ -540,6 +582,15 @@ describe('Metamask popup page', async function () {
const text = await waitUntilHasValue(fields[1])
assert.equal(text, 'false', 'incorrect value was returned')
})
it('icon copy cliboard is displayed and clickable', async function () {
const icon = await waitUntilShowUp(screens.executeMethod.copy)
assert.notEqual(icon, false, 'icon copy isn\'t displayed')
await icon.click()
})
it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.toLowerCase(), 'false', "output wasn't copied to clipboard")
})

})
describe('Check output for data type : BYTES', () => {
Expand Down Expand Up @@ -575,6 +626,16 @@ describe('Metamask popup page', async function () {
const text = await waitUntilHasValue(fields[1])
assert.equal(text, bytesValue, 'incorrect value was returned')
})
it('icon copy cliboard is displayed and clickable', async function () {
const icon = await waitUntilShowUp(screens.executeMethod.copy)
assert.notEqual(icon, false, 'icon copy isn\'t displayed')
await icon.click()
})
it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.toLowerCase(), bytesValue.toLowerCase(), "output wasn't copied to clipboard")
})

})
describe('Check output for data type : UINT256', () => {
const uint256Value = '1122334455667788991122334455667788'
Expand Down Expand Up @@ -610,6 +671,16 @@ describe('Metamask popup page', async function () {
assert.equal(text, uint256Value, 'incorrect value was returned')
})

it('icon copy cliboard is displayed and clickable', async function () {
const icon = await waitUntilShowUp(screens.executeMethod.copy)
assert.notEqual(icon, false, 'icon copy isn\'t displayed')
await icon.click()
})
it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.toLowerCase(), uint256Value.toLowerCase(), "output wasn't copied to clipboard")
})

})
describe('Check output for data type : INT256', () => {
const int256Value = '-1122334455667788991122334455667788'
Expand Down Expand Up @@ -644,6 +715,16 @@ describe('Metamask popup page', async function () {
const text = await waitUntilHasValue(fields[1])
assert.equal(text, int256Value, 'incorrect value was returned')
})
it('icon copy cliboard is displayed and clickable', async function () {
const icon = await waitUntilShowUp(screens.executeMethod.copy)
assert.notEqual(icon, false, 'icon copy isn\'t displayed')
await icon.click()
})
it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.toLowerCase(), int256Value.toLowerCase(), "output wasn't copied to clipboard")
})

})
describe('Check executed method', () => {

Expand Down Expand Up @@ -1033,8 +1114,15 @@ describe('Metamask popup page', async function () {
})

it('icon copy cliboard is displayed and clickable', async function () {
const field = await waitUntilShowUp(screens.yourPR.copy)
assert.notEqual(field, false, 'icon copy isn\'t displayed')
await waitUntilShowUp(screens.yourPR.copy)
const icons = await driver.findElements(screens.yourPR.copy)
assert.notEqual(icons[1], false, 'icon copy isn\'t displayed')
await icons[1].click()
})

it('Check clipboard buffer', async function () {
const text = clipboardy.readSync()
assert.equal(text.length, 64, "private key wasn't copied to clipboard")
})

it('file loaded if click button \'Save\' ', async function () {
Expand Down

0 comments on commit 0d67f7f

Please sign in to comment.