Refactor verifyContracts custom command

pull/1041/head
ioedeveloper 4 years ago
parent 3988333730
commit d1fc4739d7
  1. 44
      apps/remix-ide-e2e/src/commands/verifyContracts.ts
  2. 4
      apps/remix-ide-e2e/src/commands/waitForElementContainsText.ts
  3. 3
      apps/remix-ide-e2e/src/tests/compiler_api.test.ts
  4. 3
      apps/remix-ide-e2e/src/tests/debugger.spec.ts
  5. 2
      package.json

@ -1,4 +1,4 @@
import { NightwatchBrowser, NightwatchCallbackResult } from 'nightwatch'
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class VerifyContracts extends EventEmitter {
@ -13,7 +13,7 @@ class VerifyContracts extends EventEmitter {
}
}
function getCompiledContracts (browser: NightwatchBrowser, opts: { wait: number, version?: string }, callback: (result: NightwatchCallbackResult<any>) => void) {
function verifyContracts (browser: NightwatchBrowser, compiledContractNames: string[], opts: { wait: number, version?: string }, callback: VoidFunction) {
browser
.clickLaunchIcon('solidity')
.pause(opts.wait)
@ -29,44 +29,14 @@ function getCompiledContracts (browser: NightwatchBrowser, opts: { wait: number,
.assert.containsText('*[data-id="treeViewLicompiler/version"]', `version:\n ${opts.version}`)
.modalFooterCancelClick()
.perform(done)
} else done()
})
.execute(function () {
const contracts = document.querySelectorAll('*[data-id="compiledContracts"] option') as NodeListOf<HTMLInputElement>
if (!contracts) {
return null
} else {
const ret = []
for (let c = 0; c < contracts.length; c++) {
ret.push(contracts[c].value)
}
return ret
compiledContractNames.forEach((name) => {
browser.waitForElementContainsText('[data-id="compiledContracts"]', name, 60000)
})
done()
callback()
}
}, [], function (result) {
callback(result)
})
}
function verifyContracts (browser: NightwatchBrowser, compiledContractNames: string[], opts: { wait: number, version?: string }, callback: VoidFunction) {
getCompiledContracts(browser, opts, (result: NightwatchCallbackResult<any>) => {
if (result.value) {
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', '')
browser.end()
return
}
}
} else {
browser.assert.fail('compiled contract ' + compiledContractNames + ' not found - none found', 'info about error', '')
browser.end()
}
console.log('contracts all found ' + compiledContractNames)
callback()
})
}
module.exports = VerifyContracts

@ -9,7 +9,7 @@ class WaitForElementContainsText extends EventEmitter {
if (typeof result.value === 'string' && result.value.indexOf(value) !== -1) {
clearInterval(runid)
clearTimeout(waitId)
this.api.assert.ok(true, `WaitForElementContainsText ${id} contains ${value} after ${timeout}`)
this.api.assert.ok(true, `WaitForElementContainsText ${id} contains ${value}`)
this.emit('complete')
}
})
@ -17,7 +17,7 @@ class WaitForElementContainsText extends EventEmitter {
waitId = setTimeout(() => {
clearInterval(runid)
this.api.assert.fail(`TimeoutError: An error occurred while running .waitForElementContainsText() command on ${id}`)
this.api.assert.fail(`TimeoutError: An error occurred while running .waitForElementContainsText() command on ${id} after ${timeout} milliseconds`)
}, timeout)
return this
}

@ -53,8 +53,7 @@ module.exports = {
'Should produce a stack too deep error': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('fileExplorers')
.click('li[data-id="treeViewLitreeViewItemREADME.txt"')
.setSolidityCompilerVersion('soljson-v0.8.1+commit.df193b15.js')
.addFile('ContractStackLimit.sol', { content: contractStackLimit })
.clickLaunchIcon('solidity')
.waitForElementContainsText('*[data-id="compiledErrors"]', 'CompilerError: Stack too deep when compiling inline assembly: Variable headStart is 1 slot(s) too deep inside the stack.', 60000)

@ -188,8 +188,7 @@ module.exports = {
browser
.addFile('test_jsGetTrace.js', { content: jsGetTrace })
.executeScript('remix.exeCurrent()')
.pause(5000)
.journalChildIncludes('result { "gas": "0x5863", "return": "0x0000000000000000000000000000000000000000000000000000000000000000", "structLogs":')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'result { "gas": "0x5863", "return": "0x0000000000000000000000000000000000000000000000000000000000000000", "structLogs":', 60000)
},
'Should call the debugger api: debug': function (browser: NightwatchBrowser) {

@ -57,7 +57,7 @@
"nightwatch_local_firefox": "npm run build:e2e & nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js --env=firefox",
"nightwatch_local_chrome": "npm run build:e2e & nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js --env=chrome",
"nightwatch_local_ballot": "npm run build:e2e & nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/ballot.test.js --env=chrome",
"nightwatch_local_ballot_0_4_11": "npm run build:e2e & nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/ballot_0_4_11.spec.js --env=firefox",
"nightwatch_local_ballot_0_4_11": "npm run build:e2e & nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/ballot_0_4_11.spec.js --env=chrome",
"nightwatch_local_usingWorker": "npm run build:e2e & nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/usingWebWorker.test.js --env=chrome",
"nightwatch_local_libraryDeployment": "npm run build:e2e & nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/libraryDeployment.test.js --env=chrome",
"nightwatch_local_solidityImport": "npm run build:e2e & nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/solidityImport.test.js --env=chrome",

Loading…
Cancel
Save