Merge pull request #343 from ethereum/nightwatch-ts

Moved E2E Tests To Typescript
pull/5370/head
yann300 5 years ago committed by GitHub
commit eb48c2eb69
  1. 28
      .circleci/config.yml
  2. 2
      .gitignore
  3. 14
      apps/remix-ide-e2e/.eslintrc
  4. 17
      apps/remix-ide-e2e/nightwatch.ts
  5. 0
      apps/remix-ide-e2e/seleniumConfig.js
  6. 15
      apps/remix-ide-e2e/src/commands/addAtAddressInstance.ts
  7. 39
      apps/remix-ide-e2e/src/commands/addFile.ts
  8. 31
      apps/remix-ide-e2e/src/commands/checkElementStyle.ts
  9. 7
      apps/remix-ide-e2e/src/commands/checkTerminalFilter.ts
  10. 42
      apps/remix-ide-e2e/src/commands/checkVariableDebug.ts
  11. 7
      apps/remix-ide-e2e/src/commands/clearEditableContent.ts
  12. 27
      apps/remix-ide-e2e/src/commands/clickElementAtPosition.ts
  13. 7
      apps/remix-ide-e2e/src/commands/clickFunction.ts
  14. 8
      apps/remix-ide-e2e/src/commands/clickInstance.ts
  15. 5
      apps/remix-ide-e2e/src/commands/clickLaunchIcon.ts
  16. 7
      apps/remix-ide-e2e/src/commands/createContract.ts
  17. 11
      apps/remix-ide-e2e/src/commands/debugTransaction.ts
  18. 5
      apps/remix-ide-e2e/src/commands/editorScroll.ts
  19. 5
      apps/remix-ide-e2e/src/commands/executeScript.ts
  20. 11
      apps/remix-ide-e2e/src/commands/getAddressAtPosition.ts
  21. 23
      apps/remix-ide-e2e/src/commands/getEditorValue.ts
  22. 7
      apps/remix-ide-e2e/src/commands/getInstalledPlugins.ts
  23. 19
      apps/remix-ide-e2e/src/commands/getModalBody.ts
  24. 14
      apps/remix-ide-e2e/src/commands/goToVMTraceStep.ts
  25. 9
      apps/remix-ide-e2e/src/commands/journalChildIncludes.ts
  26. 5
      apps/remix-ide-e2e/src/commands/journalLastChild.ts
  27. 9
      apps/remix-ide-e2e/src/commands/journalLastChildIncludes.ts
  28. 11
      apps/remix-ide-e2e/src/commands/modalFooterCancelClick.ts
  29. 11
      apps/remix-ide-e2e/src/commands/modalFooterOKClick.ts
  30. 9
      apps/remix-ide-e2e/src/commands/noWorkerErrorFor.ts
  31. 19
      apps/remix-ide-e2e/src/commands/notContainsText.ts
  32. 7
      apps/remix-ide-e2e/src/commands/openFile.ts
  33. 15
      apps/remix-ide-e2e/src/commands/removeFile.ts
  34. 20
      apps/remix-ide-e2e/src/commands/renameFile.ts
  35. 13
      apps/remix-ide-e2e/src/commands/rightClick.ts
  36. 5
      apps/remix-ide-e2e/src/commands/scrollAndClick.ts
  37. 7
      apps/remix-ide-e2e/src/commands/scrollInto.ts
  38. 5
      apps/remix-ide-e2e/src/commands/selectAccount.ts
  39. 7
      apps/remix-ide-e2e/src/commands/selectContract.ts
  40. 6
      apps/remix-ide-e2e/src/commands/sendLowLevelTx.ts
  41. 11
      apps/remix-ide-e2e/src/commands/setEditorValue.ts
  42. 5
      apps/remix-ide-e2e/src/commands/setSolidityCompilerVersion.ts
  43. 6
      apps/remix-ide-e2e/src/commands/setupMetamask.ts
  44. 6
      apps/remix-ide-e2e/src/commands/signMessage.ts
  45. 7
      apps/remix-ide-e2e/src/commands/switchBrowserTab.ts
  46. 6
      apps/remix-ide-e2e/src/commands/switchBrowserWindow.ts
  47. 9
      apps/remix-ide-e2e/src/commands/testConstantFunction.ts
  48. 27
      apps/remix-ide-e2e/src/commands/testContracts.ts
  49. 5
      apps/remix-ide-e2e/src/commands/testEditorValue.ts
  50. 24
      apps/remix-ide-e2e/src/commands/testFunction.ts
  51. 34
      apps/remix-ide-e2e/src/commands/verifyCallReturnValue.ts
  52. 21
      apps/remix-ide-e2e/src/commands/verifyContracts.ts
  53. 9
      apps/remix-ide-e2e/src/commands/waitForElementContainsText.ts
  54. 249
      apps/remix-ide-e2e/src/examples/example-contracts.ts
  55. 0
      apps/remix-ide-e2e/src/extensions/chrome/metamask.crx
  56. 27
      apps/remix-ide-e2e/src/helpers/init.ts
  57. 28
      apps/remix-ide-e2e/src/tests/ballot.test.ts
  58. 25
      apps/remix-ide-e2e/src/tests/compiler_api.test.ts
  59. 21
      apps/remix-ide-e2e/src/tests/debugger.test.ts
  60. 24
      apps/remix-ide-e2e/src/tests/defaultLayout.test.ts
  61. 30
      apps/remix-ide-e2e/src/tests/editor.test.ts
  62. 28
      apps/remix-ide-e2e/src/tests/fileExplorer.test.ts
  63. 27
      apps/remix-ide-e2e/src/tests/fileManager_api.test.ts
  64. 49
      apps/remix-ide-e2e/src/tests/generalSettings.test.ts
  65. 21
      apps/remix-ide-e2e/src/tests/gist.test.ts
  66. 127
      apps/remix-ide-e2e/src/tests/libraryDeployment.test.ts
  67. 23
      apps/remix-ide-e2e/src/tests/pluginManager.test.ts
  68. 27
      apps/remix-ide-e2e/src/tests/publishContract.test.ts
  69. 21
      apps/remix-ide-e2e/src/tests/recorder.test.ts
  70. 19
      apps/remix-ide-e2e/src/tests/remixd.test.ts
  71. 29
      apps/remix-ide-e2e/src/tests/runAndDeploy.ts
  72. 2
      apps/remix-ide-e2e/src/tests/sauce.ts
  73. 15
      apps/remix-ide-e2e/src/tests/signingMessage.test.ts
  74. 44
      apps/remix-ide-e2e/src/tests/solidityImport.test.ts
  75. 32
      apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts
  76. 42
      apps/remix-ide-e2e/src/tests/specialFunctions.test.ts
  77. 23
      apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts
  78. 21
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  79. 15
      apps/remix-ide-e2e/src/tests/transactionExecution.test.ts
  80. 13
      apps/remix-ide-e2e/src/tests/txListener.test.ts
  81. 19
      apps/remix-ide-e2e/src/tests/usingWebWorker.test.ts
  82. 11
      apps/remix-ide-e2e/src/tests/workspace.test.ts
  83. 84
      apps/remix-ide-e2e/src/types/index.d.ts
  84. 9
      apps/remix-ide-e2e/tsconfig.e2e.json
  85. 9
      apps/remix-ide-e2e/tsconfig.json
  86. 6
      apps/remix-ide/ci/browser_tests_chrome.sh
  87. 6
      apps/remix-ide/ci/browser_tests_firefox.sh
  88. 1
      apps/remix-ide/ci/browser_tests_run_deploy.sh
  89. 101
      apps/remix-ide/nightwatch_debugger.js
  90. 36
      apps/remix-ide/test-browser/commands/addFile.js
  91. 26
      apps/remix-ide/test-browser/commands/checkElementStyle.js
  92. 38
      apps/remix-ide/test-browser/commands/checkVariableDebug.js
  93. 24
      apps/remix-ide/test-browser/commands/clickElementAtPosition.js
  94. 18
      apps/remix-ide/test-browser/commands/getEditorValue.js
  95. 16
      apps/remix-ide/test-browser/commands/getModalBody.js
  96. 18
      apps/remix-ide/test-browser/commands/notContainsText.js
  97. 26
      apps/remix-ide/test-browser/commands/switchFile.js
  98. 27
      apps/remix-ide/test-browser/commands/testContracts.js
  99. 33
      apps/remix-ide/test-browser/commands/verifyCallReturnValue.js
  100. 13
      apps/remix-ide/test-browser/helpers/applytestmode.js
  101. Some files were not shown because too many files have changed in this diff Show More

@ -60,16 +60,16 @@ jobs:
java -version
- run:
name: Download Selenium
command: ./node_modules/.bin/selenium-standalone install --config=../remix-project/apps/remix-ide/seleniumConfig.js
command: ./node_modules/.bin/selenium-standalone install --config=../remix-project/apps/remix-ide-e2e/seleniumConfig.js
- run:
name: Start Selenium
command: ./node_modules/.bin/selenium-standalone start --config=../remix-project/apps/remix-ide/seleniumConfig.js
command: ./node_modules/.bin/selenium-standalone start --config=../remix-project/apps/remix-ide-e2e/seleniumConfig.js
background: true
- run: ./apps/remix-ide/ci/browser_tests_chrome.sh
- store_test_results:
path: ./apps/remix-ide/reports/tests
path: ./reports/tests
- store_artifacts:
path: ./apps/remix-ide/reports/screenshots
path: ./reports/screenshots
remix-ide-firefox:
docker:
@ -97,10 +97,10 @@ jobs:
- run: npm run build
- run:
name: Download Selenium
command: ./node_modules/.bin/selenium-standalone install --config=../remix-project/apps/remix-ide/seleniumConfig.js
command: ./node_modules/.bin/selenium-standalone install --config=../remix-project/apps/remix-ide-e2e/seleniumConfig.js
- run:
name: Start Selenium
command: ./node_modules/.bin/selenium-standalone start --config=../remix-project/apps/remix-ide/seleniumConfig.js
command: ./node_modules/.bin/selenium-standalone start --config=../remix-project/apps/remix-ide-e2e/seleniumConfig.js
background: true
- run:
name: Download Latest Firefox
@ -110,9 +110,9 @@ jobs:
command: sudo dpkg -i firefox-mozilla-build_73.0.1-0ubuntu1_amd64.deb
- run: ./apps/remix-ide/ci/browser_tests_firefox.sh
- store_test_results:
path: ./apps/remix-ide/reports/tests
path: ./reports/tests
- store_artifacts:
path: ./apps/remix-ide/reports/screenshots
path: ./reports/screenshots
remix-ide-run-deploy:
docker:
@ -147,14 +147,16 @@ jobs:
java -version
- run:
name: Download Selenium
command: ./node_modules/.bin/selenium-standalone install --config=../remix-project/apps/remix-ide/seleniumConfig.js
command: ./node_modules/.bin/selenium-standalone install --config=../remix-project/apps/remix-ide-e2e/seleniumConfig.js
- run:
name: Start Selenium
command: ./node_modules/.bin/selenium-standalone start --config=../remix-project/apps/remix-ide/seleniumConfig.js
command: ./node_modules/.bin/selenium-standalone start --config=../remix-project/apps/remix-ide-e2e/seleniumConfig.js
background: true
- run: ./apps/remix-ide/ci/browser_tests_run_deploy.sh
- store_test_results:
path: ./reports/tests
- store_artifacts:
path: ./apps/remix-ide/reports/screenshots
path: ./reports/screenshots
deploy-remix-live:
@ -186,8 +188,6 @@ jobs:
if [ "${CIRCLE_BRANCH}" == "remix_live" ]; then
./apps/remix-ide/ci/deploy_from_travis_remix-live.sh;
fi
- store_artifacts:
path: ./apps/remix-ide/reports/screenshots
publish:
docker:
@ -244,8 +244,6 @@ jobs:
if [ "${CIRCLE_BRANCH}" == "master" ]; then
./apps/remix-ide/ci/deploy_from_travis_remix-alpha.sh;
fi
- store_artifacts:
path: ./apps/remix-ide/reports/screenshots
workflows:
version: 2

2
.gitignore vendored

@ -4,7 +4,7 @@ build
dist
node_modules
lint.xml
test-browser/reports/*
reports/*
babelify-src
docs/_build
.DS_Store

@ -0,0 +1,14 @@
{
"rules": {},
"overrides": [
{
"files": ["**/*.ts"],
"rules": {
"no-undef": "off",
"@typescript-eslint/no-var-requires": 0
}
}
],
"extends": ["../../.eslintrc"],
"ignorePatterns": ["!**/*"]
}

