inject script before tests to prepare testing

pull/1/head
yann300 8 years ago
parent 0832642dd9
commit 4d6a2e4512
  1. 1
      src/app/editor.js
  2. 7
      test-browser/helpers/applytestmode.js
  3. 8
      test-browser/helpers/contracts.js
  4. 7
      test-browser/helpers/init.js
  5. 5
      test-browser/tests/ballot.js
  6. 5
      test-browser/tests/debugger.js
  7. 5
      test-browser/tests/new-file-test.js
  8. 5
      test-browser/tests/simpleContract.js
  9. 6
      test-browser/tests/smoke-test.js

@ -12,6 +12,7 @@ function Editor (loadingFromGist, storage) {
var SOL_CACHE_FILE = null var SOL_CACHE_FILE = null
var editor = ace.edit('input') var editor = ace.edit('input')
document.getElementById('input').editor = editor
var sessions = {} var sessions = {}
var sourceAnnotations = [] var sourceAnnotations = []

@ -0,0 +1,7 @@
/**
* This script is injected by NightWatch just before starting test
*
*/
console.log('applying test mode')
document.getElementById('input').editor.setBehavioursEnabled(false)
console.log('test mode applied')

@ -19,9 +19,9 @@ function checkCompiledContracts (browser, compiled, callback) {
function testContracts (browser, contractCode, compiledContractNames, callback) { function testContracts (browser, contractCode, compiledContractNames, callback) {
browser browser
.clearValue('#input textarea') .clearValue('#input textarea')
.click('.newFile') .click('.newFile')
.setValue('#input textarea', contractCode.replace(/(\n)/g, ' '), function () {}) .setValue('#input textarea', contractCode, function () {})
.waitForElementPresent('.contract .create', 3000000) .waitForElementPresent('.contract .create', 3000000)
checkCompiledContracts(browser, compiledContractNames, callback) checkCompiledContracts(browser, compiledContractNames, callback)
} }

@ -0,0 +1,7 @@
module.exports = function (browser, callback) {
browser
.url('http://127.0.0.1:8080/#version=builtin')
.injectScript('test-browser/helpers/applytestmode.js', function () {
callback()
})
}

@ -1,6 +1,7 @@
'use strict' 'use strict'
var contractHelper = require('../helpers/contracts') var contractHelper = require('../helpers/contracts')
var examples = require('../../src/app/example-contracts') var examples = require('../../src/app/example-contracts')
var init = require('../helpers/init')
var sources = { var sources = {
'sources': { 'sources': {
@ -9,6 +10,9 @@ var sources = {
} }
module.exports = { module.exports = {
before: function (browser, done) {
init(browser, done)
},
'@Sources': function () { '@Sources': function () {
return sources return sources
}, },
@ -19,7 +23,6 @@ module.exports = {
function runTests (browser, testData) { function runTests (browser, testData) {
browser browser
.url('http://127.0.0.1:8080/#version=builtin')
.waitForElementVisible('.newFile', 10000) .waitForElementVisible('.newFile', 10000)
contractHelper.testContracts(browser, sources.sources.Untitled, ['Ballot'], function () { contractHelper.testContracts(browser, sources.sources.Untitled, ['Ballot'], function () {
browser.end() browser.end()

@ -1,9 +1,12 @@
'use strict' 'use strict'
var init = require('../helpers/init')
module.exports = { module.exports = {
before: function (browser, done) {
init(browser, done)
},
'Debugger Render': function (browser) { 'Debugger Render': function (browser) {
browser browser
.url('http://127.0.0.1:8080/#version=builtin')
.waitForElementPresent('#debugger', 10000) .waitForElementPresent('#debugger', 10000)
.waitForElementPresent('#debugger #slider', 10000) .waitForElementPresent('#debugger #slider', 10000)
.end() .end()

@ -1,9 +1,12 @@
'use strict' 'use strict'
var init = require('../helpers/init')
module.exports = { module.exports = {
before: function (browser, done) {
init(browser, done)
},
'New file test': function (browser) { 'New file test': function (browser) {
browser browser
.url('http://127.0.0.1:8080/#version=builtin')
.waitForElementVisible('.newFile', 10000) .waitForElementVisible('.newFile', 10000)
.click('.newFile') .click('.newFile')
.pause('10000') .pause('10000')

@ -1,5 +1,6 @@
'use strict' 'use strict'
var contractHelper = require('../helpers/contracts') var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init')
var sources = { var sources = {
'sources': { 'sources': {
@ -8,6 +9,9 @@ var sources = {
} }
module.exports = { module.exports = {
before: function (browser, done) {
init(browser, done)
},
'@Sources': function () { '@Sources': function () {
return sources return sources
}, },
@ -18,7 +22,6 @@ module.exports = {
function runTests (browser) { function runTests (browser) {
browser browser
.url('http://127.0.0.1:8080/#version=builtin')
.waitForElementVisible('.newFile', 10000) .waitForElementVisible('.newFile', 10000)
contractHelper.testContracts(browser, sources.sources.Untitled, ['test1', 'test2'], function () { contractHelper.testContracts(browser, sources.sources.Untitled, ['test1', 'test2'], function () {
browser.end() browser.end()

@ -1,9 +1,13 @@
'use strict' 'use strict'
var init = require('../helpers/init')
module.exports = { module.exports = {
before: function (browser, done) {
browser
init(browser, done)
},
'Smoke test': function (browser) { 'Smoke test': function (browser) {
browser browser
.url('http://127.0.0.1:8080/#version=builtin')
.waitForElementVisible('#righthand-panel', 10000) .waitForElementVisible('#righthand-panel', 10000)
.pause('10000') .pause('10000')
.assert.containsText('#righthand-panel', 'Solidity version') .assert.containsText('#righthand-panel', 'Solidity version')

Loading…
Cancel
Save