Merge branch 'master' into fixcopypaths

pull/2853/head
bunsenstraat 2 years ago committed by GitHub
commit d7d97eb9fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 41
      apps/remix-ide-e2e/src/commands/connectToExternalHttpProvider.ts
  2. 2
      apps/remix-ide-e2e/src/commands/switchEnvironment.ts
  3. 86
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  4. 1
      apps/remix-ide-e2e/src/types/index.d.ts

@ -0,0 +1,41 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class ConnectToExternalHttpProvider extends EventEmitter {
command(this: NightwatchBrowser, url: string, identifier: string): NightwatchBrowser {
this.api.element('xpath', `//*[@class='udapp_environment' and contains(.,'${identifier}')]`,
(result) => {
if (result.status as any === -1) {
console.log("No connection to external provider found. Adding one.", url)
browser
.click({
locateStrategy: 'css selector',
selector: '[data-id="basic-http-provider-modal-footer-ok-react"]',
abortOnFailure: false,
suppressNotFoundErrors: true,
timeout: 5000
})
.switchEnvironment('External Http Provider')
.waitForElementPresent('[data-id="basic-http-provider-modal-footer-ok-react"]')
.execute(() => {
(document.querySelector('*[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]') as any).focus()
}, [], () => { })
.setValue('[data-id="modalDialogCustomPromp"]', url)
.modalFooterOKClick('basic-http-provider')
.perform((done) => {
done()
this.emit('complete')
})
} else {
this.api.perform((done) => {
done()
this.emit('complete')
})
}
}
)
return this
}
}
module.exports = ConnectToExternalHttpProvider

