Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions apps/remix-ide-e2e/src/commands/addFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ class AddFile extends EventEmitter {
function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) {
browser.clickLaunchIcon('udapp')
.clickLaunchIcon('fileExplorers')
.click('li[data-id="treeViewLitreeViewItembrowser/README.txt"]') // focus on root directory
.click('li[data-id="treeViewLitreeViewItemREADME.txt"]') // focus on root directory
.click('.newFile')
.waitForElementVisible('*[data-id="treeViewLitreeViewItembrowser/blank"]')
// .scrollAndClick('*[data-id="treeViewLitreeViewItembrowser/blank"] .remixui_items')
.sendKeys('*[data-id="treeViewLitreeViewItembrowser/blank"] .remixui_items', name)
.sendKeys('*[data-id="treeViewLitreeViewItembrowser/blank"] .remixui_items', browser.Keys.ENTER)
.waitForElementVisible('*[data-id="treeViewLitreeViewItem/blank"]')
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', name)
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', browser.Keys.ENTER)
.pause(2000)
.waitForElementVisible(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`)
// .click(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`)
.waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`)
.setEditorValue(content.content)
.pause(1000)
.perform(function () {
Expand Down
36 changes: 36 additions & 0 deletions apps/remix-ide-e2e/src/commands/getLastTransactionHash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'

class GetLastTransactionHash extends EventEmitter {
command (this: NightwatchBrowser, cb: (hash: string) => void): NightwatchBrowser {
this.api.perform((done) => {
getLastTransactionHash(this.api, (hash) => {
cb(hash)
done()
this.emit('complete')
})
})
return this
}
}

function getLastTransactionHash (browser: NightwatchBrowser, callback: (hash: string) => void) {
browser.waitForElementPresent('*[data-shared="universalDappUiInstance"]')
.execute(function () {
const deployedContracts = document.querySelectorAll('*[data-id="terminalJournal"] > div')
for (let i = deployedContracts.length - 1; i >= 0; i--) {
const current = deployedContracts[i]
const attr = current.getAttribute('data-id')
if (attr && attr.replace('block_tx', '').startsWith('0x')) {
return attr.replace('block_tx', '')
}
}
return ''
}, [], function (result) {
const hash = typeof result.value === 'string' ? result.value : null

callback(hash)
})
}

module.exports = GetLastTransactionHash
13 changes: 4 additions & 9 deletions apps/remix-ide-e2e/src/commands/removeFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,10 @@ function removeFile (browser: NightwatchBrowser, path: string, done: VoidFunctio
.click('#menuitemdelete')
.pause(2000)
.perform(() => {
if (path.indexOf('browser') !== -1) {
browser.waitForElementVisible('[data-id="browser-modal-footer-ok-react"]')
.click('[data-id="browser-modal-footer-ok-react"]')
.waitForElementNotPresent('[data-path="' + path + '"]')
} else if (path.indexOf('localhost') !== -1) {
browser.waitForElementVisible('[data-id="localhost-modal-footer-ok-react"]')
.click('[data-id="localhost-modal-footer-ok-react"]')
.waitForElementNotPresent('[data-path="' + path + '"]')
}
console.log(path, 'to remove')
browser.waitForElementVisible('.modal-ok')
.click('.modal-ok')
.waitForElementNotPresent('[data-path="' + path + '"]')
done()
})
})
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/commands/renamePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function renamePath (browser: NightwatchBrowser, path: string, newFileName: stri
})
})
.pause(1000)
.click('li[data-id="treeViewLitreeViewItembrowser/README.txt"]') // focus on root directory
.click('div[data-id="remixIdeMainPanel"]') // focus out to save
.pause(2000)
.waitForElementNotPresent('[data-path="' + path + '"]')
.waitForElementPresent('[data-path="' + renamedPath + '"]')
Expand Down
95 changes: 52 additions & 43 deletions apps/remix-ide-e2e/src/commands/testFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,68 @@ class TestFunction extends EventEmitter {
}

browser
.waitForElementVisible(`[data-id="block_tx${txHash}"]`)
.click(`[data-id="block_tx${txHash}"]`)
.waitForElementVisible(`*[data-id="txLoggerTable${txHash}"]`)

// fetch and format transaction logs as key => pair object
.elements('css selector', `*[data-shared="key_${txHash}"]`, (res) => {
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 = typeof jsonElement.value === 'string' ? jsonElement.value.trim() : null

logs[key] = null
})
.perform((done) => {
browser.getLastTransactionHash((hash) => {
if (txHash === 'last') {
console.log(hash)
txHash = hash
}
done()
})
})
.elements('css selector', `*[data-shared="pair_${txHash}"]`, (res) => {
Array.isArray(res.value) && res.value.forEach(function (jsonWebElement, index) {
const jsonWebElementId = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]]
.perform((done) => {
browser.waitForElementVisible(`[data-id="block_tx${txHash}"]`)
.click(`[data-id="block_tx${txHash}"]`)
.waitForElementVisible(`*[data-id="txLoggerTable${txHash}"]`)
// fetch and format transaction logs as key => pair object
.elements('css selector', `*[data-shared="key_${txHash}"]`, (res) => {
Array.isArray(res.value) && res.value.forEach(function (jsonWebElement) {
const jsonWebElementId: string = jsonWebElement.ELEMENT || jsonWebElement[Object.keys(jsonWebElement)[0]]

browser.elementIdText(jsonWebElementId, (jsonElement) => {
let value = jsonElement.value
browser.elementIdText(jsonWebElementId, (jsonElement) => {
const key = typeof jsonElement.value === 'string' ? jsonElement.value.trim() : null

try {
value = JSON.parse(<string>jsonElement.value)
setLog(index, <string>value)
} catch (e) {
setLog(index, <string>value)
}
logs[key] = null
})
})
})
})
})
.elements('css selector', `*[data-shared="pair_${txHash}"]`, (res) => {
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

browser.perform(() => {
Object.keys(expectedValue).forEach(key => {
let equal = false
try {
value = JSON.parse(<string>jsonElement.value)
setLog(index, <string>value)
} catch (e) {
setLog(index, <string>value)
}
})
})
}).perform(() => done())
})
.perform(() => {
Object.keys(expectedValue).forEach(key => {
let equal = false

try {
const receivedValue = JSON.parse(logs[key])
try {
const receivedValue = JSON.parse(logs[key])

equal = deepequal(receivedValue, expectedValue[key])
} catch (err) {
equal = deepequal(logs[key], expectedValue[key])
}
equal = deepequal(receivedValue, expectedValue[key])
} catch (err) {
equal = deepequal(logs[key], expectedValue[key])
}

if (!equal) {
browser.assert.fail(`Expected ${JSON.stringify(expectedValue[key])} but got ${JSON.stringify(logs[key])}`)
} else {
browser.assert.ok(true, `Expected value matched returned value ${JSON.stringify(expectedValue[key])}`)
}
if (!equal) {
browser.assert.fail(`Expected ${JSON.stringify(expectedValue[key])} but got ${JSON.stringify(logs[key])}`)
} else {
browser.assert.ok(true, `Expected value matched returned value ${JSON.stringify(expectedValue[key])}`)
}
})
this.emit('complete')
})
this.emit('complete')
})
return this
}
}
Expand Down
12 changes: 5 additions & 7 deletions apps/remix-ide-e2e/src/tests/ballot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import sauce from './sauce'
import examples from '../examples/example-contracts'

const sources = [
{ 'browser/Untitled.sol': { content: examples.ballot.content } }
{ 'Untitled.sol': { content: examples.ballot.content } }
]

module.exports = {
Expand All @@ -20,18 +20,17 @@ module.exports = {
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('solidity')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp')
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c')
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
.click('*[data-id="Deploy - transact (not payable)"]')
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
.click('*[data-id="universalDappUiTitleExpander"]')
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
},
Expand Down Expand Up @@ -61,10 +60,9 @@ module.exports = {
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
.click('*[data-id="universalDappUiTitleExpander"]')
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
.testFunction('last',
{
status: 'false Transaction mined but execution failed',
'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
},
Expand All @@ -74,7 +72,7 @@ module.exports = {
.click('*[data-id="settingsWeb3Mode"]')
.modalFooterOKClick()
.clickLaunchIcon('solidity')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp')
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
.click('*[data-id="Deploy - transact (not payable)"]')
Expand Down
14 changes: 6 additions & 8 deletions apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import sauce from './sauce'
import examples from '../examples/example-contracts'

const sources = [
{ 'browser/Untitled.sol': { content: examples.ballot_0_4_11.content } }
{ 'Untitled.sol': { content: examples.ballot_0_4_11.content } }
]

module.exports = {
Expand All @@ -24,23 +24,22 @@ module.exports = {
.waitForElementVisible('[for="autoCompile"]')
.click('[for="autoCompile"]')
.verify.elementPresent('[data-id="compilerContainerAutoCompile"]:checked')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['Ballot'])
},

'Deploy Ballot': function (browser: NightwatchBrowser) {
browser.pause(500)
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp')
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c')
.setValue('input[placeholder="uint8 _numProposals"]', '2')
.click('*[data-id="Deploy - transact (not payable)"]')
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
.click('*[data-id="universalDappUiTitleExpander"]')
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
},
Expand Down Expand Up @@ -69,10 +68,9 @@ module.exports = {
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
.click('*[data-id="universalDappUiTitleExpander"]')
.clickFunction('delegate - transact (not payable)', { types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"' })
.testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
})
},
Expand All @@ -82,7 +80,7 @@ module.exports = {
.click('*[data-id="settingsWeb3Mode"]')
.modalFooterOKClick()
.clickLaunchIcon('solidity')
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
.testContracts('Untitled.sol', sources[0]['Untitled.sol'], ['Ballot'])
.clickLaunchIcon('udapp')
.setValue('input[placeholder="uint8 _numProposals"]', '2')
.click('*[data-id="Deploy - transact (not payable)"]')
Expand Down
7 changes: 5 additions & 2 deletions apps/remix-ide-e2e/src/tests/compiler_api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import sauce from './sauce'
import examples from '../examples/example-contracts'

const sources = [
{ 'browser/Untitled.sol': { content: examples.ballot.content } }
{ 'Untitled.sol': { content: examples.ballot.content } }
]

module.exports = {
Expand All @@ -24,6 +24,7 @@ module.exports = {
.executeScript('remix.exeCurrent()')
.pause(5000)
.journalChildIncludes('"languageversion": "0.6.8+commit.0bbfe453"')
.click('*[data-id="terminalClearConsole"]')
},

'Should compile using "compileWithParamaters" API with optimization On': function (browser: NightwatchBrowser) {
Expand All @@ -32,6 +33,7 @@ module.exports = {
.executeScript('remix.exeCurrent()')
.pause(10000)
.journalChildIncludes('\\"optimizer\\":{\\"enabled\\":true,\\"runs\\":300}')
.click('*[data-id="terminalClearConsole"]')
},

'Should compile using "compileWithParamaters" API with optimization off check default runs': function (browser: NightwatchBrowser) {
Expand All @@ -40,6 +42,7 @@ module.exports = {
.executeScript('remix.exeCurrent()')
.pause(10000)
.journalChildIncludes('\\"optimizer\\":{\\"enabled\\":false,\\"runs\\":200}')
.click('*[data-id="terminalClearConsole"]')
},

'Should update the compiler configuration with "setCompilerConfig" API': function (browser: NightwatchBrowser) {
Expand All @@ -55,7 +58,7 @@ module.exports = {
tearDown: sauce
}

const simpleContract = `pragma solidity >=0.4.22 <0.7.0;
const simpleContract = `pragma solidity >=0.4.22 <0.9.1;

/**
* @title Storage
Expand Down
Loading