Refactored ModalFooterClick command and merged importFromGist test with gist test.

pull/5370/head
ioedeveloper 5 years ago
parent f3069aadd2
commit 74b7c1af2f
  1. 2
      package.json
  2. 17
      test-browser/commands/modalFooterCancelClick.js
  3. 17
      test-browser/commands/modalFooterClick.js
  4. 17
      test-browser/commands/modalFooterOKClick.js
  5. 2
      test-browser/tests/ballot.js
  6. 17
      test-browser/tests/console.js
  7. 47
      test-browser/tests/gist.js
  8. 56
      test-browser/tests/importFromGist.js
  9. 2
      test-browser/tests/publishContract.js
  10. 2
      test-browser/tests/recorder.js
  11. 17
      test-browser/tests/terminal.js

@ -172,7 +172,7 @@
"nightwatch_local_specialFunctions": "nightwatch ./test-browser/tests/specialFunctions.js --config nightwatch.js --env chrome ", "nightwatch_local_specialFunctions": "nightwatch ./test-browser/tests/specialFunctions.js --config nightwatch.js --env chrome ",
"nightwatch_local_solidityUnittests": "nightwatch ./test-browser/tests/solidityUnittests.js --config nightwatch.js --env chrome ", "nightwatch_local_solidityUnittests": "nightwatch ./test-browser/tests/solidityUnittests.js --config nightwatch.js --env chrome ",
"nightwatch_local_remixd": "nightwatch ./test-browser/tests/remixd.js --config nightwatch.js --env chrome ", "nightwatch_local_remixd": "nightwatch ./test-browser/tests/remixd.js --config nightwatch.js --env chrome ",
"nightwatch_local_console": "nightwatch ./test-browser/tests/console.js --config nightwatch.js --env chrome ", "nightwatch_local_terminal": "nightwatch ./test-browser/tests/console.js --config nightwatch.js --env chrome ",
"nightwatch_local_gist": "nightwatch ./test-browser/tests/gist.js --config nightwatch.js --env chrome ", "nightwatch_local_gist": "nightwatch ./test-browser/tests/gist.js --config nightwatch.js --env chrome ",
"nightwatch_local_workspace": "nightwatch ./test-browser/tests/workspace.js --config nightwatch.js --env chrome ", "nightwatch_local_workspace": "nightwatch ./test-browser/tests/workspace.js --config nightwatch.js --env chrome ",
"onchange": "onchange build/app.js -- npm-run-all lint", "onchange": "onchange build/app.js -- npm-run-all lint",

@ -1,17 +0,0 @@
const EventEmitter = require('events')
class ModalFooterOKClick extends EventEmitter {
command () {
this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => {
this.api.execute(function () {
document.querySelector('#modal-footer-cancel').click()
}, [], (result) => {
done()
this.emit('complete')
})
})
return this
}
}
module.exports = ModalFooterOKClick

@ -0,0 +1,17 @@
const EventEmitter = require('events')
class ModalFooterClick extends EventEmitter {
command (cssSelector) {
this.api.waitForElementVisible(cssSelector).perform((client, done) => {
this.api.execute(function () {
document.querySelector(cssSelector).click()
}, [], (result) => {
done()
this.emit('complete')
})
})
return this
}
}
module.exports = ModalFooterClick

@ -1,17 +0,0 @@
const EventEmitter = require('events')
class ModalFooterOKClick extends EventEmitter {
command () {
this.api.waitForElementVisible('#modal-footer-ok').perform((client, done) => {
this.api.execute(function () {
document.querySelector('#modal-footer-ok').click()
}, [], (result) => {
done()
this.emit('complete')
})
})
return this
}
}
module.exports = ModalFooterOKClick

