You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.6 KiB
117 lines
3.6 KiB
5 years ago
|
'use strict'
|
||
|
var init = require('../helpers/init')
|
||
|
var sauce = require('./sauce')
|
||
|
|
||
|
module.exports = {
|
||
|
before: function (browser, done) {
|
||
5 years ago
|
init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false)
|
||
5 years ago
|
},
|
||
5 years ago
|
|
||
|
'Should execution a simple console command': function (browser) {
|
||
5 years ago
|
browser
|
||
5 years ago
|
.waitForElementVisible('*[data-id="terminalCli"]', 10000)
|
||
5 years ago
|
.executeScript('console.log(1 + 1)')
|
||
5 years ago
|
.journalLastChild('2')
|
||
5 years ago
|
},
|
||
|
|
||
|
'Should clear console': function (browser) {
|
||
|
browser
|
||
5 years ago
|
.waitForElementVisible('*[data-id="terminalCli"]')
|
||
5 years ago
|
.journalChildIncludes('Welcome to Remix')
|
||
|
.click('#clearConsole')
|
||
5 years ago
|
.assert.containsText('*[data-id="terminalJournal"]', '')
|
||
5 years ago
|
},
|
||
|
|
||
|
'Should display auto-complete menu': function (browser) {
|
||
|
browser
|
||
5 years ago
|
.waitForElementVisible('*[data-id="terminalCli"]')
|
||
|
.click('*[data-id="terminalCli"]')
|
||
5 years ago
|
.sendKeys('*[data-id="terminalCliInput"]', 'remix.')
|
||
5 years ago
|
.assert.visible('*[data-id="autoCompletePopUpAutoCompleteItem"]')
|
||
5 years ago
|
},
|
||
|
|
||
|
'Should execute remix.help() command': function (browser) {
|
||
|
browser
|
||
5 years ago
|
.waitForElementVisible('*[data-id="terminalCli"]')
|
||
5 years ago
|
.executeScript('remix.help()')
|
||
|
.journalChildIncludes('remix.call(message: {name, key, payload})')
|
||
|
.journalChildIncludes('remix.getFile(path)')
|
||
|
.journalChildIncludes('remix.debug(hash)')
|
||
|
.journalChildIncludes('remix.loadgist(id)')
|
||
|
.journalChildIncludes('remix.loadurl(url)')
|
||
|
.journalChildIncludes('remix.setproviderurl(url)')
|
||
|
.journalChildIncludes('remix.execute(filepath)')
|
||
|
.journalChildIncludes('remix.exeCurrent()')
|
||
|
.journalChildIncludes('remix.help()')
|
||
|
.journalChildIncludes('remix.debugHelp()')
|
||
|
},
|
||
|
|
||
|
'Should execute remix.debugHelp() command': function (browser) {
|
||
|
browser
|
||
5 years ago
|
.waitForElementVisible('*[data-id="terminalCli"]')
|
||
5 years ago
|
.executeScript('remix.debugHelp()')
|
||
|
.journalChildIncludes('Here are some examples of scripts that can be run (using remix.exeCurrent() or directly from the console)')
|
||
|
.journalChildIncludes('Please see https://www.npmjs.com/package/remix-debug for more informations')
|
||
5 years ago
|
},
|
||
|
|
||
|
'Async/Await Script': function (browser) {
|
||
|
browser
|
||
|
.addFile('asyncAwait.js', { content: asyncAwait })
|
||
5 years ago
|
.openFile('browser/asyncAwait.js')
|
||
5 years ago
|
.executeScript(`remix.execute('browser/asyncAwait.js')`)
|
||
|
.journalLastChild('Waiting Promise')
|
||
|
.pause(5500)
|
||
|
.journalLastChild('result - Promise Resolved')
|
||
|
},
|
||
|
|
||
|
'Call Remix File Manager from a script': function (browser) {
|
||
|
browser
|
||
|
.addFile('asyncAwaitWithFileManagerAccess.js', { content: asyncAwaitWithFileManagerAccess })
|
||
5 years ago
|
.openFile('browser/asyncAwaitWithFileManagerAccess.js')
|
||
5 years ago
|
.pause(5000)
|
||
5 years ago
|
.executeScript(`remix.execute('browser/asyncAwaitWithFileManagerAccess.js')`)
|
||
5 years ago
|
.pause(6000)
|
||
5 years ago
|
.journalLastChildIncludes('contract Ballot {')
|
||
5 years ago
|
.end()
|
||
|
},
|
||
5 years ago
|
|
||
5 years ago
|
tearDown: sauce
|
||
|
}
|
||
5 years ago
|
|
||
|
const asyncAwait = `
|
||
|
var p = function () {
|
||
|
return new Promise(function (resolve, reject) {
|
||
|
setTimeout(function () {
|
||
|
resolve("Promise Resolved")
|
||
|
}, 5000)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
var run = async () => {
|
||
|
console.log('Waiting Promise')
|
||
|
var result = await p()
|
||
|
console.log('result - ', result)
|
||
|
}
|
||
|
|
||
|
run()
|
||
|
`
|
||
|
|
||
|
const asyncAwaitWithFileManagerAccess = `
|
||
|
var p = function () {
|
||
|
return new Promise(function (resolve, reject) {
|
||
|
setTimeout(function () {
|
||
|
resolve("Promise Resolved")
|
||
|
}, 0)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
var run = async () => {
|
||
|
console.log('Waiting Promise')
|
||
|
var result = await p()
|
||
5 years ago
|
let text = await remix.call('fileManager', 'readFile', 'browser/3_Ballot.sol')
|
||
5 years ago
|
console.log('result - ', text)
|
||
|
}
|
||
|
|
||
|
run()
|
||
|
`
|