@ -1,13 +1,12 @@
'use strict'
require('@babel/register')()
import * as fs from 'fs'
const crxFile = require('fs').readFileSync('apps/remix-ide/test-browser/extensions/chrome/metamask.crx')
const metamaskExtension = new Buffer.from(crxFile).toString('base64') // eslint-disable-line
const crxFile = fs.readFileSync('apps/remix-ide-e2e/src/extensions/chrome/metamask.crx')
const metamaskExtension = Buffer.from(crxFile).toString('base64')
module.exports = {
'src_folders': ['apps/remix-ide/test-browser/tests'],
'output_folder': 'apps/remix-ide/reports/tests',
'custom_commands_path': ['apps/remix-ide/test-browser/commands'],
'src_folders': ['dist/apps/remix-ide-e2e/src/tests'],
'output_folder': './reports/tests',
'custom_commands_path': ['dist/apps/remix-ide-e2e/src/commands'],
'custom_assertions_path': '',
'page_objects_path': '',
'globals_path': '',
@ -22,7 +21,7 @@ module.exports = {
},
'screenshots': {
'enabled': true,
'path': 'apps/remix-ide/reports/screenshots',
'path': './reports/screenshots',
'on_failure': true,
'on_error': true
},
@ -31,7 +30,7 @@ module.exports = {
'javascriptEnabled': true,
'acceptSslCerts': true
},
'exclude': ['apps/remix-ide/test-browser/tests/runAndDeploy.js']
'exclude': ['dist/apps/remix-ide-e2e/src/tests/runAndDeploy.js']
},
'chrome': {

@ -1,8 +1,9 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class addAtAddressInstance extends EventEmitter {
command (address, isValidFormat, isValidChecksum) {
this.api.perform((done) => {
command (this: NightwatchBrowser, address: string, isValidFormat: boolean, isValidChecksum: boolean): NightwatchBrowser {
this.api.perform((done: VoidFunction) => {
addInstance(this.api, address, isValidFormat, isValidChecksum, () => {
done()
this.emit('complete')
@ -12,12 +13,14 @@ class addAtAddressInstance extends EventEmitter {
}
}
function addInstance (browser, address, isValidFormat, isValidChecksum, callback) {
function addInstance (browser: NightwatchBrowser, address: string, isValidFormat: boolean, isValidChecksum: boolean, callback: VoidFunction) {
browser.clickLaunchIcon('udapp').clearValue('.ataddressinput').setValue('.ataddressinput', address, function () {
browser.click('button[id^="runAndDeployAtAdressButton"]')
.execute(function () {
var ret = document.querySelector('div[class^="modal-body"] div').innerHTML
document.querySelector('#modal-footer-ok').click()
const ret = document.querySelector('div[class^="modal-body"] div').innerHTML
const modal = document.querySelector('#modal-footer-ok') as HTMLElement
modal.click()
return ret
}, [], function (result) {
if (!isValidFormat) {

@ -0,0 +1,39 @@
import { NightwatchBrowser, NightwatchContractContent } from 'nightwatch'
import EventEmitter from "events"
class AddFile extends EventEmitter {
command (this: NightwatchBrowser, name: string, content: NightwatchContractContent): NightwatchBrowser {
this.api.perform((done) => {
addFile(this.api, name, content, () => {
done()
this.emit('complete')
})
})
return this
}
}
function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) {
browser.clickLaunchIcon('udapp').clickLaunchIcon('fileExplorers').click('.newFile')
.waitForElementVisible('#modal-dialog')
.perform((client, done) => {
browser.execute(function (fileName) {
if (fileName !== 'Untitled.sol') {
document.querySelector('#modal-dialog #prompt_text').setAttribute('value', fileName)
}
const elem = document.querySelector('#modal-footer-ok') as HTMLElement
elem.click()
}, [name], function (result) {
console.log(result)
done()
})
})
.setEditorValue(content.content)
.pause(1000)
.perform(function () {
done()
})
}
module.exports = AddFile

@ -0,0 +1,31 @@
import EventEmitter from 'events'
import { NightwatchBrowser } from 'nightwatch'
class checkElementStyle extends EventEmitter {
command (this: NightwatchBrowser, cssSelector: string, styleProperty: string, expectedResult: string): NightwatchBrowser {
this.api.perform((done) => {
checkStyle(this.api, cssSelector, styleProperty, expectedResult, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkStyle (browser: NightwatchBrowser, cssSelector: string, styleProperty: string, expectedResult: string, callback: VoidFunction) {
browser.execute(function (cssSelector, styleProperty) {
return window.getComputedStyle(document.querySelector(cssSelector)).getPropertyValue(styleProperty)
}, [cssSelector, styleProperty], function (result) {
const value = result.value
if (typeof value === 'string') {
browser.assert.equal(value.trim().toLowerCase(), expectedResult.toLowerCase())
} else {
browser.assert.fail('Failed with error info :', result.value.toString())
}
callback()
})
}
module.exports = checkElementStyle

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import EventEmitter from 'events'
import { NightwatchBrowser } from 'nightwatch'
class CheckTerminalFilter extends EventEmitter {
command (filter, test) {
command (this: NightwatchBrowser, filter: string, test: string): NightwatchBrowser {
this.api.perform((done) => {
checkFilter(this.api, filter, test, () => {
done()
@ -12,7 +13,7 @@ class CheckTerminalFilter extends EventEmitter {
}
}
function checkFilter (browser, filter, test, done) {
function checkFilter (browser: NightwatchBrowser, filter: string, test: string, done: VoidFunction) {
if (browser.options.desiredCapabilities.browserName === 'chrome') { // nightwatch deos not handle well that part.... works locally
done()
return

@ -0,0 +1,42 @@
import { NightwatchBrowser, NightwatchCheckVariableDebugValue } from 'nightwatch'
import EventEmitter from "events"
const deepequal = require('deep-equal')
class CheckVariableDebug extends EventEmitter {
command (this: NightwatchBrowser, id: string, debugValue: NightwatchCheckVariableDebugValue): NightwatchBrowser {
this.api.perform((done) => {
checkDebug(this.api, id, debugValue, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkDebug (browser: NightwatchBrowser, id: string, debugValue: NightwatchCheckVariableDebugValue, done: VoidFunction) {
// id is soliditylocals or soliditystate
browser.execute(function (id: string) {
const elem = document.querySelector('#' + id + ' .dropdownrawcontent') as HTMLElement
return elem.innerText
}, [id], function (result) {
console.log(id + ' ' + result.value)
let value
try {
value = JSON.parse(<string>result.value)
} catch (e) {
browser.assert.fail('cant parse solidity state', e.message, '')
done()
return
}
const equal = deepequal(debugValue, value)
if (!equal) {
browser.assert.fail('checkDebug on ' + id, 'info about error\n ' + JSON.stringify(debugValue) + '\n ' + JSON.stringify(value), '')
}
done()
})
}
module.exports = CheckVariableDebug

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class clearEditablecontent extends EventEmitter {
command (cssSelector) {
command (this: NightwatchBrowser, cssSelector: string): NightwatchBrowser {
this.api.perform((done) => {
clearContent(this.api, cssSelector, () => {
done()
@ -12,7 +13,7 @@ class clearEditablecontent extends EventEmitter {
}
}
function clearContent (browser, cssSelector, callback) {
function clearContent (browser: NightwatchBrowser, cssSelector: string, callback: VoidFunction) {
browser.execute(function (cssSelector) {
const selection = window.getSelection()
const range = document.createRange()

@ -0,0 +1,27 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class ClickElement extends EventEmitter {
command (this: NightwatchBrowser, cssSelector: string, index = 0): NightwatchBrowser {
this.api.perform((done) => {
_clickElement(this.api, cssSelector, index, () => {
done()
this.emit('complete')
})
})
return this
}
}
function _clickElement (browser: NightwatchBrowser, cssSelector: string, index: number, cb: VoidFunction) {
browser.waitForElementPresent(cssSelector)
.execute(function (cssSelector: string, index: number) {
const elem = document.querySelectorAll(cssSelector)[index] as HTMLElement
elem.click()
}, [cssSelector, index], function () {
cb()
})
}
module.exports = ClickElement

@ -1,14 +1,15 @@
const EventEmitter = require('events')
import { NightwatchBrowser, NightwatchClickFunctionExpectedInput } from 'nightwatch'
import EventEmitter from "events"
class ClickFunction extends EventEmitter {
command (fnFullName, expectedInput) {
command (this: NightwatchBrowser, fnFullName: string, expectedInput?: NightwatchClickFunctionExpectedInput): NightwatchBrowser {
this.api.waitForElementPresent('.instance button[title="' + fnFullName + '"]')
.perform(function (client, done) {
client.execute(function () {
document.querySelector('#runTabView').scrollTop = document.querySelector('#runTabView').scrollHeight
}, [], function () {
if (expectedInput) {
client.setValue('#runTabView input[title="' + expectedInput.types + '"]', expectedInput.values, function () {})
client.setValue('#runTabView input[title="' + expectedInput.types + '"]', expectedInput.values, _ => _)
}
done()
})

@ -1,9 +1,11 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class ClickInstance extends EventEmitter {
command (index) {
command (this: NightwatchBrowser, index: number): NightwatchBrowser {
index = index + 2
let selector = '.instance:nth-of-type(' + index + ') > div > button'
const selector = '.instance:nth-of-type(' + index + ') > div > button'
this.api.waitForElementPresent(selector).scrollAndClick(selector).perform(() => { this.emit('complete') })
return this
}

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class ClickLaunchIcon extends EventEmitter {
command (icon) {
command (this: NightwatchBrowser, icon: string): NightwatchBrowser {
this.api.waitForElementVisible('#icon-panel div[plugin="' + icon + '"]').click('#icon-panel div[plugin="' + icon + '"]').perform((done) => {
done()
this.emit('complete')

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class CreateContract extends EventEmitter {
command (inputParams) {
command (this: NightwatchBrowser, inputParams: string): NightwatchBrowser {
this.api.perform((done) => {
createContract(this.api, inputParams, () => {
done()
@ -12,7 +13,7 @@ class CreateContract extends EventEmitter {
}
}
function createContract (browser, inputParams, callback) {
function createContract (browser: NightwatchBrowser, inputParams: string, callback: VoidFunction) {
if (inputParams) {
browser.clickLaunchIcon('settings').clickLaunchIcon('udapp')
.setValue('div[class^="contractActionsContainerSingle"] input', inputParams, function () {

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class debugTransaction extends EventEmitter {
command (index = 0) {
command (this: NightwatchBrowser, index = 0): NightwatchBrowser {
this.api.perform((done) => {
checkStyle(this.api, index, () => {
done()
@ -12,9 +13,9 @@ class debugTransaction extends EventEmitter {
}
}
function checkStyle (browser, index, callback) {
browser.pause(2000).execute(function (index) {
const debugBtn = document.querySelectorAll('*[data-shared="txLoggerDebugButton"]')[index]
function checkStyle (browser: NightwatchBrowser, index: number, callback: VoidFunction) {
browser.pause(2000).execute(function (index: number) {
const debugBtn = document.querySelectorAll('*[data-shared="txLoggerDebugButton"]')[index] as HTMLInputElement
debugBtn.click()
}, [index], function () {

@ -1,8 +1,9 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
// fix for editor scroll
class ScrollEditor extends EventEmitter {
command (direction, numberOfTimes) {
command (this: NightwatchBrowser, direction: 'up' | 'down', numberOfTimes: number): NightwatchBrowser {
const browser = this.api
browser.waitForElementPresent('.ace_text-input')

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class ExecuteScript extends EventEmitter {
command (script) {
command (this: NightwatchBrowser, script: string): NightwatchBrowser {
this.api
.clearEditableContent('*[data-id="terminalCliInput"]')
.click('*[data-id="terminalCli"]')

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class GetAddressAtPosition extends EventEmitter {
command (index, cb) {
command (this: NightwatchBrowser, index: number, cb: (pos: string) => void): NightwatchBrowser {
this.api.perform((done) => {
getAddressAtPosition(this.api, index, (pos) => {
done()
@ -13,7 +14,7 @@ class GetAddressAtPosition extends EventEmitter {
}
}
function getAddressAtPosition (browser, index, callback) {
function getAddressAtPosition (browser: NightwatchBrowser, index: number, callback: (pos: string) => void) {
browser.waitForElementPresent('*[data-shared="universalDappUiInstance"]')
.execute(function (index) {
const deployedContracts = document.querySelectorAll('*[data-shared="universalDappUiInstance"]')
@ -21,7 +22,9 @@ function getAddressAtPosition (browser, index, callback) {
return id.replace('instance', '')
}, [index], function (result) {
callback(result.value)
const pos = typeof result.value === 'string' ? result.value : null
callback(pos)
})
}

@ -0,0 +1,23 @@
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class GetEditorValue extends EventEmitter {
command (this: NightwatchBrowser, callback: (content: string) => void): NightwatchBrowser {
this.api.perform((client, done) => {
this.api.execute(function () {
const elem: any = document.getElementById('input')
return elem.editor.getValue()
}, [], (result) => {
done()
const value = typeof result.value === 'string' ? result.value : null
callback(value)
this.emit('complete')
})
})
return this
}
}
module.exports = GetEditorValue

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class GetInstalledPlugins extends EventEmitter {
command (cb) {
command (this: NightwatchBrowser, cb: (plugins: string[]) => void): NightwatchBrowser {
const browser = this.api
browser.waitForElementPresent('[plugin]:not([plugin=""]')
@ -16,7 +17,7 @@ class GetInstalledPlugins extends EventEmitter {
return pluginNames
}, [], (result) => {
done()
cb(result.value)
Array.isArray(result.value) && cb(result.value)
this.emit('complete')
})
})

@ -0,0 +1,19 @@
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class GetModalBody extends EventEmitter {
command (this: NightwatchBrowser, callback: (value: string, cb: VoidFunction) => void) {
this.api.waitForElementVisible('.modal-body')
.getText('.modal-body', (result) => {
console.log(result)
const value = typeof result.value === 'string' ? result.value : null
callback(value, () => {
this.emit('complete')
})
})
return this
}
}
module.exports = GetModalBody

@ -1,7 +1,7 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class GoToVmTraceStep extends EventEmitter {
command (step, incr) {
command (this: NightwatchBrowser, step: number, incr?: number): NightwatchBrowser {
this.api.perform((done) => {
goToVMtraceStep(this.api, step, incr, () => {
done()
@ -12,12 +12,12 @@ class GoToVmTraceStep extends EventEmitter {
}
}
function goToVMtraceStep (browser, step, incr, done) {
function goToVMtraceStep (browser: NightwatchBrowser, step: number, incr: number, done: VoidFunction) {
if (!incr) incr = 0
browser.execute(function (step) {
browser.execute(function () {
return document.querySelector('#stepdetail').innerHTML
}, [step], function (result) {
if (result.value.indexOf('vm trace step:') !== -1 && result.value.indexOf(step) !== -1) {
}, [], function (result) {
if (typeof result.value === 'string' && ( result.value.indexOf('vm trace step:') !== -1 && result.value.indexOf(step.toString()) !== -1)) {
done()
} else if (incr > 1000) {
browser.assert.fail('goToVMtraceStep fails', 'info about error', '')

@ -1,21 +1,22 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
/*
Checks if any child elements of journal (console) contains a matching value.
*/
class JournalChildIncludes extends EventEmitter {
command (val) {
command (this: NightwatchBrowser, val: string): NightwatchBrowser {
let isTextFound = false
const browser = this.api
this.api.elements('css selector', '*[data-id="terminalJournal"]', (res) => {
res.value.forEach(function (jsonWebElement) {
Array.isArray(res.value) && res.value.forEach(function (jsonWebElement) {
const jsonWebElementId = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]]
browser.elementIdText(jsonWebElementId, (jsonElement) => {
const text = jsonElement.value
if (text.indexOf(val) !== -1) isTextFound = true
if (typeof text === 'string' && text.indexOf(val) !== -1) isTextFound = true
})
})
})

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class JournalLastChild extends EventEmitter {
command (val) {
command (this: NightwatchBrowser, val: string): NightwatchBrowser {
this.api
.waitForElementVisible('*[data-id="terminalJournal"] > div:last-child', 10000)
.assert.containsText('*[data-id="terminalJournal"] > div:last-child', val).perform(() => {

@ -1,16 +1,17 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
/*
Check if the last log in the console contains a specific text
*/
class JournalLastChildIncludes extends EventEmitter {
command (val) {
command (this: NightwatchBrowser, val: string): NightwatchBrowser {
this.api
.waitForElementVisible('*[data-id="terminalJournal"] > div:last-child', 10000)
.getText('*[data-id="terminalJournal"] > div:last-child', (result) => {
console.log('JournalLastChildIncludes', result.value)
if (result.value.indexOf(val) === -1) return this.api.assert.fail(`wait for ${val} in ${result.value}`)
else this.api.assert.ok(`<*[data-id="terminalJournal"] > div:last-child> contains ${val}.`)
if (typeof result.value === 'string' && result.value.indexOf(val) === -1) return this.api.assert.fail(`wait for ${val} in ${result.value}`)
else this.api.assert.ok(true, `<*[data-id="terminalJournal"] > div:last-child> contains ${val}.`)
this.emit('complete')
})
return this

@ -1,11 +1,14 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class ModalFooterOKClick extends EventEmitter {
command () {
command (this: NightwatchBrowser): NightwatchBrowser {
this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => {
this.api.execute(function () {
document.querySelector('#modal-footer-cancel').click()
}, [], (result) => {
const elem = document.querySelector('#modal-footer-cancel') as HTMLElement
elem.click()
}, [], () => {
done()
this.emit('complete')
})

@ -1,11 +1,14 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class ModalFooterOKClick extends EventEmitter {
command () {
command (this: NightwatchBrowser): NightwatchBrowser {
this.api.waitForElementVisible('#modal-footer-ok').perform((client, done) => {
this.api.execute(function () {
document.querySelector('#modal-footer-ok').click()
}, [], (result) => {
const elem = document.querySelector('#modal-footer-ok') as HTMLElement
elem.click()
}, [], () => {
done()
this.emit('complete')
})

@ -1,8 +1,9 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class NoWorkerErrorFor extends EventEmitter {
command (version) {
this.api.perform((done) => {
command (this: NightwatchBrowser, version: string): NightwatchBrowser {
this.api.perform((done: VoidFunction) => {
noWorkerErrorFor(this.api, version, () => {
done()
this.emit('complete')
@ -12,7 +13,7 @@ class NoWorkerErrorFor extends EventEmitter {
}
}
function noWorkerErrorFor (browser, version, callback) {
function noWorkerErrorFor (browser: NightwatchBrowser, version: string, callback: VoidFunction) {
browser
.setSolidityCompilerVersion(version)
.click('*[data-id="compilerContainerCompileBtn"]')

@ -0,0 +1,19 @@
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class NotContainsText extends EventEmitter {
command (this: NightwatchBrowser, cssSelector: string, text: string): NightwatchBrowser {
const browser = this.api
browser.getText(cssSelector, (result) => {
if (typeof result.value === 'string' && result.value.includes(text)) return this.api.assert.fail(`${cssSelector} contains ${text}.`)
else this.api.assert.ok(true, `${cssSelector} does not contains ${text}.`)
})
.perform(() => {
this.emit('complete')
})
return this
}
}
module.exports = NotContainsText

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class OpenFile extends EventEmitter {
command (name) {
command (this: NightwatchBrowser, name: string) {
this.api.perform((done) => {
openFile(this.api, name, () => {
done()
@ -13,7 +14,7 @@ class OpenFile extends EventEmitter {
}
// click on fileExplorer can toggle it. We go through settings to be sure FE is open
function openFile (browser, name, done) {
function openFile (browser: NightwatchBrowser, name: string, done: VoidFunction) {
browser.clickLaunchIcon('settings').clickLaunchIcon('fileExplorers')
.waitForElementVisible('li[key="' + name + '"]')
.click('li[key="' + name + '"]')

@ -1,7 +1,9 @@
import { NightwatchBrowser } from "nightwatch"
const EventEmitter = require('events')
class RemoveFile extends EventEmitter {
command (path) {
command (this: NightwatchBrowser, path: string): NightwatchBrowser {
this.api.perform((done) => {
removeFile(this.api, path, () => {
done()
@ -12,15 +14,16 @@ class RemoveFile extends EventEmitter {
}
}
function removeFile (browser, path, done) {
function removeFile (browser: NightwatchBrowser, path: string, done: VoidFunction) {
browser.execute(function (path) {
function contextMenuClick (element) {
var evt = element.ownerDocument.createEvent('MouseEvents')
var RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
const evt = element.ownerDocument.createEvent('MouseEvents')
const RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null)
if (document.createEventObject) {
if (Object.prototype.hasOwnProperty.call(document, 'createEventObject')) {
// dispatch for IE
return element.fireEvent('onclick', evt)
} else {
@ -29,7 +32,7 @@ function removeFile (browser, path, done) {
}
}
contextMenuClick(document.querySelector('[data-path="' + path + '"]'))
}, [path], function (result) {
}, [path], function () {
browser
.waitForElementVisible('#menuitemdelete', 2000)
.click('#menuitemdelete')

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import EventEmitter from 'events'
import { NightwatchBrowser } from 'nightwatch'
class RenameFile extends EventEmitter {
command (path, newFileName, renamedPath) {
command (this: NightwatchBrowser, path: string, newFileName: string, renamedPath: string) {
this.api.perform((done) => {
renameFile(this.api, path, newFileName, renamedPath, () => {
done()
@ -12,15 +13,16 @@ class RenameFile extends EventEmitter {
}
}
function renameFile (browser, path, newFileName, renamedPath, done) {
browser.execute(function (path) {
function renameFile (browser: NightwatchBrowser, path: string, newFileName: string, renamedPath: string, done: VoidFunction) {
browser.execute(function (path: string) {
function contextMenuClick (element) {
var evt = element.ownerDocument.createEvent('MouseEvents')
var RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
const evt = element.ownerDocument.createEvent('MouseEvents')
const RIGHT_CLICK_BUTTON_CODE = 2 // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null)
if (document.createEventObject) {
if (Object.prototype.hasOwnProperty.call(document, 'createEventObject')) {
// dispatch for IE
return element.fireEvent('onclick', evt)
} else {
@ -29,7 +31,7 @@ function renameFile (browser, path, newFileName, renamedPath, done) {
}
}
contextMenuClick(document.querySelector('[data-path="' + path + '"]'))
}, [path], function (result) {
}, [path], function () {
browser
.click('#menuitemrename')
.perform((client, doneSetValue) => {
@ -51,4 +53,4 @@ function renameFile (browser, path, newFileName, renamedPath, done) {
})
}
module.exports = RenameFile
module.exports = RenameFile

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import EventEmitter from 'events'
import { NightwatchBrowser } from 'nightwatch'
class RightClick extends EventEmitter {
command (cssSelector) {
command (this: NightwatchBrowser, cssSelector: string) {
this.api.perform((done) => {
rightClick(this.api, cssSelector, () => {
done()
@ -12,16 +13,16 @@ class RightClick extends EventEmitter {
}
}
function rightClick (browser, cssSelector, callback) {
browser.execute(function (cssSelector) {
const element = document.querySelector(cssSelector)
function rightClick (browser: NightwatchBrowser, cssSelector: string, callback: VoidFunction) {
browser.execute(function (cssSelector: string) {
const element: any = document.querySelector(cssSelector)
const evt = element.ownerDocument.createEvent('MouseEvents')
const RIGHT_CLICK_BUTTON_CODE = 2
evt.initMouseEvent('contextmenu', true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null)
if (document.createEventObject) {
if (Object.prototype.hasOwnProperty.call(document, 'createEventObject')) {
// dispatch for IE
return element.fireEvent('onclick', evt)
} else {

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class scrollAndClick extends EventEmitter {
command (target) {
command (this: NightwatchBrowser, target: string): NightwatchBrowser {
this.api
.scrollInto(target)
.click(target)

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class ScrollInto extends EventEmitter {
command (target) {
command (this: NightwatchBrowser, target: string): NightwatchBrowser {
this.api.perform((client, done) => {
_scrollInto(this.api, target, () => {
done()
@ -12,7 +13,7 @@ class ScrollInto extends EventEmitter {
}
}
function _scrollInto (browser, target, cb) {
function _scrollInto (browser: NightwatchBrowser, target: string, cb: VoidFunction): void {
browser.execute(function (target) {
document.querySelector(target).scrollIntoView(({block: 'center'}))
}, [target], function () {

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class SelectAccount extends EventEmitter {
command (account) {
command (this: NightwatchBrowser, account?: string): NightwatchBrowser {
if (account) {
this.api
.click(`select[data-id="runTabSelectAccount"] [value="${account}"]`)

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class SelectContract extends EventEmitter {
command (contractName) {
command (this: NightwatchBrowser, contractName: string): NightwatchBrowser {
this.api.perform((done) => {
selectContract(this.api, contractName, () => {
done()
@ -12,7 +13,7 @@ class SelectContract extends EventEmitter {
}
}
function selectContract (browser, contractName, callback) {
function selectContract (browser: NightwatchBrowser, contractName: string, callback: VoidFunction) {
browser.clickLaunchIcon('settings').clickLaunchIcon('udapp')
.setValue('#runTabView select[class^="contractNames"]', contractName).perform(() => {
callback()

@ -1,6 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class sendLowLevelTx extends EventEmitter {
command (address, value, callData) {
command (this: NightwatchBrowser, address: string, value: string, callData: string): NightwatchBrowser {
console.log('low level transact to ', address, value, callData)
this.api.waitForElementVisible(`#instance${address} #deployAndRunLLTxSendTransaction`, 1000)
.clearValue(`#instance${address} #deployAndRunLLTxCalldata`)

@ -1,11 +1,14 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class SetEditorValue extends EventEmitter {
command (value, callback) {
command (this: NightwatchBrowser, value: string, callback?: VoidFunction): NightwatchBrowser {
this.api.perform((client, done) => {
this.api.execute(function (value) {
document.getElementById('input').editor.session.setValue(value)
}, [value], (result) => {
const elem: any = document.getElementById('input')
elem.editor.session.setValue(value)
}, [value], () => {
done()
if (callback) {
callback.call(this.api)

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class SetSolidityCompilerVersion extends EventEmitter {
command (version) {
command (this: NightwatchBrowser, version: string): NightwatchBrowser {
this.api
.click(`#compileTabView #versionSelector [value="${version}"]`)
.pause(5000)

@ -1,7 +1,9 @@
import { NightwatchBrowser } from "nightwatch"
const EventEmitter = require('events')
class MetaMask extends EventEmitter {
command (passphrase, password) {
command (this: NightwatchBrowser, passphrase: string, password: string): NightwatchBrowser {
this.api.perform((done) => {
setupMetaMask(this.api, passphrase, password, () => {
done()
@ -12,7 +14,7 @@ class MetaMask extends EventEmitter {
}
}
function setupMetaMask (browser, passphrase, password, done) {
function setupMetaMask (browser: NightwatchBrowser, passphrase: string, password: string, done: VoidFunction) {
browser
.switchBrowserWindow('chrome-extension://poemojpkcjbpmcccohjnomjffeinlafe/home.html#initialize/welcome', 'MetaMask', (browser) => {
browser.waitForElementPresent('.first-time-flow__button')

@ -1,7 +1,9 @@
import { NightwatchBrowser } from "nightwatch"
const EventEmitter = require('events')
class SelectContract extends EventEmitter {
command (msg, callback) {
command (this: NightwatchBrowser, msg: string, callback: (hash: { value: string }, signature: { value: string }) => void): NightwatchBrowser {
this.api.perform((done) => {
signMsg(this.api, msg, (hash, signature) => {
callback(hash, signature)
@ -13,7 +15,7 @@ class SelectContract extends EventEmitter {
}
}
function signMsg (browser, msg, cb) {
function signMsg (browser: NightwatchBrowser, msg: string, cb: (hash: { value: string }, signature: { value: string }) => void) {
let hash, signature
browser
.waitForElementPresent('i[id="remixRunSignMsg"]')

@ -1,12 +1,13 @@
const EventEmitter = require('events')
import { NightwatchBrowser, NightwatchAPI } from "nightwatch"
import EventEmitter from "events"
/*
Switches between browser tabs
*/
class SwitchBrowserTab extends EventEmitter {
command (index) {
this.api.perform((browser, done) => {
command (this: NightwatchBrowser, index: number): NightwatchBrowser {
this.api.perform((browser: NightwatchAPI, done) => {
browser.windowHandles((result) => {
browser.switchWindow(result.value[index])
done()

@ -1,7 +1,9 @@
import { NightwatchBrowser, NightwatchCallbackResult } from "nightwatch"
const EventEmitter = require('events')
class SwitchBrowserWindow extends EventEmitter {
command (url, windowName, cb) {
command (this: NightwatchBrowser, url: string, windowName: string, cb: (browser: NightwatchBrowser, window?: NightwatchCallbackResult<Window>) => void): NightwatchBrowser {
this.api.perform((done) => {
switchWindow(this.api, url, windowName, cb)
done()
@ -11,7 +13,7 @@ class SwitchBrowserWindow extends EventEmitter {
}
}
function switchWindow (browser, url, windowName, cb) {
function switchWindow (browser: NightwatchBrowser, url: string, windowName: string, cb: (browser: NightwatchBrowser, window: NightwatchCallbackResult<Window>) => void) {
browser.execute(function (windowName) {
return window.open('', windowName, 'width=2560, height=1440')
}, [windowName], (newWindow) => {

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser, NightwatchTestConstantFunctionExpectedInput } from "nightwatch"
import EventEmitter from "events"
class TestConstantFunction extends EventEmitter {
command (address, fnFullName, expectedInput, expectedOutput) {
command (this: NightwatchBrowser, address: string, fnFullName: string, expectedInput: NightwatchTestConstantFunctionExpectedInput | null, expectedOutput: string): NightwatchBrowser {
console.log('TestConstantFunction ' + address + ' fnFullName')
this.api.perform((done) => {
testConstantFunction(this.api, address, fnFullName, expectedInput, expectedOutput, () => {
@ -13,13 +14,13 @@ class TestConstantFunction extends EventEmitter {
}
}
function testConstantFunction (browser, address, fnFullName, expectedInput, expectedOutput, cb) {
function testConstantFunction (browser: NightwatchBrowser, address: string, fnFullName: string, expectedInput: NightwatchTestConstantFunctionExpectedInput, expectedOutput: string, cb: VoidFunction) {
browser.waitForElementPresent('.instance button[title="' + fnFullName + '"]').perform(function (client, done) {
client.execute(function () {
document.querySelector('#runTabView').scrollTop = document.querySelector('#runTabView').scrollHeight
}, [], function () {
if (expectedInput) {
client.setValue('#runTabView input[title="' + expectedInput.types + '"]', expectedInput.values, function () {})
client.setValue('#runTabView input[title="' + expectedInput.types + '"]', expectedInput.values)
}
done()
})

@ -0,0 +1,27 @@
import { NightwatchBrowser, NightwatchContractContent } from 'nightwatch'
import EventEmitter from "events"
class TestContracts extends EventEmitter {
command (this: NightwatchBrowser,fileName: string, contractCode: NightwatchContractContent, compiledContractNames: string[]): NightwatchBrowser {
this.api.perform((done) => {
testContracts(this.api, fileName, contractCode, compiledContractNames, () => {
done()
this.emit('complete')
})
})
return this
}
}
function testContracts (browser: NightwatchBrowser, fileName: string, contractCode: NightwatchContractContent, compiledContractNames: string[], callback: VoidFunction) {
browser
.clickLaunchIcon('solidity')
.addFile(fileName, contractCode)
.pause(1000)
.verifyContracts(compiledContractNames)
.perform(() => {
callback()
})
}
module.exports = TestContracts

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class TestEditorValue extends EventEmitter {
command (testvalue) {
command (this: NightwatchBrowser, testvalue: string): NightwatchBrowser {
this.api.getEditorValue((value) => {
this.api.assert.equal(testvalue, value)
this.emit('complete')

@ -1,11 +1,13 @@
const EventEmitter = require('events')
import { NightwatchBrowser, NightwatchTestFunctionExpectedInput } from 'nightwatch'
import EventEmitter from "events"
const deepequal = require('deep-equal')
class TestFunction extends EventEmitter {
command (txHash, expectedValue) {
command (this: NightwatchBrowser, txHash: string, expectedValue: NightwatchTestFunctionExpectedInput): NightwatchBrowser {
const browser = this.api
const logs = {}
const setLog = (index, value) => { logs[Object.keys(logs)[index]] = typeof value === 'string' ? value.trim() : value }
const setLog = (index: number, value: string) => { logs[Object.keys(logs)[index]] = typeof value === 'string' ? value.trim() : value }
browser
.waitForElementVisible(`[data-id="block_tx${txHash}"]`)
@ -14,28 +16,28 @@ class TestFunction extends EventEmitter {
// fetch and format transaction logs as key => pair object
.elements('css selector', `*[data-shared="key_${txHash}"]`, (res) => {
res.value.forEach(function (jsonWebElement) {
const jsonWebElementId = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]]
Array.isArray(res.value) && res.value.forEach(function (jsonWebElement) {
const jsonWebElementId: string = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]]
browser.elementIdText(jsonWebElementId, (jsonElement) => {
const key = jsonElement.value.trim()
const key = typeof jsonElement.value === 'string' ? jsonElement.value.trim() : null
logs[key] = null
})
})
})
.elements('css selector', `*[data-shared="pair_${txHash}"]`, (res) => {
res.value.forEach(function (jsonWebElement, index) {
Array.isArray(res.value) && res.value.forEach(function (jsonWebElement, index) {
const jsonWebElementId = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]]
browser.elementIdText(jsonWebElementId, (jsonElement) => {
let value = jsonElement.value
try {
value = JSON.parse(jsonElement.value)
setLog(index, value)
value = JSON.parse(<string>jsonElement.value)
setLog(index, <string>value)
} catch (e) {
setLog(index, value)
setLog(index, <string>value)
}
})
})
@ -43,7 +45,7 @@ class TestFunction extends EventEmitter {
browser.perform(() => {
Object.keys(expectedValue).forEach(key => {
const equal = deepequal(logs[key], expectedValue[key])
const equal: boolean = deepequal(logs[key], expectedValue[key])
if (!equal) {
browser.assert.fail(`Expected ${expectedValue[key]} but got ${logs[key]}`)

@ -0,0 +1,34 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class VerifyCallReturnValue extends EventEmitter {
command (this: NightwatchBrowser, address: string, checks: string[]): NightwatchBrowser {
this.api.perform((done) => {
verifyCallReturnValue(this.api, address, checks, () => {
done()
this.emit('complete')
})
})
return this
}
}
function verifyCallReturnValue (browser: NightwatchBrowser, address: string, checks: string[], done: VoidFunction) {
browser.execute(function (address: string) {
const nodes = document.querySelectorAll('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]') as NodeListOf<HTMLElement>
const ret = []
for (let k = 0; k < nodes.length; k++) {
const text = nodes[k].innerText ? nodes[k].innerText : nodes[k].textContent
ret.push(text.replace('\n', ''))
}
return ret
}, [address], function (result) {
console.log('verifyCallReturnValue', result)
for (const k in checks) {
browser.assert.equal(result.value[k].trim(), checks[k].trim())
}
done()
})
}
module.exports = VerifyCallReturnValue

@ -1,7 +1,8 @@
const EventEmitter = require('events')
import { NightwatchBrowser, NightwatchCallbackResult } from 'nightwatch'
import EventEmitter from "events"
class VerifyContracts extends EventEmitter {
command (compiledContractNames, opts = { wait: 1000, version: null }) {
command (this: NightwatchBrowser,compiledContractNames: string[], opts = { wait: 1000, version: null }): NightwatchBrowser {
this.api.perform((done) => {
verifyContracts(this.api, compiledContractNames, opts, () => {
done()
@ -12,7 +13,7 @@ class VerifyContracts extends EventEmitter {
}
}
function getCompiledContracts (browser, opts, callback) {
function getCompiledContracts (browser: NightwatchBrowser, opts: { wait: number, version?: string }, callback: (result: NightwatchCallbackResult<any>) => void) {
browser
.clickLaunchIcon('solidity')
.pause(opts.wait)
@ -30,12 +31,14 @@ function getCompiledContracts (browser, opts, callback) {
} else done()
})
.execute(function () {
var contracts = document.querySelectorAll('*[data-id="compiledContracts"] option')
const contracts = document.querySelectorAll('*[data-id="compiledContracts"] option') as NodeListOf<HTMLInputElement>
if (!contracts) {
return null
} else {
var ret = []
for (var c = 0; c < contracts.length; c++) {
const ret = []
for (let c = 0; c < contracts.length; c++) {
ret.push(contracts[c].value)
}
return ret
@ -45,10 +48,10 @@ function getCompiledContracts (browser, opts, callback) {
})
}
function verifyContracts (browser, compiledContractNames, opts, callback) {
getCompiledContracts(browser, opts, (result) => {
function verifyContracts (browser: NightwatchBrowser, compiledContractNames: string[], opts: { wait: number, version?: string }, callback: VoidFunction) {
getCompiledContracts(browser, opts, (result: NightwatchCallbackResult<any>) => {
if (result.value) {
for (var contract in compiledContractNames) {
for (const contract in compiledContractNames) {
console.log(' - ' + compiledContractNames[contract], result.value)
if (result.value.indexOf(compiledContractNames[contract]) === -1) {
browser.assert.fail('compiled contract ' + compiledContractNames + ' not found', 'info about error', '')

@ -1,11 +1,12 @@
const EventEmitter = require('events')
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class WaitForElementContainsText extends EventEmitter {
command (id, value) {
command (this: NightwatchBrowser, id: string, value: string): NightwatchBrowser {
let incr = 0
let runid = setInterval(() => {
const runid = setInterval(() => {
this.api.getText(id, (result) => {
if (value.indexOf(result.value || '') !== -1) {
if (typeof result.value === 'string' && value.indexOf(result.value || '') !== -1) {
clearInterval(runid)
this.api.assert.ok(true, `WaitForElementContainsText ${id} contains ${value}`)
this.emit('complete')

@ -0,0 +1,249 @@
'use strict'
const storage = `pragma solidity >=0.4.22 <0.7.0;
/**
* @title Storage
* @dev Store & retreive value in a variable
*/
contract Storage {
uint256 number;
/**
* @dev Store value in variable
* @param num value to store
*/
function store(uint256 num) public {
number = num;
}
/**
* @dev Return value
* @return value of 'number'
*/
function retreive() public view returns (uint256){
return number;
}
}`
const owner = `pragma solidity >=0.4.22 <0.7.0;
/**
* @title Owner
* @dev Set & change owner
*/
contract Owner {
address private owner;
// event for EVM logging
event OwnerSet(address indexed oldOwner, address indexed newOwner);
// modifier to check if caller is owner
modifier isOwner() {
// If the first argument of 'require' evaluates to 'false', execution terminates and all
// changes to the state and to Ether balances are reverted.
// This used to consume all gas in old EVM versions, but not anymore.
// It is often a good idea to use 'require' to check if functions are called correctly.
// As a second argument, you can also provide an explanation about what went wrong.
require(msg.sender == owner, "Caller is not owner");
_;
}
/**
* @dev Set contract deployer as owner
*/
constructor() public {
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
emit OwnerSet(address(0), owner);
}
/**
* @dev Change owner
* @param newOwner address of new owner
*/
function changeOwner(address newOwner) public isOwner {
emit OwnerSet(owner, newOwner);
owner = newOwner;
}
/**
* @dev Return owner address
* @return address of owner
*/
function getOwner() external view returns (address) {
return owner;
}
}`
const ballot = `pragma solidity >=0.4.22 <0.7.0;
/**
* @title Ballot
* @dev Implements voting process along with vote delegation
*/
contract Ballot {
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
address delegate; // person delegated to
uint vote; // index of the voted proposal
}
struct Proposal {
// If you can limit the length to a certain number of bytes,
// always use one of bytes1 to bytes32 because they are much cheaper
bytes32 name; // short name (up to 32 bytes)
uint voteCount; // number of accumulated votes
}
address public chairperson;
mapping(address => Voter) public voters;
Proposal[] public proposals;
/**
* @dev Create a new ballot to choose one of 'proposalNames'.
* @param proposalNames names of proposals
*/
constructor(bytes32[] memory proposalNames) public {
chairperson = msg.sender;
voters[chairperson].weight = 1;
for (uint i = 0; i < proposalNames.length; i++) {
// 'Proposal({...})' creates a temporary
// Proposal object and 'proposals.push(...)'
// appends it to the end of 'proposals'.
proposals.push(Proposal({
name: proposalNames[i],
voteCount: 0
}));
}
}
/**
* @dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'.
* @param voter address of voter
*/
function giveRightToVote(address voter) public {
require(
msg.sender == chairperson,
"Only chairperson can give right to vote."
);
require(
!voters[voter].voted,
"The voter already voted."
);
require(voters[voter].weight == 0);
voters[voter].weight = 1;
}
/**
* @dev Delegate your vote to the voter 'to'.
* @param to address to which vote is delegated
*/
function delegate(address to) public {
Voter storage sender = voters[msg.sender];
require(!sender.voted, "You already voted.");
require(to != msg.sender, "Self-delegation is disallowed.");
while (voters[to].delegate != address(0)) {
to = voters[to].delegate;
// We found a loop in the delegation, not allowed.
require(to != msg.sender, "Found loop in delegation.");
}
sender.voted = true;
sender.delegate = to;
Voter storage delegate_ = voters[to];
if (delegate_.voted) {
// If the delegate already voted,
// directly add to the number of votes
proposals[delegate_.vote].voteCount += sender.weight;
} else {
// If the delegate did not vote yet,
// add to her weight.
delegate_.weight += sender.weight;
}
}
/**
* @dev Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'.
* @param proposal index of proposal in the proposals array
*/
function vote(uint proposal) public {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote");
require(!sender.voted, "Already voted.");
sender.voted = true;
sender.vote = proposal;
// If 'proposal' is out of the range of the array,
// this will throw automatically and revert all
// changes.
proposals[proposal].voteCount += sender.weight;
}
/**
* @dev Computes the winning proposal taking all previous votes into account.
* @return winningProposal_ index of winning proposal in the proposals array
*/
function winningProposal() public view
returns (uint winningProposal_)
{
uint winningVoteCount = 0;
for (uint p = 0; p < proposals.length; p++) {
if (proposals[p].voteCount > winningVoteCount) {
winningVoteCount = proposals[p].voteCount;
winningProposal_ = p;
}
}
}
/**
* @dev Calls winningProposal() function to get the index of the winner contained in the proposals array and then
* @return winnerName_ the name of the winner
*/
function winnerName() public view
returns (bytes32 winnerName_)
{
winnerName_ = proposals[winningProposal()].name;
}
}
`
const ballotTest = `pragma solidity >=0.4.22 <0.7.0;
import "remix_tests.sol"; // this import is automatically injected by Remix.
import "../3_Ballot.sol";
contract BallotTest {
bytes32[] proposalNames;
Ballot ballotToTest;
function beforeAll () public {
proposalNames.push(bytes32("candidate1"));
ballotToTest = new Ballot(proposalNames);
}
function checkWinningProposal () public {
ballotToTest.vote(0);
Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal");
Assert.equal(ballotToTest.winnerName(), bytes32("candidate1"), "candidate1 should be the winner name");
}
function checkWinninProposalWithReturnValue () public view returns (bool) {
return ballotToTest.winningProposal() == 0;
}
}
`
export default {
storage: { name: '1_Storage.sol', content: storage },
owner: { name: '2_Owner.sol', content: owner },
ballot: { name: '3_Ballot.sol', content: ballot },
ballot_test: { name: 'tests/4_Ballot_test.sol', content: ballotTest }
}

@ -1,29 +1,28 @@
import { NightwatchBrowser } from "nightwatch"
require('dotenv').config()
module.exports = function (browser, callback, url, preloadPlugins = true) {
export default function (browser: NightwatchBrowser, callback: VoidFunction, url?: string, preloadPlugins = true): void {
browser
.url(url || 'http://127.0.0.1:8080')
.pause(5000)
.switchBrowserTab(0)
.injectScript('test-browser/helpers/applytestmode.js', function () {
browser.fullscreenWindow(() => {
if (preloadPlugins) {
console.log('preloadPlugins: ', preloadPlugins)
initModules(browser, () => {
browser.clickLaunchIcon('solidity')
.waitForElementVisible('[for="autoCompile"]')
.click('[for="autoCompile"]')
.verify.elementPresent('[data-id="compilerContainerAutoCompile"]:checked')
})
}
})
.fullscreenWindow(() => {
if (preloadPlugins) {
initModules(browser, () => {
browser.clickLaunchIcon('solidity')
.waitForElementVisible('[for="autoCompile"]')
.click('[for="autoCompile"]')
.verify.elementPresent('[data-id="compilerContainerAutoCompile"]:checked')
})
}
})
.perform(() => {
callback()
})
}
function initModules (browser, callback) {
function initModules (browser: NightwatchBrowser, callback: VoidFunction) {
browser.pause(5000)
.click('[data-id="verticalIconsKindpluginManager"]')
.scrollAndClick('[data-id="pluginManagerComponentActivateButtonsolidityStaticAnalysis"]')

@ -1,20 +1,22 @@
'use strict'
var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var sources = [
{'browser/Untitled.sol': {content: examples.ballot.content}}
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
import examples from '../examples/example-contracts'
const sources = [
{'browser/Untitled.sol': { content: examples.ballot.content }}
]
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Deploy Ballot': function (browser) {
'Deploy Ballot': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('solidity')
@ -34,7 +36,7 @@ module.exports = {
})
},
'Debug Ballot / delegate': function (browser) {
'Debug Ballot / delegate': function (browser: NightwatchBrowser) {
browser.pause(500)
.click('*[data-id="txLoggerDebugButton0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3"]')
.pause(2000)
@ -47,7 +49,7 @@ module.exports = {
.checkVariableDebug('soliditylocals', localsCheck)
},
'Access Ballot via at address': function (browser) {
'Access Ballot via at address': function (browser: NightwatchBrowser) {
browser.clickLaunchIcon('udapp')
.click('*[data-id="universalDappUiUdappClose"]')
.addFile('ballot.abi', { content: ballotABI })
@ -66,7 +68,7 @@ module.exports = {
})
},
'Deploy and use Ballot using external web3': function (browser) {
'Deploy and use Ballot using external web3': function (browser: NightwatchBrowser) {
browser
.click('*[data-id="settingsWeb3Mode"]')
.modalFooterOKClick()
@ -86,14 +88,14 @@ module.exports = {
tearDown: sauce
}
var localsCheck = {
const localsCheck = {
'to': {
'value': '0x4B0897B0513FDC7C541B6D9D7E929C4E5364D2DB',
'type': 'address'
}
}
var stateCheck = {
const stateCheck = {
'chairperson': {
'value': '0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C',
'type': 'address',
@ -148,7 +150,7 @@ var stateCheck = {
}
}
var ballotABI = `[
const ballotABI = `[
{
"inputs": [
{

@ -1,21 +1,24 @@
'use strict'
var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var sources = [
{'browser/Untitled.sol': {content: examples.ballot.content}}
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
import examples from '../examples/example-contracts'
const sources = [
{'browser/Untitled.sol': { content: examples.ballot.content }}
]
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Should compile using "compileWithParamaters" API': function (browser) {
'Should compile using "compileWithParamaters" API': function (browser: NightwatchBrowser) {
browser
.addFile('test_jsCompile.js', { content: jsCompile })
.executeScript('remix.exeCurrent()')
@ -23,13 +26,13 @@ module.exports = {
.journalChildIncludes(`version: '0.6.8+commit.0bbfe453'`)
},
'Should update the compiler configuration with "setCompilerConfig" API': function (browser) {
'Should update the compiler configuration with "setCompilerConfig" API': function (browser: NightwatchBrowser) {
browser
.addFile('test_updateConfiguration.js', { content: updateConfiguration })
.executeScript('remix.exeCurrent()')
.pause(5000)
.addFile('test_updateConfiguration.sol', { content: simpleContract })
.verifyContracts(['StorageTestUpdateConfiguration'], {wait: 5000, version: '0.6.8+commit.0bbfe453'})
.verifyContracts(['StorageTestUpdateConfiguration'], { wait: 5000, version: '0.6.8+commit.0bbfe453' })
.end()
},
@ -40,7 +43,7 @@ const simpleContract = `pragma solidity >=0.4.22 <0.7.0;
/**
* @title Storage
* @dev Store & retrieve value in a variable
* @dev Store & retreive value in a variable
*/
contract StorageTestUpdateConfiguration {
@ -58,7 +61,7 @@ contract StorageTestUpdateConfiguration {
* @dev Return value
* @return value of 'number'
*/
function retrieve() public view returns (uint256){
function retreive() public view returns (uint256){
return number;
}
}

@ -1,10 +1,11 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
@ -12,7 +13,7 @@ module.exports = {
return sources
},
'Should launch debugger': function (browser) {
'Should launch debugger': function (browser: NightwatchBrowser) {
browser.addFile('blah.sol', sources[0]['browser/blah.sol'])
.clickLaunchIcon('udapp')
.waitForElementPresent('*[title="Deploy - transact (not payable)"]')
@ -21,7 +22,7 @@ module.exports = {
.assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEBUGGER')
},
'Should debug failing transaction': function (browser) {
'Should debug failing transaction': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]')
.clickLaunchIcon('udapp')
.waitForElementPresent('*[data-id="universalDappUiTitleExpander"]')
@ -36,17 +37,17 @@ module.exports = {
.assert.containsText('*[data-id="solidityLocals"]', '999')
},
'Should debug transaction using slider': function (browser) {
'Should debug transaction using slider': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]')
.waitForElementVisible('*[data-id="slider"]')
.click('*[data-id="slider"]')
.setValue('*[data-id="slider"]', 50)
.setValue('*[data-id="slider"]', '50')
.pause(2000)
.assert.containsText('*[data-id="solidityLocals"]', 'no locals')
.assert.containsText('*[data-id="stepdetail"]', 'vm trace step:\n92')
},
'Should step back and forward transaction': function (browser) {
'Should step back and forward transaction': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindudapp"]')
.waitForElementPresent('*[data-id="buttonNavigatorIntoBack"]')
.scrollAndClick('*[data-id="buttonNavigatorIntoBack"]')
@ -59,7 +60,7 @@ module.exports = {
.assert.containsText('*[data-id="stepdetail"]', 'execution step:\n92')
},
'Should jump through breakpoints': function (browser) {
'Should jump through breakpoints': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="editorInput"]')
.click('.ace_gutter-cell:nth-of-type(10)')
.click('.ace_gutter-cell:nth-of-type(20)')
@ -78,7 +79,7 @@ module.exports = {
tearDown: sauce
}
var sources = [
const sources = [
{
'browser/blah.sol': {
content: `

@ -1,12 +1,14 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', false)
},
'Loads Icon\'s Panel': function (browser) {
'Loads Icon\'s Panel': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="remixIdeIconPanel"]', 10000)
.waitForElementVisible('div[data-id="verticalIconsHomeIcon"]')
.waitForElementVisible('div[plugin="fileExplorers"]')
@ -14,27 +16,27 @@ module.exports = {
.waitForElementVisible('div[plugin="settings"]')
},
'Loads Side Panel': function (browser) {
'Loads Side Panel': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="remixIdeSidePanel"]')
.assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS')
.waitForElementVisible('div[data-id="filePanelFileExplorerTree"]')
.waitForElementVisible('li[key="browser/3_Ballot.sol"]')
},
'Loads Main View': function (browser) {
'Loads Main View': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="mainPanelPluginsContainer"]')
.waitForElementVisible('div[data-id="landingPageHomeContainer"]')
.waitForElementVisible('div[data-id="landingPageHpSections"]')
.waitForElementVisible('div[data-id="terminalContainer"]')
},
'Loads terminal': function (browser) {
'Loads terminal': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('div[data-id="terminalCli"]', 10000)
.journalLastChildIncludes('Welcome to Remix')
},
'Toggles Side Panel': function (browser) {
'Toggles Side Panel': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="remixIdeSidePanel"]')
.assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS')
.clickLaunchIcon('fileExplorers')
@ -44,7 +46,7 @@ module.exports = {
.assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS')
},
'Toggles Terminal': function (browser) {
'Toggles Terminal': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="terminalContainer"]')
.assert.visible('div[data-id="terminalContainerDisplay"]')
.click('i[data-id="terminalToggleIcon"]')
@ -53,7 +55,7 @@ module.exports = {
.assert.visible('div[data-id="terminalContainerDisplay"]')
},
'Toggles File Explorer Browser': function (browser) {
'Toggles File Explorer Browser': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('div[data-id="filePanelFileExplorerTree"]')
.assert.visible('ul[key="browser"]')
@ -63,7 +65,7 @@ module.exports = {
.assert.visible('ul[key="browser"]')
},
'Switch Tabs using tabs icon': function (browser) {
'Switch Tabs using tabs icon': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('div[data-id="filePanelFileExplorerTree"]')
.openFile('browser/3_Ballot.sol')

@ -1,14 +1,16 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'Should zoom in editor': function (browser) {
'Should zoom in editor': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="mainPanelPluginsContainer"]')
.openFile('browser/1_Storage.sol')
.waitForElementVisible('*[data-id="editorInput"]')
@ -18,7 +20,7 @@ module.exports = {
.checkElementStyle('*[data-id="editorInput"]', 'font-size', '14px')
},
'Should zoom out editor': function (browser) {
'Should zoom out editor': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="editorInput"]')
.checkElementStyle('*[data-id="editorInput"]', 'font-size', '14px')
.click('*[data-id="tabProxyZoomOut"]')
@ -26,7 +28,7 @@ module.exports = {
.checkElementStyle('*[data-id="editorInput"]', 'font-size', '12px')
},
'Should display compile error in editor': function (browser) {
'Should display compile error in editor': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="editorInput"]')
.waitForElementVisible('*[class="ace_content"]')
.click('*[class="ace_content"]')
@ -35,7 +37,7 @@ module.exports = {
.waitForElementVisible('.ace_error')
},
'Should minimize and maximize codeblock in editor': function (browser) {
'Should minimize and maximize codeblock in editor': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="editorInput"]')
.waitForElementVisible('.ace_open')
.click('.ace_start:nth-of-type(1)')
@ -44,14 +46,14 @@ module.exports = {
.waitForElementVisible('.ace_open')
},
'Should add breakpoint to editor': function (browser) {
'Should add breakpoint to editor': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="editorInput"]')
.waitForElementNotPresent('.ace_breakpoint')
.click('.ace_gutter-cell:nth-of-type(1)')
.waitForElementVisible('.ace_breakpoint')
},
'Should load syntax highlighter for ace light theme': function (browser) {
'Should load syntax highlighter for ace light theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="editorInput"]')
.checkElementStyle('.ace_keyword', 'color', aceThemes.light.keyword)
.checkElementStyle('.ace_comment.ace_doc', 'color', aceThemes.light.comment)
@ -59,7 +61,7 @@ module.exports = {
.checkElementStyle('.ace_variable', 'color', aceThemes.light.variable)
},
'Should load syntax highlighter for ace dark theme': function (browser) {
'Should load syntax highlighter for ace dark theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="verticalIconsKindsettings"]')
.waitForElementVisible('*[data-id="settingsTabThemeDark"]')
@ -74,7 +76,7 @@ module.exports = {
*/
},
'Should highlight source code': function (browser) {
'Should highlight source code': function (browser: NightwatchBrowser) {
browser.addFile('sourcehighlight.js', sourcehighlightScript)
.openFile('browser/sourcehighlight.js')
.executeScript('remix.exeCurrent()')
@ -87,7 +89,7 @@ module.exports = {
.checkElementStyle('.highlightLine50', 'background-color', 'rgb(8, 108, 181)')
},
'Should remove 1 highlight from source code': function (browser) {
'Should remove 1 highlight from source code': function (browser: NightwatchBrowser) {
browser.addFile('removeSourcehighlightScript.js', removeSourcehighlightScript)
.openFile('browser/removeSourcehighlightScript.js')
.executeScript('remix.exeCurrent()')
@ -97,7 +99,7 @@ module.exports = {
.checkElementStyle('.highlightLine50', 'background-color', 'rgb(8, 108, 181)')
},
'Should remove all highlights from source code': function (browser) {
'Should remove all highlights from source code': function (browser: NightwatchBrowser) {
browser.addFile('removeAllSourcehighlightScript.js', removeAllSourcehighlightScript)
.openFile('browser/removeAllSourcehighlightScript.js')
.executeScript('remix.exeCurrent()')
@ -111,7 +113,7 @@ module.exports = {
tearDown: sauce
}
var aceThemes = {
const aceThemes = {
light: {
keyword: 'rgb(147, 15, 128)',
comment: 'rgb(35, 110, 36)',

@ -1,7 +1,9 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
const path = require('path')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
import * as path from 'path'
const testData = {
testFile1: path.resolve(__dirname + '/editor.test.js'), // eslint-disable-line
testFile2: path.resolve(__dirname + '/fileExplorer.test.js'), // eslint-disable-line
@ -10,11 +12,11 @@ const testData = {
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'Should create a new file `5_New_contract.sol` in file explorer': function (browser) {
'Should create a new file `5_New_contract.sol` in file explorer': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="remixIdeSidePanel"]')
.clickLaunchIcon('fileExplorers')
.assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS')
@ -25,14 +27,14 @@ module.exports = {
.waitForElementVisible('*[data-id="treeViewLibrowser/5_New_contract.sol"]', 7000)
},
'Should rename `5_New_contract.sol` to 5_Renamed_Contract.sol': function (browser) {
'Should rename `5_New_contract.sol` to 5_Renamed_Contract.sol': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="treeViewLibrowser/5_New_contract.sol"]')
.renameFile('browser/5_New_contract.sol', '5_Renamed_Contract.sol', 'browser/5_Renamed_Contract.sol')
.waitForElementVisible('*[data-id="treeViewLibrowser/5_Renamed_Contract.sol"]')
},
'Should delete file `5_Renamed_Contract.sol` from file explorer': function (browser) {
'Should delete file `5_Renamed_Contract.sol` from file explorer': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="treeViewLibrowser/5_Renamed_Contract.sol"]')
.rightClick('[data-path="browser/5_Renamed_Contract.sol"]')
@ -42,7 +44,7 @@ module.exports = {
.waitForElementNotPresent('*[data-id="treeViewLibrowser/5_Renamed_Contract.sol"')
},
'Should create a new folder': function (browser) {
'Should create a new folder': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="treeViewLibrowser/1_Storage.sol"]')
.rightClick('[data-path="browser/1_Storage.sol"]')
@ -53,7 +55,7 @@ module.exports = {
.waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]')
},
'Should rename Browser_Tests folder to Browser_E2E_Tests': function (browser) {
'Should rename Browser_Tests folder to Browser_E2E_Tests': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]')
.rightClick('[data-path="browser/Browser_Tests"]')
@ -63,7 +65,7 @@ module.exports = {
.waitForElementVisible('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]')
},
'Should delete Browser_E2E_Tests folder': function (browser) {
'Should delete Browser_E2E_Tests folder': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]')
.rightClick('[data-path="browser/Browser_E2E_Tests"]')
@ -73,8 +75,8 @@ module.exports = {
.waitForElementNotPresent('*[data-id="treeViewLibrowser/Browser_E2E_Tests"]')
},
'Should publish all explorer files to github gist': function (browser) {
const runtimeBrowser = browser.capabilities.browserName
'Should publish all explorer files to github gist': function (browser: NightwatchBrowser) {
const runtimeBrowser = browser.options.desiredCapabilities.browserName
browser
.waitForElementVisible('*[data-id="fileExplorerNewFilepublishToGist"]')
@ -94,7 +96,7 @@ module.exports = {
})
},
'Should open local filesystem explorer': function (browser) {
'Should open local filesystem explorer': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="filePanelFileExplorerTree"]')
.setValue('*[data-id="fileExplorerFileUpload"]', testData.testFile1)
.setValue('*[data-id="fileExplorerFileUpload"]', testData.testFile2)

@ -1,13 +1,14 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'Should execute `file` api from file manager external api': function (browser) {
'Should execute `file` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('file.js', { content: executeFile })
.executeScript(`remix.exeCurrent()`)
@ -15,7 +16,7 @@ module.exports = {
.journalLastChildIncludes('browser/file.js')
},
'Should execute `exists` api from file manager external api': function (browser) {
'Should execute `exists` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('exists.js', { content: executeExists })
.executeScript(`remix.exeCurrent()`)
@ -24,7 +25,7 @@ module.exports = {
.journalChildIncludes('browser/non-exists.js false')
},
'Should execute `open` api from file manager external api': function (browser) {
'Should execute `open` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('open.js', { content: executeOpen })
.executeScript(`remix.exeCurrent()`)
@ -32,7 +33,7 @@ module.exports = {
.journalLastChildIncludes('browser/3_Ballot.sol')
},
'Should execute `writeFile` api from file manager external api': function (browser) {
'Should execute `writeFile` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('writeFile.js', { content: executeWriteFile })
.executeScript(`remix.exeCurrent()`)
@ -41,7 +42,7 @@ module.exports = {
.assert.containsText('[data-id="editorInput"]', 'pragma solidity ^0.6.0')
},
'Should execute `readFile` api from file manager external api': function (browser) {
'Should execute `readFile` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('readFile.js', { content: executeReadFile })
.executeScript(`remix.exeCurrent()`)
@ -49,7 +50,7 @@ module.exports = {
.journalLastChildIncludes('pragma solidity ^0.6.0')
},
'Should execute `copyFile` api from file manager external api': function (browser) {
'Should execute `copyFile` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('copyFile.js', { content: executeCopyFile })
.executeScript(`remix.exeCurrent()`)
@ -57,7 +58,7 @@ module.exports = {
.journalLastChildIncludes('pragma solidity >=0.4.22 <0.7.0;')
},
'Should execute `rename` api from file manager external api': function (browser) {
'Should execute `rename` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('renameFile.js', { content: executeRename })
.executeScript(`remix.exeCurrent()`)
@ -65,7 +66,7 @@ module.exports = {
.waitForElementPresent('[data-id="treeViewLibrowser/old_contract.sol"]')
},
'Should execute `mkdir` api from file manager external api': function (browser) {
'Should execute `mkdir` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('mkdirFile.js', { content: executeMkdir })
.executeScript(`remix.exeCurrent()`)
@ -73,7 +74,7 @@ module.exports = {
.waitForElementPresent('[data-id="treeViewLibrowser/Test_Folder"]')
},
'Should execute `readdir` api from file manager external api': function (browser) {
'Should execute `readdir` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('readdirFile.js', { content: executeReaddir })
.executeScript(`remix.exeCurrent()`)
@ -81,7 +82,7 @@ module.exports = {
.journalLastChildIncludes('Test_Folder isDirectory true')
},
'Should execute `remove` api from file manager external api': function (browser) {
'Should execute `remove` api from file manager external api': function (browser: NightwatchBrowser) {
browser
.addFile('removeFile.js', { content: executeRemove })
.executeScript(`remix.exeCurrent()`)

@ -1,13 +1,14 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', false)
},
'Should display settings menu': function (browser) {
'Should display settings menu': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.click('*[data-id="landingPageStartSolidity"]')
.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
@ -15,8 +16,8 @@ module.exports = {
.waitForElementContainsText('h6[data-id="sidePanelSwapitTitle"]', 'SETTINGS')
},
'Should open gitter channel in a new tab when `Gitter Channel Button` is clicked': function (browser) {
const runtimeBrowser = browser.capabilities.browserName
'Should open gitter channel in a new tab when `Gitter Channel Button` is clicked': function (browser: NightwatchBrowser) {
const runtimeBrowser = browser.options.desiredCapabilities.browserName
browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]')
.waitForElementVisible('*[data-id="settingsTabGitterChannelButton"]', 5000)
@ -25,7 +26,7 @@ module.exports = {
.perform((done) => { if (runtimeBrowser === 'chrome') { browser.switchBrowserTab(1).assert.urlContains('https://gitter.im/ethereum/remix') } done() })
},
'Should activate `generate contract metadata`': function (browser) {
'Should activate `generate contract metadata`': function (browser: NightwatchBrowser) {
browser.switchBrowserTab(0)
.waitForElementVisible('*[data-id="remixIdeSidePanel"]', 5000)
.waitForElementVisible('*[data-id="settingsTabGenerateContractMetadata"]', 5000)
@ -40,7 +41,7 @@ module.exports = {
.openFile('browser/artifacts/Ballot.json')
},
'Should add new github access token': function (browser) {
'Should add new github access token': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="verticalIconsKindsettings"]')
.setValue('*[data-id="settingsTabGistAccessToken"]', '**********')
@ -49,14 +50,14 @@ module.exports = {
.assert.containsText('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 'Access token saved')
},
'Should copy github access token to clipboard': function (browser) {
'Should copy github access token to clipboard': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="copyToClipboardCopyIcon"]')
.waitForElementVisible('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 5000)
.assert.containsText('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 'Copied value to clipboard.')
},
'Should remove github access token': function (browser) {
'Should remove github access token': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabRemoveGistToken"]')
.waitForElementVisible('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 5000)
@ -64,7 +65,7 @@ module.exports = {
.assert.containsText('*[data-id="settingsTabGistAccessToken"]', '')
},
'Should load dark theme': function (browser) {
'Should load dark theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeDark"]')
.pause(2000)
@ -76,7 +77,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.dark.danger)
},
'Should load light theme': function (browser) {
'Should load light theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeLight"]')
.pause(2000)
@ -88,7 +89,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.light.danger)
},
'Should load Cerulean theme': function (browser) {
'Should load Cerulean theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeCerulean"]')
.pause(5000)
@ -100,7 +101,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.curelean.danger)
},
'Should load Flatly theme': function (browser) {
'Should load Flatly theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeFlatly"]')
.pause(2000)
@ -112,7 +113,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.flatly.danger)
},
'Should load Lumen theme': function (browser) {
'Should load Lumen theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeLumen"]')
.pause(2000)
@ -124,7 +125,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.lumen.danger)
},
'Should load Minty theme': function (browser) {
'Should load Minty theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeMinty"]')
.pause(2000)
@ -136,7 +137,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.minty.danger)
},
'Should load Pulse theme': function (browser) {
'Should load Pulse theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemePulse"]')
.pause(2000)
@ -148,7 +149,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.pulse.danger)
},
'Should load Sandstone theme': function (browser) {
'Should load Sandstone theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeSandstone"]')
.pause(2000)
@ -160,7 +161,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.sandstone.danger)
},
'Should load Spacelab theme': function (browser) {
'Should load Spacelab theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeSpacelab"]')
.pause(2000)
@ -172,7 +173,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.spacelab.danger)
},
'Should load Yeti theme': function (browser) {
'Should load Yeti theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeYeti"]')
.pause(2000)
@ -184,7 +185,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.yeti.danger)
},
'Should load Cyborg theme': function (browser) {
'Should load Cyborg theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeCyborg"]')
.pause(2000)
@ -196,7 +197,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.cyborg.danger)
},
'Should load Darkly theme': function (browser) {
'Should load Darkly theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeDarkly"]')
.pause(2000)
@ -208,7 +209,7 @@ module.exports = {
.checkElementStyle(':root', '--danger', remixIdeThemes.darkly.danger)
},
'Should load Superhero theme': function (browser) {
'Should load Superhero theme': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="settingsTabThemeSuperhero"]')
.pause(2000)
@ -224,7 +225,7 @@ module.exports = {
tearDown: sauce
}
var remixIdeThemes = {
const remixIdeThemes = {
dark: {
primary: '#007aa6',
secondary: '#595c76',

@ -1,6 +1,8 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
const testData = {
validGistId: '1859c97c6e1efc91047d725d5225888e',
invalidGistId: '6368b389f9302v32902msk2402'
@ -8,10 +10,10 @@ const testData = {
// 99266d6da54cc12f37f11586e8171546c7700d67
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'UploadToGists': function (browser) {
'UploadToGists': function (browser: NightwatchBrowser) {
/*
- set the access token
- publish to gist
@ -19,7 +21,7 @@ module.exports = {
- switch to a file in the new gist
*/
console.log('token', process.env.gist_token)
const runtimeBrowser = browser.capabilities.browserName
const runtimeBrowser = browser.options.desiredCapabilities.browserName
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
@ -36,11 +38,12 @@ module.exports = {
.getModalBody((value, done) => {
const reg = /gist.github.com\/([^.]+)/
const id = value.match(reg)
console.log('gist regex', id)
if (!id) {
browser.assert.fail('cannot get the gist id', '', '')
} else {
let gistid = id[1]
const gistid = id[1]
browser
.modalFooterCancelClick()
.executeScript(`remix.loadgist('${gistid}')`)
@ -51,7 +54,7 @@ module.exports = {
})
},
'Load Gist Modal': function (browser) {
'Load Gist Modal': function (browser: NightwatchBrowser) {
browser.clickLaunchIcon('home')
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('fileExplorers')
@ -64,7 +67,7 @@ module.exports = {
.modalFooterCancelClick()
},
'Display Error Message For Invalid Gist ID': function (browser) {
'Display Error Message For Invalid Gist ID': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('fileExplorers')
@ -77,7 +80,7 @@ module.exports = {
.modalFooterOKClick()
},
'Import From Gist For Valid Gist ID': function (browser) {
'Import From Gist For Valid Gist ID': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('fileExplorers')

@ -0,0 +1,127 @@
'use strict'
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Add Lib Test File': function (browser: NightwatchBrowser) {
browser.addFile('Untitled5.sol', sources[0]['browser/Untitled5.sol'])
.clickLaunchIcon('udapp')
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c') // this account will be used for this test suite
},
'Test Auto Deploy Lib': function (browser: NightwatchBrowser) {
let addressRef: string
browser.verifyContracts(['test'])
.selectContract('test')
.createContract('')
.getAddressAtPosition(0, (address) => {
console.log('testAutoDeployLib ' + address)
addressRef = address
})
.waitForElementPresent('.instance:nth-of-type(2)')
.click('.instance:nth-of-type(2) > div > button')
.perform((done) => {
browser.testConstantFunction(addressRef, 'get - call', null, '0:\nuint256: 45').perform(() => {
done()
})
})
},
'Test Manual Deploy Lib': function (browser: NightwatchBrowser) {
console.log('testManualDeployLib')
browser.click('*[data-id="deployAndRunClearInstances"]')
.pause(5000)
.clickLaunchIcon('settings')
.click('#generatecontractmetadata')
.clickLaunchIcon('solidity')
.click('#compileTabView button[title="Compile"]') // that should generate the JSON artefact
.verifyContracts(['test'])
.selectContract('lib') // deploy lib
.createContract('')
.perform((done) => {
browser.getAddressAtPosition(0, (address) => {
console.log(address)
checkDeployShouldFail(browser, () => {
checkDeployShouldSucceed(browser, address, () => {
done()
})
})
})
})
.end()
},
tearDown: sauce
}
function checkDeployShouldFail (browser: NightwatchBrowser, callback: VoidFunction) {
let config
browser.openFile('browser/artifacts').openFile('browser/artifacts/test.json')
.getEditorValue((content) => {
config = JSON.parse(content)
config.deploy['VM:-'].autoDeployLib = false
})
.perform(() => {
browser.setEditorValue(JSON.stringify(config))
})
.openFile('browser/Untitled5.sol')
.selectContract('test') // deploy lib
.createContract('')
.getText('div[class^="terminal"]', (value) => {
console.log('value: ', value)
})
.assert.containsText('div[class^="terminal"]', '<address> is not a valid address')
.perform(() => { callback() })
}
function checkDeployShouldSucceed (browser: NightwatchBrowser, address: string, callback: VoidFunction) {
let addressRef: string
let config
browser.openFile('browser/artifacts').openFile('browser/artifacts/test.json')
.getEditorValue((content) => {
config = JSON.parse(content)
config.deploy['VM:-'].autoDeployLib = false
config.deploy['VM:-']['linkReferences']['browser/Untitled5.sol'].lib = address
})
.perform(() => {
browser.setEditorValue(JSON.stringify(config))
})
.openFile('browser/Untitled5.sol')
.selectContract('test') // deploy lib
.createContract('')
.getAddressAtPosition(1, (address) => {
addressRef = address
})
.waitForElementPresent('.instance:nth-of-type(3)')
.click('.instance:nth-of-type(3) > div > button')
.perform(() => {
browser
.testConstantFunction(addressRef, 'get - call', null, '0:\nuint256: 45')
.perform(() => { callback() })
})
}
const sources = [
{
'browser/Untitled5.sol': {content: `library lib {
function getInt () public view returns (uint) {
return 45;
}
}
contract test {
function get () public view returns (uint) {
return lib.getInt();
}
}`}
}
]

@ -1,6 +1,8 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
const testData = {
pluginName: 'remixIde',
pluginDisplayName: 'Remix IDE',
@ -8,11 +10,11 @@ const testData = {
}
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', false)
},
'Should Load Plugin Manager': function (browser) {
'Should Load Plugin Manager': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]')
.pause(3000)
.click('*[plugin="pluginManager"]')
@ -20,7 +22,7 @@ module.exports = {
.assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'PLUGIN MANAGER')
},
'Should Search for plugins': function (browser) {
'Should Search for plugins': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.click('*[data-id="pluginManagerComponentSearchInput"]')
.keys('debugger')
@ -38,7 +40,7 @@ module.exports = {
.keys(browser.Keys.ENTER)
},
'Should activate plugins': function (browser) {
'Should activate plugins': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.click('*[data-id="pluginManagerComponentPluginManager"]')
.scrollAndClick('*[data-id="pluginManagerComponentActivateButtondebugger"]')
@ -49,7 +51,7 @@ module.exports = {
.waitForElementVisible('*[data-id="pluginManagerComponentDeactivateButtonZoKrates"]')
},
'Should deactivate plugins': function (browser) {
'Should deactivate plugins': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.click('*[data-id="pluginManagerComponentPluginManager"]')
.scrollAndClick('*[data-id="pluginManagerComponentDeactivateButtondebugger"]')
@ -96,7 +98,7 @@ module.exports = {
},
*/
'Should connect a local plugin': function (browser) {
'Should connect a local plugin': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.click('*[data-id="pluginManagerComponentPluginSearchButton"]')
.waitForElementVisible('*[data-id="modalDialogContainer"]')
@ -112,7 +114,7 @@ module.exports = {
.waitForElementVisible('*[data-id="pluginManagerComponentDeactivateButtonremixIde"]')
},
'Should display error message for creating already existing plugin': function (browser) {
'Should display error message for creating already existing plugin': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.click('*[data-id="pluginManagerComponentPluginSearchButton"]')
.waitForElementVisible('*[data-id="modalDialogContainer"]')
@ -131,7 +133,7 @@ module.exports = {
.assert.containsText('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 'Cannot create Plugin : This name has already been used')
},
'Should load back installed plugins after reload': function (browser) {
'Should load back installed plugins after reload': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.getInstalledPlugins((plugins) => {
browser.refresh()
@ -148,5 +150,6 @@ module.exports = {
})
.end()
},
tearDown: sauce
}

@ -1,15 +1,18 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return []
},
'Publish on IPFS': function (browser) {
'Publish on IPFS': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('fileExplorers')
@ -23,7 +26,8 @@ module.exports = {
})
.modalFooterOKClick()
},
'Publish on Swarm': '' + function (browser) {
'Publish on Swarm': '' + function (browser: NightwatchBrowser) {
browser
.click('#publishOnSwarm')
.getModalBody((value, done) => {
@ -33,27 +37,30 @@ module.exports = {
})
.modalFooterOKClick()
},
'Should publish contract metadata to ipfs on deploy': function (browser) {
'Should publish contract metadata to ipfs on deploy': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('#icon-panel')
.clickLaunchIcon('fileExplorers')
.openFile('browser/1_Storage.sol')
.clickLaunchIcon('udapp')
.waitForElementVisible('*[data-id="contractDropdownIpfsCheckboxLabel"]')
.click('*[data-id="contractDropdownIpfsCheckboxLabel"]')
.waitForElementPresent('*[data-id="contractDropdownIpfsCheckbox"]')
.click('*[data-id="contractDropdownIpfsCheckbox"]')
.click('*[data-id="Deploy - transact (not payable)"]')
.pause(5000)
.assert.containsText('*[data-id="modalDialogModalBody"]', 'Metadata of "storage" was published successfully.')
.modalFooterOKClick()
},
'Should remember choice after page refresh': function (browser) {
'Should remember choice after page refresh': function (browser: NightwatchBrowser) {
browser
.refresh()
.openFile('browser/1_Storage.sol')
.clickLaunchIcon('udapp')
.waitForElementVisible('*[data-id="contractDropdownIpfsCheckboxLabel"]')
.waitForElementPresent('*[data-id="contractDropdownIpfsCheckbox"]')
.verify.elementPresent('*[data-id="contractDropdownIpfsCheckbox"]:checked')
.end()
},
tearDown: sauce
}

@ -1,16 +1,19 @@
'use strict'
var sauce = require('./sauce')
var init = require('../helpers/init')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Test Recorder': function (browser) {
var addressRef
'Test Recorder': function (browser: NightwatchBrowser) {
let addressRef
browser.addFile('scenario.json', {content: records})
.pause(5000)
.clickLaunchIcon('udapp')
@ -42,7 +45,7 @@ module.exports = {
.click('i.savetransaction')
.modalFooterOKClick()
.getEditorValue(function (result) {
var parsed = JSON.parse(result)
const 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.name), JSON.stringify(scenario.transactions[0].record.name))
browser.assert.equal(JSON.stringify(parsed.transactions[0].record.type), JSON.stringify(scenario.transactions[0].record.type))
@ -59,7 +62,7 @@ module.exports = {
tearDown: sauce
}
var sources = [{'browser/testRecorder.sol': {content: `contract testRecorder {
const sources = [{'browser/testRecorder.sol': {content: `contract testRecorder {
constructor(uint p) public {
}
@ -68,7 +71,7 @@ var sources = [{'browser/testRecorder.sol': {content: `contract testRecorder {
}
}`}}]
var records = `{
const records = `{
"accounts": {
"account{10}": "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c"
},
@ -226,7 +229,7 @@ var records = `{
}
}`
var scenario = {
const scenario = {
'accounts': {
'account{10}': '0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'
},

@ -1,8 +1,9 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
var assetsTestContract = `import "./contract.sol";
const assetsTestContract = `import "./contract.sol";
contract Assets {
uint[] proposals;
function add(uint8 _numProposals) public {
@ -11,14 +12,14 @@ contract Assets {
}
`
var gmbhTestContract = `contract gmbh {
const gmbhTestContract = `contract gmbh {
uint[] proposals;
function register(uint8 _numProposals) public {
proposals.length = _numProposals;
}
}
`
var sources = [
const sources = [
{
'localhost/folder1/contract2.sol': {content: 'contract test2 { function get () public returns (uint) { return 11; }}'}
},
@ -41,9 +42,11 @@ module.exports = {
before: function (browser, done) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Remixd': function (browser) {
runTests(browser)
},
@ -73,8 +76,8 @@ module.exports = {
tearDown: sauce
}
function runTests (browser, testData) {
var browserName = browser.options.desiredCapabilities.browserName
function runTests (browser: NightwatchBrowser) {
const browserName = browser.options.desiredCapabilities.browserName
if (browserName === 'safari' || browserName === 'internet explorer') {
console.log('do not run remixd test for ' + browserName + ': sauce labs doesn\'t seems to handle websocket')
browser.end()
@ -124,7 +127,7 @@ function runTests (browser, testData) {
.click('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]')
}
function testImportFromRemixd (browser, callback) {
function testImportFromRemixd (browser: NightwatchBrowser, callback: VoidFunction) {
browser
.waitForElementVisible('[data-path="localhost/src"]', 100000)
.click('[data-path="localhost/src"]')

@ -1,13 +1,14 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
const passphrase = process.env.account_passphrase
const password = process.env.account_password
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
@ -15,14 +16,14 @@ module.exports = {
return sources
},
'Should load run and deploy tab': function (browser) {
'Should load run and deploy tab': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.clickLaunchIcon('udapp')
.waitForElementPresent('*[data-id="sidePanelSwapitTitle"]')
.assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEPLOY & RUN TRANSACTIONS')
},
'Should sign message using account key': function (browser) {
'Should sign message using account key': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="settingsRemixRunSignMsg"]')
.click('*[data-id="settingsRemixRunSignMsg"]')
.pause(2000)
@ -37,7 +38,7 @@ module.exports = {
.modalFooterOKClick()
},
'Should deploy contract on JavascriptVM': function (browser) {
'Should deploy contract on JavascriptVM': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.clickLaunchIcon('fileExplorers')
.addFile('Greet.sol', sources[0]['browser/Greet.sol'])
@ -52,7 +53,7 @@ module.exports = {
})
},
'Should run low level interaction (fallback function)': function (browser) {
'Should run low level interaction (fallback function)': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.waitForElementPresent('*[data-id="universalDappUiTitleExpander"]')
.click('*[data-id="universalDappUiTitleExpander"]')
@ -65,7 +66,7 @@ module.exports = {
})
},
'Should connect to Goerli Test Network using MetaMask': function (browser) {
'Should connect to Goerli Test Network using MetaMask': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.setupMetamask(passphrase, password)
.click('.network-indicator__down-arrow')
@ -86,7 +87,7 @@ module.exports = {
.switchBrowserTab(0)
},
'Should deploy contract on Goerli Test Network using MetaMask': function (browser) {
'Should deploy contract on Goerli Test Network using MetaMask': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="runTabSelectAccount"] option')
.clickLaunchIcon('fileExplorers')
.openFile('browser/Greet.sol')
@ -103,7 +104,7 @@ module.exports = {
.switchBrowserTab(0)
},
'Should run low level interaction (fallback function) on Goerli Test Network using MetaMask': function (browser) {
'Should run low level interaction (fallback function) on Goerli Test Network using MetaMask': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.waitForElementPresent('*[data-id="universalDappUiTitleExpander"]')
.click('*[data-id="universalDappUiTitleExpander"]')
@ -119,7 +120,7 @@ module.exports = {
.switchBrowserTab(0)
},
'Should connect to Ethereum Main Network using MetaMask': function (browser) {
'Should connect to Ethereum Main Network using MetaMask': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.switchBrowserTab(2)
.waitForElementPresent('.network-indicator__down-arrow')
@ -137,7 +138,7 @@ module.exports = {
.assert.containsText('*[data-id="settingsNetworkEnv"]', 'Main (1) network')
},
'Should deploy contract on Ethereum Main Network using MetaMask': function (browser) {
'Should deploy contract on Ethereum Main Network using MetaMask': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="runTabSelectAccount"] option')
.clickLaunchIcon('fileExplorers')
.openFile('browser/Greet.sol')
@ -157,7 +158,7 @@ module.exports = {
* - Ropsten node for retrieving the trace and storage
*
*/
'Should debug Ropsten transaction with source highlighting using the source verifier service and MetaMask': function (browser) {
'Should debug Ropsten transaction with source highlighting using the source verifier service and MetaMask': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.switchBrowserTab(2)
@ -185,7 +186,7 @@ module.exports = {
tearDown: sauce
}
var sources = [
const sources = [
{
'browser/Greet.sol': {
content:

@ -1,7 +1,7 @@
// const https = require('https')
module.exports = function sauce (callback) {
export default function sauce (callback: VoidFunction): void {
if (typeof callback === 'function') return callback()
/*
const currentTest = this.client.currentTest

@ -1,15 +1,18 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Test Signature': function (browser) {
'Test Signature': function (browser: NightwatchBrowser) {
let hash, signature
browser
.clickLaunchIcon('udapp')
@ -32,7 +35,7 @@ module.exports = {
browser.getAddressAtPosition(0, (address) => {
// skip 'instance' part of e.g. 'instance0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'
console.log('Test Signature address', address)
var inputs = `"${hash.value}","${signature.value}"`
const inputs = `"${hash.value}","${signature.value}"`
console.log('Test Signature Input', inputs)
browser.clickFunction('ecrecovery - call', { types: 'bytes32 hash, bytes sig', values: inputs })
.pause(5000)
@ -49,7 +52,7 @@ module.exports = {
tearDown: sauce
}
var sources = [
const sources = [
{
'browser/signMassage.sol': {content: `
pragma solidity >=0.4.22 <0.7.0;

@ -1,39 +1,43 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Test Simple Contract': function (browser) {
'Test Simple Contract': function (browser: NightwatchBrowser) {
browser.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['test1', 'test2'])
},
'Test Success Import': function (browser) {
'Test Success Import': function (browser: NightwatchBrowser) {
browser.addFile('Untitled1.sol', sources[1]['browser/Untitled1.sol'])
.addFile('Untitled2.sol', sources[1]['browser/Untitled2.sol'])
.openFile('browser/Untitled1.sol')
.verifyContracts(['test6', 'test4', 'test5'])
.addFile('Untitled2.sol', sources[1]['browser/Untitled2.sol'])
.openFile('browser/Untitled1.sol')
.verifyContracts(['test6', 'test4', 'test5'])
},
'Test Failed Import': function (browser) {
'Test Failed Import': function (browser: NightwatchBrowser) {
browser.addFile('Untitled3.sol', sources[2]['browser/Untitled3.sol'])
.clickLaunchIcon('solidity')
.assert.containsText('#compileTabView .error pre', 'not found browser/Untitled11.sol')
.clickLaunchIcon('solidity')
.assert.containsText('#compileTabView .error pre', 'not found browser/Untitled11.sol')
},
'Test Github Import - from master branch': function (browser) {
'Test Github Import - from master branch': function (browser: NightwatchBrowser) {
browser
.setSolidityCompilerVersion('soljson-v0.6.2+commit.bacdbe57.js') // open-zeppelin moved to pragma ^0.6.0 (master branch)
.addFile('Untitled4.sol', sources[3]['browser/Untitled4.sol'])
.clickLaunchIcon('fileExplorers')
.verifyContracts(['test7', 'ERC20', 'SafeMath'], {wait: 10000})
.setSolidityCompilerVersion('soljson-v0.6.2+commit.bacdbe57.js') // open-zeppelin moved to pragma ^0.6.0 (master branch)
.addFile('Untitled4.sol', sources[3]['browser/Untitled4.sol'])
.clickLaunchIcon('fileExplorers')
.verifyContracts(['test7', 'ERC20', 'SafeMath'], {wait: 10000})
},
'Test Github Import - from other branch': function (browser) {
'Test Github Import - from other branch': function (browser: NightwatchBrowser) {
browser
.setSolidityCompilerVersion('soljson-v0.5.0+commit.1d4f565a.js') // switch back to 0.5.0 : release-v2.3.0 branch is not solidity 0.6 compliant
.addFile('Untitled5.sol', sources[4]['browser/Untitled5.sol'])
@ -41,7 +45,7 @@ module.exports = {
.verifyContracts(['test8', 'ERC20', 'SafeMath'], {wait: 10000})
},
'Test Github Import - no branch specified': function (browser) {
'Test Github Import - no branch specified': function (browser: NightwatchBrowser) {
browser
.setSolidityCompilerVersion('soljson-v0.6.2+commit.bacdbe57.js') // open-zeppelin moved to pragma ^0.6.0 (master branch)
.addFile('Untitled6.sol', sources[5]['browser/Untitled6.sol'])
@ -49,7 +53,7 @@ module.exports = {
.verifyContracts(['test10', 'ERC20', 'SafeMath'], {wait: 10000})
},
'Test Github Import - raw URL': function (browser) {
'Test Github Import - raw URL': function (browser: NightwatchBrowser) {
browser
.addFile('Untitled7.sol', sources[6]['browser/Untitled7.sol'])
.clickLaunchIcon('fileExplorers')
@ -59,7 +63,7 @@ module.exports = {
tearDown: sauce
}
var sources = [
const sources = [
{
'browser/Untitled.sol': {content: 'contract test1 {} contract test2 {}'}
},

@ -1,10 +1,12 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done) {
init(browser, done)
},
@ -12,7 +14,7 @@ module.exports = {
return sources
},
'Should launch solidity unit test plugin': function (browser) {
'Should launch solidity unit test plugin': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.clickLaunchIcon('fileExplorers')
.addFile('simple_storage.sol', sources[0]['browser/simple_storage.sol'])
@ -24,7 +26,7 @@ module.exports = {
.assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'SOLIDITY UNIT TESTING')
},
'Should generate test file': function (browser) {
'Should generate test file': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.clickLaunchIcon('fileExplorers')
.openFile('browser/simple_storage.sol')
@ -38,7 +40,7 @@ module.exports = {
.removeFile('browser/tests/simple_storage_test.sol')
},
'Should run simple unit test `simple_storage_test.sol` ': function (browser) {
'Should run simple unit test `simple_storage_test.sol` ': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.addFile('tests/simple_storage_test.sol', sources[0]['browser/tests/simple_storage_test.sol'])
.click('*[data-id="verticalIconsKindsolidityUnitTesting"]')
@ -57,7 +59,7 @@ module.exports = {
.assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'FAIL MyTest (browser/tests/simple_storage_test.sol)')
},
'Should run advance unit test using natspec and experimental ABIEncoderV2 `ks2b_test.sol` ': function (browser) {
'Should run advance unit test using natspec and experimental ABIEncoderV2 `ks2b_test.sol` ': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.clickLaunchIcon('fileExplorers')
.addFile('tests/ks2b_test.sol', sources[0]['browser/tests/ks2b_test.sol'])
@ -80,7 +82,7 @@ module.exports = {
.assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'wrong value')
},
'Should stop unit tests during test execution` ': function (browser) {
'Should stop unit tests during test execution` ': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.waitForElementPresent('*[data-id="testTabRunTestsTabRunAction"]')
.clickElementAtPosition('.singleTestLabel', 0)
@ -98,7 +100,7 @@ module.exports = {
.assert.containsText('*[data-id="testTabTestsExecutionStopped"]', 'The test execution has been stopped')
},
'Should fail on compilation': function (browser) {
'Should fail on compilation': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.addFile('tests/compilationError_test.sol', sources[0]['browser/compilationError_test.sol'])
.clickLaunchIcon('fileExplorers')
@ -113,7 +115,7 @@ module.exports = {
.assert.containsText('*[data-id="testTabTestsExecutionStoppedError"]', 'The test execution has been stopped because of error(s) in your test file')
},
'Should fail on deploy': function (browser) {
'Should fail on deploy': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.addFile('tests/deployError_test.sol', sources[0]['browser/tests/deployError_test.sol'])
.clickLaunchIcon('fileExplorers')
@ -127,7 +129,7 @@ module.exports = {
.assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'contract deployment failed after trying twice')
},
'Should fail when parameters are to method in test contract': function (browser) {
'Should fail when parameters are to method in test contract': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.addFile('tests/methodFailure_test.sol', sources[0]['browser/tests/methodFailure_test.sol'])
.clickLaunchIcon('fileExplorers')
@ -141,7 +143,7 @@ module.exports = {
.assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', `Method 'add' can not have parameters inside a test contract`)
},
'Changing current path': function (browser) {
'Changing current path': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.addFile('myTests/simple_storage_test.sol', sources[0]['browser/tests/simple_storage_test.sol'])
.clickLaunchIcon('solidityUnitTesting')
@ -154,14 +156,14 @@ module.exports = {
.setValue('*[data-id="uiPathInput"]', 'browser/tests')
},
'Solidity Unittests': function (browser) {
'Solidity Unittests': function (browser: NightwatchBrowser) {
runTests(browser)
},
tearDown: sauce
}
function runTests (browser) {
function runTests (browser: NightwatchBrowser) {
browser
.waitForElementPresent('*[data-id="verticalIconsKindfileExplorers"]')
.clickLaunchIcon('fileExplorers')
@ -178,7 +180,7 @@ function runTests (browser) {
.end()
}
var sources = [
const sources = [
{
'browser/simple_storage.sol': {
content: `

@ -1,9 +1,10 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
// this test suite also contribute testing https://github.com/ethereum/remix/pull/1497 and https://github.com/ethereum/remix-ide/pull/2898
// quick explanation:
// the goal of https://github.com/ethereum/remix-ide/pull/2898 is to keep track of all the compiled contracts an not only the last one.
@ -12,10 +13,12 @@ module.exports = {
// which result in name clashing we process the whole contract object (which contain bytecode, deployedbytecode, ...)
init(browser, done)
},
'@sources': function () {
return sources
},
'Use special functions receive/fallback - both are declared, sending data': function (browser) {
'Use special functions receive/fallback - both are declared, sending data': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('#icon-panel', 10000)
.testContracts('receiveAndFallback.sol', sources[0]['browser/receiveAndFallback.sol'], ['CheckSpecials']) // compile
.clickLaunchIcon('udapp')
@ -34,7 +37,8 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - both are declared, failing sending data < 1 byte': function (browser) {
'Use special functions receive/fallback - both are declared, failing sending data < 1 byte': function (browser: NightwatchBrowser) {
// don't need to redeploy it, same contract
browser.perform((done) => {
browser.getAddressAtPosition(0, (address) => {
@ -46,7 +50,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - both are declared, failing sending data with odd number of digits': function (browser) {
'Use special functions receive/fallback - both are declared, failing sending data with odd number of digits': function (browser: NightwatchBrowser) {
// don't need to redeploy it, same contract
browser.perform((done) => {
browser.getAddressAtPosition(0, (address) => {
@ -58,7 +62,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - both are declared - receive called, sending wei': function (browser) {
'Use special functions receive/fallback - both are declared - receive called, sending wei': function (browser: NightwatchBrowser) {
// don't need to redeploy it, same contract
browser.perform((done) => {
browser.getAddressAtPosition(0, (address) => {
@ -71,7 +75,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - both are declared - fallback should fail cause not payable, sending data and wei': function (browser) {
'Use special functions receive/fallback - both are declared - fallback should fail cause not payable, sending data and wei': function (browser: NightwatchBrowser) {
// don't need to redeploy it, same contract
browser.perform((done) => {
browser.getAddressAtPosition(0, (address) => {
@ -83,7 +87,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - only receive is declared, sending wei': function (browser) {
'Use special functions receive/fallback - only receive is declared, sending wei': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('#icon-panel', 10000)
.testContracts('receiveOnly.sol', sources[1]['browser/receiveOnly.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp')
@ -101,7 +105,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - only receive is declared, failing, fallback is not declared, sending data': function (browser) {
'Use special functions receive/fallback - only receive is declared, failing, fallback is not declared, sending data': function (browser: NightwatchBrowser) {
// don't need to redeploy it, same contract
browser.perform((done) => {
browser.getAddressAtPosition(1, (address) => {
@ -113,7 +117,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - only fallback declared and is payable, sending wei': function (browser) {
'Use special functions receive/fallback - only fallback declared and is payable, sending wei': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('#icon-panel', 10000)
.testContracts('fallbackOnlyPayable.sol', sources[2]['browser/fallbackOnlyPayable.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp')
@ -131,7 +135,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - only fallback is diclared and is payable, sending data and wei': function (browser) {
'Use special functions receive/fallback - only fallback is diclared and is payable, sending data and wei': function (browser: NightwatchBrowser) {
// don't need to redeploy it, same contract
browser.perform((done) => {
browser.getAddressAtPosition(2, (address) => {
@ -144,7 +148,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - only fallback is declared, fallback should fail cause not payable, sending wei': function (browser) {
'Use special functions receive/fallback - only fallback is declared, fallback should fail cause not payable, sending wei': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('#icon-panel', 10000)
.testContracts('fallbackOnlyNotPayable.sol', sources[3]['browser/fallbackOnlyNotPayable.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp')
@ -161,14 +165,14 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - receive and fallback are declared, sending data and wei': function (browser) {
'Use special functions receive/fallback - receive and fallback are declared, sending data and wei': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('#icon-panel', 10000)
.testContracts('receiveAndFallbackBothPayable.sol', sources[4]['browser/receiveAndFallbackBothPayable.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp')
.selectContract('CheckSpecials')
.waitForElementVisible('#value')
.clearValue('#value')
.setValue('#value', 0)
.setValue('#value', '0')
.createContract('')
.clickInstance(4)
.pause(1000)
@ -183,7 +187,7 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - receive and fallback are declared and payable, sending wei': function (browser) {
'Use special functions receive/fallback - receive and fallback are declared and payable, sending wei': function (browser: NightwatchBrowser) {
browser.perform((done) => {
browser.getAddressAtPosition(4, (address) => {
browser.sendLowLevelTx(address, '1', '')
@ -195,14 +199,14 @@ module.exports = {
})
})
},
'Use special functions receive/fallback - receive and fallback are not declared, sending nothing': function (browser) {
'Use special functions receive/fallback - receive and fallback are not declared, sending nothing': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('#icon-panel', 10000)
.testContracts('notSpecial.sol', sources[5]['browser/notSpecial.sol'], ['CheckSpecials'])
.clickLaunchIcon('udapp')
.selectContract('CheckSpecials')
.waitForElementVisible('#value')
.clearValue('#value')
.setValue('#value', 0)
.setValue('#value', '0')
.createContract('')
.clickInstance(5)
.pause(1000)
@ -220,7 +224,7 @@ module.exports = {
tearDown: sauce
}
var sources = [
const sources = [
{
'browser/receiveAndFallback.sol': {
content: `

@ -1,8 +1,9 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
var sources = [
const sources = [
{
'browser/Untitled.sol': {content: `
pragma solidity >=0.4.22 <0.6.0;
@ -19,19 +20,19 @@ contract TooMuchGas {
]
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Static Analysis': function (browser) {
'Static Analysis': function (browser: NightwatchBrowser) {
runTests(browser)
},
tearDown: sauce
}
function runTests (browser) {
function runTests (browser: NightwatchBrowser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('solidity')
@ -50,17 +51,17 @@ function runTests (browser) {
})
}
function listSelectorContains (textsToFind, selector, browser, callback) {
function listSelectorContains (textsToFind: string[], selector: string, browser: NightwatchBrowser, callback: VoidFunction) {
browser.execute(function (selector) {
var items = document.querySelectorAll(selector)
var ret = []
for (var k = 0; k < items.length; k++) {
const items = document.querySelectorAll(selector)
const ret = []
for (let k = 0; k < items.length; k++) {
ret.push(items[k].innerText)
}
return ret
}, [selector], function (result) {
console.log(result.value)
for (var k in textsToFind) {
for (const k in textsToFind) {
console.log('testing `' + result.value[k] + '` against `' + textsToFind[k] + '`')
browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true)
}

@ -1,20 +1,21 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false)
},
'Should execution a simple console command': function (browser) {
'Should execution a simple console command': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="terminalCli"]', 10000)
.executeScript('console.log(1 + 1)')
.journalLastChild('2')
},
'Should clear console': function (browser) {
'Should clear console': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="terminalCli"]')
.journalChildIncludes('Welcome to Remix')
@ -22,7 +23,7 @@ module.exports = {
.assert.containsText('*[data-id="terminalJournal"]', '')
},
'Should display auto-complete menu': function (browser) {
'Should display auto-complete menu': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="terminalCli"]')
.click('*[data-id="terminalCli"]')
@ -30,7 +31,7 @@ module.exports = {
.assert.visible('*[data-id="autoCompletePopUpAutoCompleteItem"]')
},
'Should execute remix.help() command': function (browser) {
'Should execute remix.help() command': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="terminalCli"]')
.executeScript('remix.help()')
@ -46,7 +47,7 @@ module.exports = {
.journalChildIncludes('remix.debugHelp()')
},
'Should execute remix.debugHelp() command': function (browser) {
'Should execute remix.debugHelp() command': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="terminalCli"]')
.executeScript('remix.debugHelp()')
@ -54,7 +55,7 @@ module.exports = {
.journalChildIncludes('Please see https://www.npmjs.com/package/remix-debug for more informations')
},
'Async/Await Script': function (browser) {
'Async/Await Script': function (browser: NightwatchBrowser) {
browser
.addFile('asyncAwait.js', { content: asyncAwait })
.openFile('browser/asyncAwait.js')
@ -64,7 +65,7 @@ module.exports = {
.journalLastChild('result - Promise Resolved')
},
'Call Remix File Manager from a script': function (browser) {
'Call Remix File Manager from a script': function (browser: NightwatchBrowser) {
browser
.addFile('asyncAwaitWithFileManagerAccess.js', { content: asyncAwaitWithFileManagerAccess })
.openFile('browser/asyncAwaitWithFileManagerAccess.js')

@ -1,16 +1,17 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from "nightwatch"
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Execute Simple Contract and Test Terminal': function (browser) {
'Execute Simple Contract and Test Terminal': function (browser: NightwatchBrowser) {
browser.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['TestContract'])
.clickLaunchIcon('udapp')
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c') // this account will be used for this test suite
@ -43,7 +44,7 @@ module.exports = {
.click('*[data-id="deployAndRunClearInstances"]')
},
'Test Complex Return Values': function (browser) {
'Test Complex Return Values': function (browser: NightwatchBrowser) {
browser.testContracts('returnValues.sol', sources[1]['browser/returnValues.sol'], ['testReturnValues'])
.clickLaunchIcon('udapp')
.click('#runTabView button[class^="instanceButton"]')
@ -91,7 +92,7 @@ module.exports = {
}).click('*[data-id="deployAndRunClearInstances"]')
},
'Test Complex Input Values': function (browser) {
'Test Complex Input Values': function (browser: NightwatchBrowser) {
browser.testContracts('inputValues.sol', sources[2]['browser/inputValues.sol'], ['test'])
.clickLaunchIcon('udapp')
.click('#runTabView button[class^="instanceButton"]')
@ -153,7 +154,7 @@ module.exports = {
// @TODO test: bytes8[3][] type as input
var sources = [
const sources = [
{'browser/Untitled.sol': {content: `
contract TestContract { function f() public returns (uint) { return 8; }
function g() public returns (uint, string memory, bool, uint) {

@ -1,21 +1,22 @@
'use strict'
var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
import examples from '../examples/example-contracts'
var sources = [
const sources = [
{'browser/Untitled.sol': {content: examples.ballot.content}},
{'browser/Untitled1.sol': {content: `contract test {}`}}
]
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'The sequence: Compiling / Deploying / Compiling another contract / calling the first contract - should display in the log the transaction with all the decoded information': function (browser) {
'The sequence: Compiling / Deploying / Compiling another contract / calling the first contract - should display in the log the transaction with all the decoded information': function (browser: NightwatchBrowser) {
// https://github.com/ethereum/remix-ide/issues/2864
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)

@ -1,8 +1,9 @@
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
var sources = [
const sources = [
{'browser/basic.sol': { content:
`pragma solidity >=0.2.0 <0.7.0;
@ -17,20 +18,22 @@ var sources = [
]
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Using Web Worker': function (browser) {
'Using Web Worker': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('fileExplorers')
.addFile('browser/basic.sol', sources[0]['browser/basic.sol'])
.clickLaunchIcon('solidity')
.execute(function() {
document.getElementById('nightlies').checked = true
const elem = document.getElementById('nightlies') as HTMLInputElement
elem.checked = true
})
.noWorkerErrorFor('soljson-v0.3.4+commit.7dab8902.js')
.noWorkerErrorFor('soljson-v0.6.5+commit.f956cc89.js')
@ -38,7 +41,9 @@ module.exports = {
.noWorkerErrorFor('soljson-v0.6.0-nightly.2019.12.17+commit.d13438ee.js')
.noWorkerErrorFor('soljson-v0.4.26+commit.4563c3fc.js')
.execute(function() {
document.getElementById('nightlies').checked = false
const elem = document.getElementById('nightlies') as HTMLInputElement
elem.checked = false
})
.end()
},

@ -1,17 +1,20 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false)
},
'CheckSolidityActivatedAndUDapp': function (browser) {
'CheckSolidityActivatedAndUDapp': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('solidity')
.clickLaunchIcon('udapp')
.end()
},
tearDown: sauce
}

@ -0,0 +1,84 @@
// Merge custom command types with nightwatch types
import { NightwatchBrowser, NightwatchBrowser, NightwatchBrowser } from "nightwatch";
declare module "nightwatch" {
export interface NightwatchCustomCommands {
clickLaunchIcon(icon: string): NightwatchBrowser,
switchBrowserTab(index: number): NightwatchBrowser,
scrollAndClick(target: string): NightwatchBrowser,
scrollInto(target: string): NightwatchBrowser,
testContracts(fileName: string, contractCode: NightwatchContractContent, compiledContractNames: string[]): NightwatchBrowser,
setEditorValue(value: string, callback?: () => void): NightwatchBrowser,
addFile(name: string, content: NightwatchContractContent): NightwatchBrowser,
verifyContracts(compiledContractNames: string[], opts?: { wait: number, version?: string }): NightwatchBrowser,
selectAccount(account?: string): NightwatchBrowser,
clickFunction(fnFullName: string, expectedInput?: NightwatchClickFunctionExpectedInput): NightwatchBrowser,
testFunction(txHash: string, expectedInput: NightwatchTestFunctionExpectedInput): NightwatchBrowser,
goToVMTraceStep(step: number, incr?: number): NightwatchBrowser,
checkVariableDebug(id: string, debugValue: NightwatchCheckVariableDebugValue): NightwatchBrowser,
addAtAddressInstance(address: string, isValidFormat: boolean, isValidChecksum: boolean): NightwatchBrowser,
modalFooterOKClick(): NightwatchBrowser,
clickInstance(index: number): NightwatchBrowser,
journalLastChildIncludes(val: string): NightwatchBrowser,
executeScript(script: string): NightwatchBrowser,
clearEditableContent(cssSelector: string): NightwatchBrowser,
journalChildIncludes(val: string): NightwatchBrowser,
debugTransaction(index: number): NightwatchBrowser,
checkElementStyle(cssSelector: string, styleProperty: string, expectedResult: string): NightwatchBrowser,
openFile(name: string): NightwatchBrowser,
editorScroll(direction: 'up' | 'down', numberOfTimes: number): NightwatchBrowser,
renameFile(path: string, newFileName: string, renamedPath: string): NightwatchBrowser,
rightClick(cssSelector: string): NightwatchBrowser,
waitForElementContainsText(id: string, value: string): NightwatchBrowser,
getModalBody(callback: (value: string, cb: VoidFunction) => void): NightwatchBrowser,
modalFooterCancelClick(): NightwatchBrowser,
selectContract(contractName: string): NightwatchBrowser,
createContract(inputParams: string): NightwatchBrowser,
getAddressAtPosition(index: number, cb: (pos: string) => void): NightwatchBrowser,
testConstantFunction(address: string, fnFullName: string, expectedInput: NightwatchTestConstantFunctionExpectedInput | null, expectedOutput: string): NightwatchBrowser,
getEditorValue(callback: (content: string) => void): NightwatchBrowser,
getInstalledPlugins(cb: (plugins: string[]) => void): NightwatchBrowser,
verifyCallReturnValue(address: string, checks: string[]): NightwatchBrowser,
testEditorValue(testvalue: string): NightwatchBrowser,
removeFile(path: string): NightwatchBrowser,
switchBrowserWindow(url: string, windowName: string, cb: (browser: NightwatchBrowser, window?: NightwatchCallbackResult<Window>) => void): NightwatchBrowser,
setupMetamask(passphrase: string, password: string): NightwatchBrowser,
signMessage(msg: string, callback: (hash: { value: string }, signature: { value: string }) => void): NightwatchBrowser,
setSolidityCompilerVersion(version: string): NightwatchBrowser,
clickElementAtPosition(cssSelector: string, index: number): NightwatchBrowser,
notContainsText(cssSelector: string, text: string): NightwatchBrowser,
sendLowLevelTx(address: string, value: string, callData: string): NightwatchBrowser,
journalLastChild(val: string): NightwatchBrowser,
checkTerminalFilter(filter: string, test: string): NightwatchBrowser,
noWorkerErrorFor(version: string): NightwatchBrowser
}
export interface NightwatchBrowser {
api: this,
emit: (status: string) => void,
fullscreenWindow: (result?: any) => this,
keys(keysToSend: string, callback?: (this: NightwatchAPI, result: NightwatchCallbackResult<void>) => void): NightwatchBrowser,
sendKeys: (selector: string, inputValue: string | string[], callback?: (this: NightwatchAPI, result: NightwatchCallbackResult<void>) => void) => NightwatchBrowser
}
export interface NightwatchContractContent {
content: string;
}
export interface NightwatchClickFunctionExpectedInput {
types: string,
values: string
}
export interface NightwatchTestFunctionExpectedInput {
[key: string]: any
}
export interface NightwatchTestConstantFunctionExpectedInput {
types: string,
values: string
}
export type NightwatchCheckVariableDebugValue = NightwatchTestFunctionExpectedInput
}

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist",
"allowJs": true
},
"include": ["**/*.ts", "**/*.js"]
}

@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["node", "nightwatch"],
"esModuleInterop": true
},
"include": ["**/*.ts", "**/*.js"]
}

@ -21,9 +21,11 @@ setupRemixd
sleep 5
TESTFILES=$(circleci tests glob "./apps/remix-ide/test-browser/tests/**/*.test.js" | circleci tests split --split-by=timings)
npx nx build remix-ide-e2e
TESTFILES=$(circleci tests glob "dist/apps/remix-ide-e2e/src/tests/**/*.test.js" | circleci tests split --split-by=timings)
for TESTFILE in $TESTFILES; do
./node_modules/.bin/nightwatch --config ./apps/remix-ide/nightwatch.js --env chrome $TESTFILE || TEST_EXITCODE=1
npx nx e2e remix-ide-e2e --filePath=$TESTFILE --env=chrome || TEST_EXITCODE=1
done
echo "$TEST_EXITCODE"

@ -21,9 +21,11 @@ setupRemixd
sleep 5
TESTFILES=$(circleci tests glob "./apps/remix-ide/test-browser/tests/**/*.test.js" | circleci tests split --split-by=timings)
npx nx build remix-ide-e2e
TESTFILES=$(circleci tests glob "dist/apps/remix-ide-e2e/src/tests/**/*.test.js" | circleci tests split --split-by=timings)
for TESTFILE in $TESTFILES; do
./node_modules/.bin/nightwatch --config ./apps/remix-ide/nightwatch.js --env firefox $TESTFILE || TEST_EXITCODE=1
npx nx e2e remix-ide-e2e --filePath=$TESTFILE --env=firefox || TEST_EXITCODE=1
done
echo "$TEST_EXITCODE"

@ -21,6 +21,7 @@ setupRemixd
sleep 5
npx nx build remix-ide-e2e
npm run nightwatch_local_runAndDeploy || TEST_EXITCODE=1
echo "$TEST_EXITCODE"

@ -1,101 +0,0 @@
'use strict'
var buildId = process.env.CIRCLE_BUILD_NUM || process.env.TRAVIS_JOB_NUMBER
module.exports = {
'src_folders': ['./test-browser-debugger/test'],
'output_folder': './test-browser-debugger/test/reports',
'custom_commands_path': '',
'custom_assertions_path': '',
'globals_path': '',
'page_objects_path': '',
'selenium': {
'start_process': false,
'server_path': '',
'log_path': '',
'host': '127.0.0.1',
'port': 4444,
'cli_args': {
'webdriver.chrome.driver': '',
'webdriver.ie.driver': '',
'webdriver.firefox.profile': ''
}
},
'test_settings': {
'default': {
'launch_url': 'http://ondemand.saucelabs.com:80',
'selenium_host': 'ondemand.saucelabs.com',
'selenium_port': 80,
'silent': true,
'username': 'yanneth',
'access_key': '1f5a4560-b02b-41aa-b52b-f033aad30870',
'use_ssl': false,
'globals': {
'waitForConditionTimeout': 10000,
'asyncHookTimeout': 100000
},
'screenshots': {
'enabled': false,
'path': ''
},
'desiredCapabilities': {
'browserName': 'firefox',
'javascriptEnabled': true,
'acceptSslCerts': true,
'build': 'build-' + buildId,
'tunnel-identifier': 'remix_tests_' + buildId
}
},
'chrome': {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true,
'build': 'build-' + buildId,
'tunnel-identifier': 'remix_tests_' + buildId
}
},
'safari': {
'desiredCapabilities': {
'browserName': 'safari',
'javascriptEnabled': true,
'platform': 'OS X 10.11',
'version': '10.0',
'acceptSslCerts': true,
'build': 'build-' + buildId,
'tunnel-identifier': 'remix_tests_' + buildId
}
},
'ie': {
'desiredCapabilities': {
'browserName': 'internet explorer',
'javascriptEnabled': true,
'acceptSslCerts': true,
'platform': 'Windows 10',
'version': '11.103',
'build': 'build-' + buildId,
'tunnel-identifier': 'remix_tests_' + buildId
}
},
'local': {
'launch_url': 'http://localhost',
'selenium_host': '127.0.0.1',
'selenium_port': 4444,
'silent': true,
'screenshots': {
'enabled': false,
'path': ''
},
'desiredCapabilities': {
'browserName': 'firefox',
'javascriptEnabled': true,
'acceptSslCerts': true
}
}
}
}

@ -1,36 +0,0 @@
const EventEmitter = require('events')
class AddFile extends EventEmitter {
command (name, content) {
this.api.perform((done) => {
addFile(this.api, name, content, () => {
done()
this.emit('complete')
})
})
return this
}
}
function addFile (browser, name, content, done) {
browser.clickLaunchIcon('udapp').clickLaunchIcon('fileExplorers').click('.newFile')
.waitForElementVisible('#modal-dialog')
.perform((client, done) => {
browser.execute(function (fileName) {
if (fileName !== 'Untitled.sol') {
document.querySelector('#modal-dialog #prompt_text').setAttribute('value', fileName)
}
document.querySelector('#modal-footer-ok').click()
}, [name], function (result) {
console.log(result)
done()
})
})
.setEditorValue(content.content)
.pause(1000)
.perform(function () {
done()
})
}
module.exports = AddFile

@ -1,26 +0,0 @@
const EventEmitter = require('events')
class checkElementStyle extends EventEmitter {
command (cssSelector, styleProperty, expectedResult) {
this.api.perform((done) => {
checkStyle(this.api, cssSelector, styleProperty, expectedResult, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkStyle (browser, cssSelector, styleProperty, expectedResult, callback) {
browser.execute(function (cssSelector, styleProperty) {
return window.getComputedStyle(document.querySelector(cssSelector)).getPropertyValue(styleProperty)
}, [cssSelector, styleProperty], function (result) {
const value = result.value
browser.assert.equal(value.trim().toLowerCase(), expectedResult.toLowerCase())
callback()
})
}
module.exports = checkElementStyle

@ -1,38 +0,0 @@
const EventEmitter = require('events')
const deepequal = require('deep-equal')
class CreateContract extends EventEmitter {
command (id, debugValue) {
this.api.perform((done) => {
checkDebug(this.api, id, debugValue, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkDebug (browser, id, debugValue, done) {
// id is soliditylocals or soliditystate
browser.execute(function (id) {
return document.querySelector('#' + id + ' .dropdownrawcontent').innerText
}, [id], function (result) {
console.log(id + ' ' + result.value)
var value
try {
value = JSON.parse(result.value)
} catch (e) {
browser.assert.fail('cant parse solidity state', e.message, '')
done()
return
}
var equal = deepequal(debugValue, value)
if (!equal) {
browser.assert.fail('checkDebug on ' + id, 'info about error\n ' + JSON.stringify(debugValue) + '\n ' + JSON.stringify(value), '')
}
done()
})
}
module.exports = CreateContract

@ -1,24 +0,0 @@
const EventEmitter = require('events')
class ClickElement extends EventEmitter {
command (cssSelector, index = 0) {
this.api.perform((done) => {
_clickElement(this.api, cssSelector, index, () => {
done()
this.emit('complete')
})
})
return this
}
}
function _clickElement (browser, cssSelector, index, cb) {
browser.waitForElementPresent(cssSelector)
.execute(function (cssSelector, index) {
document.querySelectorAll(cssSelector)[index].click()
}, [cssSelector, index], function () {
cb()
})
}
module.exports = ClickElement

@ -1,18 +0,0 @@
const EventEmitter = require('events')
class GetEditorValue extends EventEmitter {
command (callback) {
this.api.perform((client, done) => {
this.api.execute(function (value) {
return document.getElementById('input').editor.getValue()
}, [], (result) => {
done(result.value)
callback(result.value)
this.emit('complete')
})
})
return this
}
}
module.exports = GetEditorValue

@ -1,16 +0,0 @@
const EventEmitter = require('events')
class GetModalBody extends EventEmitter {
command (callback) {
this.api.waitForElementVisible('.modal-body')
.getText('.modal-body', (result) => {
console.log(result)
callback(result.value, () => {
this.emit('complete')
})
})
return this
}
}
module.exports = GetModalBody

@ -1,18 +0,0 @@
const EventEmitter = require('events')
class NotContainsText extends EventEmitter {
command (cssSelector, text) {
const browser = this.api
browser.getText(cssSelector, (result) => {
if (result.value.includes(text)) return this.api.assert.fail(`${cssSelector} contains ${text}.`)
else this.api.assert.ok(`${cssSelector} does not contains ${text}.`)
})
.perform(() => {
this.emit('complete')
})
return this
}
}
module.exports = NotContainsText

@ -1,26 +0,0 @@
const EventEmitter = require('events')
class SwitchFile extends EventEmitter {
command (name) {
this.api.perform((done) => {
switchFile(this.api, name, () => {
done()
this.emit('complete')
})
})
return this
}
}
// click on fileExplorer can toggle it. We go through settings to be sure FE is open
function switchFile (browser, name, done) {
browser.clickLaunchIcon('settings').clickLaunchIcon('fileExplorers')
.waitForElementVisible('li[key="' + name + '"]')
.click('li[key="' + name + '"]')
.pause(2000)
.perform(() => {
done()
})
}
module.exports = SwitchFile

@ -1,27 +0,0 @@
const EventEmitter = require('events')
class TestContracts extends EventEmitter {
command (fileName, contractCode, compiledContractNames) {
this.api.perform((done) => {
testContracts(this.api, fileName, contractCode, compiledContractNames, () => {
done()
this.emit('complete')
})
})
return this
}
}
function testContracts (browser, fileName, contractCode, compiledContractNames, callback) {
browser
.clickLaunchIcon('solidity')
.addFile(fileName, contractCode)
.pause(1000)
.verifyContracts(compiledContractNames)
.perform(() => {
callback()
})
}
module.exports = TestContracts

@ -1,33 +0,0 @@
const EventEmitter = require('events')
class VerifyCallReturnValue extends EventEmitter {
command (address, checks) {
this.api.perform((done) => {
verifyCallReturnValue(this.api, address, checks, () => {
done()
this.emit('complete')
})
})
return this
}
}
function verifyCallReturnValue (browser, address, checks, done) {
browser.execute(function (address) {
var nodes = document.querySelectorAll('#instance' + address + ' div[class^="contractActionsContainer"] div[class^="value"]')
var ret = []
for (var k = 0; k < nodes.length; k++) {
var text = nodes[k].innerText ? nodes[k].innerText : nodes[k].textContent
ret.push(text.replace('\n', ''))
}
return ret
}, [address], function (result) {
console.log('verifyCallReturnValue', result)
for (var k in checks) {
browser.assert.equal(result.value[k].trim(), checks[k].trim())
}
done()
})
}
module.exports = VerifyCallReturnValue

@ -1,13 +0,0 @@
/**
* This script is injected by NightWatch just before starting test
*
*/
console.log('applying test mode')
var editor = document.getElementById('input').editor
editor.setBehavioursEnabled(false) // disable bracket auto-match (i.e. automatic injection of closing brackets and other things), so we can enter raw source code.
editor.setOptions({
enableBasicAutocompletion: false,
enableSnippets: false,
enableLiveAutocompletion: false
})
console.log('test mode applied')

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save