remix-project mirror
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.
remix-project/test-browser/tests/remixd.js

137 lines
6.1 KiB

8 years ago
'use strict'
var init = require('../helpers/init')
var sauce = require('./sauce')
7 years ago
var assetsTestContract = `import "./contract.sol";
contract Assets {
uint[] proposals;
6 years ago
function add(uint8 _numProposals) public {
7 years ago
proposals.length = _numProposals;
}
}
`
6 years ago
var gmbhTestContract = `contract gmbh {
7 years ago
uint[] proposals;
6 years ago
function register(uint8 _numProposals) public {
7 years ago
proposals.length = _numProposals;
}
}
`
var sources = [
{
6 years ago
'localhost/folder1/contract2.sol': {content: 'contract test2 { function get () public returns (uint) { return 11; }}'}
7 years ago
},
{
'localhost/src/gmbh/company.sol': {content: assetsTestContract}
},
{
'localhost/src/gmbh/company.sol': {content: assetsTestContract},
'localhost/src/gmbh/contract.sol': {content: gmbhTestContract}
},
{
'browser/test_import_node_modules.sol': {content: 'import "openzeppelin-solidity/contracts/math/SafeMath.sol";'}
},
{
'browser/test_import_node_modules_with_github_import.sol': {content: 'import "openzeppelin-solidity/contracts/sample.sol";'}
}
]
8 years ago
module.exports = {
before: function (browser, done) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Remixd': function (browser) {
8 years ago
runTests(browser)
},
'Import from node_modules ': function (browser) {
/*
when a relative import is used (i.e import "openzeppelin-solidity/contracts/math/SafeMath.sol")
remix (as well as truffle) try to resolve it against the node_modules and installed_contracts folder.
*/
Nightwatch config for running tests in parallel Added drivers path for chrome and firefox Changed firefox port Installed geckodriver Changed firefox config cli_args config Fixed linting error Modified config Revert nightwatch config Fixed linting error Set drivers path Fixed linting error point driver path to new location Set marionette to false Removed cli_args option Set parallel command in ci Retry firefox in pipeline Retry firefox in ci pipeline Remove cli_args from nightwatch config Retry ci pipeline Load gecko in circleci Debug circleci Debug circleci Retry pipeline Retry pipeline Debug pipeline Debug pipeline Debug pipeline Debug pipeline Debug pipeline Debug pipeline Retry pipeline Retry pipeline Retry pipeline Retry pipeline Debug pipeline Debug pipeline Debug pipeline Debug pipeline Debug pipeline Debug pipeline Debug pipeline Changed CI selenium-server-standalone to selenium-standalone Fixed linting error Set marionette to false Add download of old firefox to ci build Set marionette to true Set permission Rearranged steps Fix ci error Remove gecko driver Use node_modules selenium standalone Change build steps Change firefox version Update firefox version Renamed firefox start step Test yml changes Test yml changes Test yml changes Test yml changes Setup workflows for running firefox and chrome tests in parallel Setup workflows for running firefox and chrome tests in parallel Setup workflows for running firefox and chrome tests in parallel Setup workflows for running firefox and chrome tests in parallel Use selenium-standalone Use selenium-standalone Set selenium-server version Added selenium config Fixed liniting error Fixed Build error path Fixed Selenium config error path Changed selenium server version Test for chrome Added config for chrome Test firefox and chrome in parallel Add firefox config to seleniumConfig Downgrade firefox driver version Download firefox browser Test circleci parallelism Test circleci parallelism Remove parallelism Added delay to ZoKrates test to fix failing test Fixed failing gist tests for firefox Disabled remixd tests for firefox browser Fix linting error Fixed failing terminal test Remove gecko driver dependency Disable remixd test for firefox Fixed failing solidity unit tests switch to .keys() to .sendKeys() since it is supported by both chrome and firefox
5 years ago
browser.waitForElementVisible('#icon-panel', 2000)
.clickLaunchIcon('fileExplorers')
.addFile('test_import_node_modules.sol', sources[3]['browser/test_import_node_modules.sol'])
.clickLaunchIcon('solidity')
.testContracts('test_import_node_modules.sol', sources[3]['browser/test_import_node_modules.sol'], ['SafeMath'])
},
'Import from node_modules and reference a github import': function (browser) {
browser.waitForElementVisible('#icon-panel', 2000)
.clickLaunchIcon('fileExplorers')
.addFile('test_import_node_modules_with_github_import.sol', sources[4]['browser/test_import_node_modules_with_github_import.sol'])
.clickLaunchIcon('solidity')
.setSolidityCompilerVersion('soljson-v0.6.2+commit.bacdbe57.js') // open-zeppelin moved to pragma ^0.6.0
.testContracts('test_import_node_modules_with_github_import.sol', sources[4]['browser/test_import_node_modules_with_github_import.sol'], ['ERC20', 'test11'])
.clickLaunchIcon('pluginManager')
.scrollAndClick('#pluginManager article[id="remixPluginManagerListItem_remixd"] button')
.end()
},
8 years ago
tearDown: sauce
}
function runTests (browser, testData) {
7 years ago
var 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')
8 years ago
browser.end()
return
}
8 years ago
browser
6 years ago
.waitForElementVisible('#icon-panel', 2000)
.clickLaunchIcon('fileExplorers')
6 years ago
.clickLaunchIcon('pluginManager')
.scrollAndClick('#pluginManager article[id="remixPluginManagerListItem_remixd"] button')
6 years ago
.waitForElementVisible('#modal-footer-ok', 2000)
6 years ago
.pause(2000)
.click('#modal-footer-ok')
6 years ago
.clickLaunchIcon('fileExplorers')
7 years ago
.waitForElementVisible('[data-path="localhost/folder1"]')
8 years ago
.click('[data-path="localhost/folder1"]')
7 years ago
.waitForElementVisible('[data-path="localhost/contract1.sol"]')
8 years ago
.assert.containsText('[data-path="localhost/contract1.sol"]', 'contract1.sol')
.assert.containsText('[data-path="localhost/contract2.sol"]', 'contract2.sol')
7 years ago
.waitForElementVisible('[data-path="localhost/folder1/contract1.sol"]')
8 years ago
.assert.containsText('[data-path="localhost/folder1/contract1.sol"]', 'contract1.sol')
7 years ago
.assert.containsText('[data-path="localhost/folder1/contract2.sol"]', 'contract2.sol') // load and test sub folder
8 years ago
.click('[data-path="localhost/folder1/contract2.sol"]')
7 years ago
.click('[data-path="localhost/folder1/contract1.sol"]') // open localhost/folder1/contract1.sol
.pause(1000)
.testEditorValue('contract test1 { function get () returns (uint) { return 10; }}') // check the content and replace by another
.setEditorValue('contract test1Changed { function get () returns (uint) { return 10; }}')
.testEditorValue('contract test1Changed { function get () returns (uint) { return 10; }}')
.setEditorValue('contract test1 { function get () returns (uint) { return 10; }}')
7 years ago
.click('[data-path="localhost/folder1/contract_' + browserName + '.sol"]') // rename a file and check
.pause(1000)
.renameFile('localhost/folder1/contract_' + browserName + '.sol', 'renamed_contract_' + browserName + '.sol', 'localhost/folder1/renamed_contract_' + browserName + '.sol')
7 years ago
.pause(1000)
.removeFile('localhost/folder1/contract_' + browserName + '_toremove.sol')
7 years ago
.perform(function (done) {
testImportFromRemixd(browser, () => { done() })
})
.clickLaunchIcon('fileExplorers')
.waitForElementVisible('[data-path="localhost/folder1"]')
.waitForElementVisible('[data-path="localhost/folder1/contract1.sol"]')
.waitForElementVisible('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]') // check if renamed file is preset
.waitForElementNotPresent('[data-path="localhost/folder1/contract_' + browserName + '.sol"]') // check if renamed (old) file is not present
.waitForElementNotPresent('[data-path="localhost/folder1/contract_' + browserName + '_toremove.sol"]') // check if removed (old) file is not present
.click('[data-path="localhost/folder1/renamed_contract_' + browserName + '.sol"]')
8 years ago
}
7 years ago
function testImportFromRemixd (browser, callback) {
browser
.waitForElementVisible('[data-path="localhost/src"]', 100000)
.click('[data-path="localhost/src"]')
.waitForElementVisible('[data-path="localhost/src/gmbh"]', 100000)
.click('[data-path="localhost/src/gmbh"]')
.waitForElementVisible('[data-path="localhost/src/gmbh/company.sol"]', 100000)
.click('[data-path="localhost/src/gmbh/company.sol"]')
.pause(1000)
.verifyContracts(['Assets', 'gmbh'])
.perform(() => { callback() })
7 years ago
}