@ -3,7 +3,7 @@ import EventEmitter from 'events'
class switchEnvironment extends EventEmitter { class switchEnvironment extends EventEmitter {
command (this: NightwatchBrowser, provider: string): NightwatchBrowser { command (this: NightwatchBrowser, provider: string): NightwatchBrowser {
this.api.waitForElementVisible('[data-id="settingsSelectEnvOptions"]') this.api.useCss().waitForElementVisible('[data-id="settingsSelectEnvOptions"]')
.click('[data-id="settingsSelectEnvOptions"] button') .click('[data-id="settingsSelectEnvOptions"] button')
.waitForElementVisible(`[data-id="dropdown-item-${provider}"]`) .waitForElementVisible(`[data-id="dropdown-item-${provider}"]`)
.click(`[data-id="dropdown-item-${provider}"]`) .click(`[data-id="dropdown-item-${provider}"]`)

@ -196,8 +196,8 @@ module.exports = {
'Should run a script right after compilation #group6': function (browser: NightwatchBrowser) { 'Should run a script right after compilation #group6': function (browser: NightwatchBrowser) {
browser browser
.addFile('contracts/storage.sol', { content: scriptAutoExec.contract } ) .addFile('contracts/storage.sol', { content: scriptAutoExec.contract })
.addFile('scripts/deploy_storage.js', { content: scriptAutoExec.script } ) .addFile('scripts/deploy_storage.js', { content: scriptAutoExec.script })
.openFile('contracts/storage.sol') .openFile('contracts/storage.sol')
.sendKeys('body', [browser.Keys.CONTROL, browser.Keys.SHIFT, 's']) .sendKeys('body', [browser.Keys.CONTROL, browser.Keys.SHIFT, 's'])
.pause(15000) .pause(15000)
@ -211,12 +211,12 @@ module.exports = {
.waitForElementPresent('[data-id="basic-http-provider-modal-footer-ok-react"]') .waitForElementPresent('[data-id="basic-http-provider-modal-footer-ok-react"]')
.execute(() => { .execute(() => {
(document.querySelector('*[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]') as any).focus() (document.querySelector('*[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]') as any).focus()
}, [], () => {}) }, [], () => { })
.setValue('[data-id="modalDialogCustomPromp"]', 'https://remix-goerli.ethdevops.io') .setValue('[data-id="modalDialogCustomPromp"]', 'https://remix-goerli.ethdevops.io')
.modalFooterOKClick('basic-http-provider') .modalFooterOKClick('basic-http-provider')
.clickLaunchIcon('filePanel') .clickLaunchIcon('filePanel')
.openFile('README.txt') .openFile('README.txt')
.addFile('scripts/log_tx_block.js', { content: scriptBlockAndTransaction } ) .addFile('scripts/log_tx_block.js', { content: scriptBlockAndTransaction })
.pause(1000) .pause(1000)
.executeScriptInTerminal('remix.execute(\'scripts/log_tx_block.js\')') .executeScriptInTerminal('remix.execute(\'scripts/log_tx_block.js\')')
// check if the input of the transaction is being logged (web3 call) // check if the input of the transaction is being logged (web3 call)
@ -228,36 +228,66 @@ module.exports = {
}, },
'Should listen on all transactions #group8': function (browser: NightwatchBrowser) { 'Should listen on all transactions #group8': function (browser: NightwatchBrowser) {
const url = 'http://127.0.0.1:8545'
const identifier = 'Custom'
browser browser
.clickLaunchIcon('udapp') // connect to mainnet .clickLaunchIcon('udapp') // connect to mainnet
.switchEnvironment('External Http Provider') .connectToExternalHttpProvider(url, identifier)
.waitForElementPresent('[data-id="basic-http-provider-modal-footer-ok-react"]') .openFile('contracts')
.execute(() => { .openFile('contracts/1_Storage.sol')
(document.querySelector('*[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]') as any).focus() .clickLaunchIcon('solidity')
}, [], () => {}) .click({
.setValue('[data-id="modalDialogCustomPromp"]', 'https://rpc.archivenode.io/e50zmkroshle2e2e50zm0044i7ao04ym') selector: '*[data-id="compilerContainerCompileAndRunBtn"]',
.modalFooterOKClick('basic-http-provider') })
.click('[data-id="terminalClearConsole"]') // clear the console .pause(10000)
.click('[data-id="listenNetworkCheckInput"]') // start to listen .waitForElementNotPresent({
.waitForElementContainsText('*[data-id="terminalJournal"]', 'from:', 200000) locateStrategy: 'xpath',
.waitForElementContainsText('*[data-id="terminalJournal"]', 'to:', 200000) selector: "//*[@class='remix_ui_terminal_log' and contains(.,'to:') and contains(.,'from:')]",
.click('[data-id="terminalClearConsole"]') // clear the console timeout: 120000
.waitForElementContainsText('*[data-id="terminalJournal"]', 'from:', 200000) })
.waitForElementContainsText('*[data-id="terminalJournal"]', 'to:', 200000) .click({
.click('[data-id="listenNetworkCheckInput"]') // stop to listen selector: '[data-id="listenNetworkCheckInput"]',
.pause(30000) }) // start to listen
.click('[data-id="terminalClearConsole"]') // clear the console .click({
.pause(5000) selector: '*[data-id="compilerContainerCompileAndRunBtn"]',
.click('[data-id="terminalClearConsole"]') // clear the console })
.pause(20000) .pause(10000)
.execute(function () { .findElements(
return (document.querySelector('[data-id="terminalJournal"]') as any).innerText {
}, [], function (result) { locateStrategy: 'xpath',
browser.assert.equal(result.value, '', 'terminal log should be empty') selector: "//*[@class='remix_ui_terminal_log' and contains(.,'to:') and contains(.,'from:')]",
timeout: 120000,
}
, async (result) => {
if (Array.isArray(result.value) && result.value.length > 0) {
console.log('Found ' + result.value.length + ' transactions')
browser
.click({
selector: '[data-id="listenNetworkCheckInput"]',
})
.click({
selector: '*[data-id="terminalClearConsole"]',
})
.click({
selector: '*[data-id="compilerContainerCompileAndRunBtn"]',
})
.pause(10000)
.waitForElementNotPresent({
locateStrategy: 'xpath',
selector: "//*[@class='remix_ui_terminal_log' and contains(.,'to:') and contains(.,'from:')]",
timeout: 120000
})
.end()
} else {
browser
.assert.fail('No transaction found')
.end()
}
}) })
} }
} }
const asyncAwait = ` const asyncAwait = `
var p = function () { var p = function () {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {

@ -65,6 +65,7 @@ declare module 'nightwatch' {
currentSelectedFileIs (name: string): NightwatchBrowser, currentSelectedFileIs (name: string): NightwatchBrowser,
switchWorkspace: (workspaceName: string) => NightwatchBrowser switchWorkspace: (workspaceName: string) => NightwatchBrowser
switchEnvironment: (provider: string) => NightwatchBrowser switchEnvironment: (provider: string) => NightwatchBrowser
connectToExternalHttpProvider: (url: string, identifier: string) => NightwatchBrowser
} }
export interface NightwatchBrowser { export interface NightwatchBrowser {

Loading…
Cancel
Save