e2e: add sign data tests

This commit is contained in:
dennistikhomirov 2018-10-31 21:27:12 -07:00
parent a386734efc
commit cb6669b77b
2 changed files with 68 additions and 1 deletions

View File

@ -46,6 +46,16 @@ module.exports = {
},
},
screens: {
signMessage: {
buttons: {
sign: By.css('#app-content > div > div.app-primary.from-right > div > div > div.flex-row.flex-space-around > button:nth-child(2)'),
cancel: By.css('#app-content > div > div.app-primary.from-right > div > div > div.flex-row.flex-space-around > button:nth-child(1)'),
},
title: By.css('#app-content > div > div.app-primary.from-right > div > div > h3'),
error: By.className('error'),
accountName: By.css('#app-content > div > div.app-primary.from-right > div > div > div:nth-child(3) > div.identity-panel.flex-row.flex-space-between > div.identity-data.flex-column.flex-justify-center.flex-grow.select-none > h2'),
message: By.css('#app-content > div > div.app-primary.from-right > div > div > div:nth-child(3) > div.tx-data.flex-column.flex-justify-center.flex-grow.select-none > div > span'),
},
sendTokens: {
error: By.className('error flex-center'),
errorText: {

View File

@ -52,7 +52,7 @@ describe('Metamask popup page', async function () {
})
after(async function () {
await driver.quit()
// await driver.quit()
})
describe('Setup', async function () {
@ -232,7 +232,64 @@ describe('Metamask popup page', async function () {
const button = await waitUntilShowUp(screens.info.buttonArrow)
await button.click()
})
})
describe('Sign Data', () => {
it('simulate sign request ', async function () {
await driver.get('https://danfinlay.github.io/js-eth-personal-sign-examples/')
const button = await waitUntilShowUp(By.id('ethSignButton'))
await button.click()
})
it('navigates back to MetaMask popup in the tab', async function () {
if (process.env.SELENIUM_BROWSER === 'chrome') {
await driver.get(`chrome-extension://${extensionId}/popup.html`)
} else if (process.env.SELENIUM_BROWSER === 'firefox') {
await driver.get(`moz-extension://${extensionId}/popup.html`)
}
await delay(700)
})
it('error message is displayed and contains text', async function () {
const error = await waitUntilShowUp(screens.signMessage.error)
assert.notEqual(error, false, 'error message isn\'t displayed')
const text = await error.getText()
assert.equal(text.length > 183, true, 'error message hasn\'t text')
})
it('account name is displayed and correct', async function () {
const name = await waitUntilShowUp(screens.signMessage.accountName)
assert.notEqual(name, false, 'account name isn\'t displayed')
assert.equal(await name.getText(), 'Account 2', 'account name is incorrect')
})
it('title is displayed and correct', async function () {
const title = await waitUntilShowUp(screens.signMessage.title)
assert.notEqual(title, false, 'title isn\'t displayed')
assert.equal(await title.getText(), 'Sign message', 'title is incorrect')
})
it('message is displayed and correct', async function () {
const message = await waitUntilShowUp(screens.signMessage.message)
assert.notEqual(message, false, 'message isn\'t displayed')
assert.equal((await message.getText()).length > 32, true, 'message is incorrect')
})
it('button \'Cancel\' is enabled and lead to main screen ', async function () {
const button = await waitUntilShowUp(screens.signMessage.buttons.cancel)
assert.equal(await button.isEnabled(), true, 'button isn\'t enabled')
assert.equal(await button.getText(), 'Cancel', 'button has incorrect name')
})
it('button \'Sign\' is enabled and lead to main screen ', async function () {
const button = await waitUntilShowUp(screens.signMessage.buttons.sign)
assert.equal(await button.isEnabled(), true, 'button isn\'t enabled')
assert.equal(await button.getText(), 'Sign', 'button has incorrect name')
await click(button)
const identicon = await waitUntilShowUp(screens.main.identicon)
assert.notEqual(identicon, false, 'main screen didn\'t opened')
})
})
describe('Import Account', () => {