@ -60,7 +60,7 @@ module.exports = {
'Deploy and use Ballot using external web3': function (browser) { 'Deploy and use Ballot using external web3': function (browser) {
browser browser
.click('#selectExEnvOptions #web3-mode') .click('#selectExEnvOptions #web3-mode')
.modalFooterOKClick() .modalFooterClick('#modal-footer-ok')
.clickLaunchIcon('solidity') .clickLaunchIcon('solidity')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) .testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp') .clickLaunchIcon('udapp')

@ -1,17 +0,0 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
module.exports = {
before: function (browser, done) {
init(browser, done)
},
'SimpleExecutionConsole': function (browser) {
browser
.waitForElementVisible('#terminalCli', 10000)
.executeScript('1+1')
.journalLastChild('2')
.end()
},
tearDown: sauce
}

@ -1,6 +1,10 @@
'use strict' 'use strict'
const init = require('../helpers/init') const init = require('../helpers/init')
const sauce = require('./sauce') const sauce = require('./sauce')
const testData = {
validGistId: '1859c97c6e1efc91047d725d5225888e',
invalidGistId: '6368b389f9302v32902msk2402'
}
// 99266d6da54cc12f37f11586e8171546c7700d67 // 99266d6da54cc12f37f11586e8171546c7700d67
module.exports = { module.exports = {
@ -19,7 +23,7 @@ module.exports = {
.waitForElementVisible('#icon-panel', 10000) .waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('fileExplorers') .clickLaunchIcon('fileExplorers')
.click('#publishToGist') .click('#publishToGist')
.modalFooterOKClick() .modalFooterClick('#modal-footer-ok')
.getModalBody((value, done) => { .getModalBody((value, done) => {
const reg = /gist.github.com\/([^.]+)/ const reg = /gist.github.com\/([^.]+)/
const id = value.match(reg) const id = value.match(reg)
@ -29,7 +33,7 @@ module.exports = {
} else { } else {
let gistid = id[1] let gistid = id[1]
browser browser
.modalFooterCancelClick() .modalFooterClick('#modal-footer-cancel')
.executeScript(`remix.loadgist('${gistid}')`) .executeScript(`remix.loadgist('${gistid}')`)
.switchFile('browser/gists') .switchFile('browser/gists')
.switchFile(`browser/gists/${gistid}`) .switchFile(`browser/gists/${gistid}`)
@ -37,6 +41,45 @@ module.exports = {
.perform(done) .perform(done)
} }
}) })
},
'Load Gist Modal': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('fileExplorers')
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)')
.waitForElementVisible('h6.modal-title')
.assert.containsText('h6.modal-title', 'Load a Gist')
.waitForElementVisible('div.modal-body > div')
.assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.')
.waitForElementVisible('#prompt_text')
.click('#modal-footer-cancel')
},
'Display Error Message For Invalid Gist ID': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('fileExplorers')
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)')
.waitForElementVisible('#prompt_text')
.setValue('#prompt_text', testData.invalidGistId)
.modalFooterClick('#modal-footer-ok')
.waitForElementVisible('div.modal-body > div')
.assert.containsText('div.modal-body > div', 'Gist load error: Not Found')
.modalFooterClick('#modal-footer-ok')
},
'Import From Gist For Valid Gist ID': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('fileExplorers')
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)')
.waitForElementVisible('#prompt_text')
.setValue('#prompt_text', testData.validGistId)
.modalFooterClick('#modal-footer-ok')
.switchFile(`browser/gists/${testData.validGistId}`)
.switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`)
.waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`)
.assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry')
.end() .end()
}, },
tearDown: sauce tearDown: sauce

@ -1,56 +0,0 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
const testData = {
validGistId: '1859c97c6e1efc91047d725d5225888e',
invalidGistId: '6368b389f9302v32902msk2402'
}
module.exports = {
before: function (browser, done) {
init(browser, done)
},
'Load Gist Modal': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('fileExplorers')
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)')
.waitForElementVisible('h6.modal-title')
.assert.containsText('h6.modal-title', 'Load a Gist')
.waitForElementVisible('div.modal-body > div')
.assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.')
.waitForElementVisible('#prompt_text')
.click('#modal-footer-cancel')
},
'Display Error Message For Invalid Gist ID': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('fileExplorers')
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)')
.waitForElementVisible('#prompt_text')
.setValue('#prompt_text', testData.invalidGistId)
.modalFooterOKClick()
.waitForElementVisible('div.modal-body > div')
.assert.containsText('div.modal-body > div', 'Gist load error: Not Found')
.modalFooterOKClick()
},
'Import From Gist For Valid Gist ID': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('fileExplorers')
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)')
.waitForElementVisible('#prompt_text')
.setValue('#prompt_text', testData.validGistId)
.modalFooterOKClick()
.switchFile(`browser/gists/${testData.validGistId}`)
.switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`)
.waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`)
.assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry')
.end()
},
tearDown: sauce
}

@ -21,7 +21,7 @@ module.exports = {
if (value.indexOf('dweb:/ipfs') === -1) browser.assert.fail('ipfs deploy failed', '', '') if (value.indexOf('dweb:/ipfs') === -1) browser.assert.fail('ipfs deploy failed', '', '')
done() done()
}) })
.modalFooterOKClick() .modalFooterClick('#modal-footer-ok')
}, },
'Publish on Swarm': function (browser) { 'Publish on Swarm': function (browser) {
browser browser

@ -38,7 +38,7 @@ module.exports = {
.click('.instance:nth-of-type(2) > div > button') .click('.instance:nth-of-type(2) > div > button')
.clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'}) .clickFunction('set - transact (not payable)', {types: 'uint256 _p', values: '34'})
.click('i.savetransaction') .click('i.savetransaction')
.modalFooterOKClick() .modalFooterClick('#modal-footer-ok')
.getEditorValue(function (result) { .getEditorValue(function (result) {
var parsed = JSON.parse(result) var parsed = JSON.parse(result)
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters)) browser.assert.equal(JSON.stringify(parsed.transactions[0].record.parameters), JSON.stringify(scenario.transactions[0].record.parameters))

@ -0,0 +1,17 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
module.exports = {
before: function (browser, done) {
init(browser, done)
},
'SimpleExecutionConsole': function (browser) {
browser
.waitForElementVisible('#terminalCli', 10000)
.executeScript('1+1')
.journalLastChild('2')
.end()
},
tearDown: sauce
}
Loading…
Cancel
Save