Merge branch 'master' of https://github.com/ethereum/remix-project into e2epluginapi2

indexworkspace2
bunsenstraat 3 years ago
parent 2ebe883b8a
commit 14fbd18b4f
  1. 8
      apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
  2. 193
      apps/remix-ide-e2e/src/tests/plugin_api.ts
  3. 1
      apps/remix-ide/src/assets/css/intro.js/2.7.0/introjs.min.css
  4. 2
      apps/remix-ide/src/assets/css/intro.js/4.1.0/introjs.min.css
  5. 2
      apps/remix-ide/src/remixEngine.js

@ -46,7 +46,8 @@ function App () {
profiles.map((profile: Profile) => {
if (profile.events) {
profile.events.map((event: string) => {
client.on(profile.name as any, event, (...args:any) => {
client.on(profile.name as any, event, (...args: any) => {
console.log('event :', event, args)
setEvents({
event: event,
args: args
@ -67,9 +68,12 @@ function App () {
let ob: any = null
try {
ob = JSON.parse(payload)
} catch (e) {}
if (ob && !Array.isArray(ob)) { ob = [ob] }
} catch (e) { }
const args = ob || [payload]
console.log('calling :', profile.name, method, ...args)
const result = await client.call(profile.name as any, method, ...args)
console.log('result :', result)
setLog(result)
} catch (e) {
setLog(e.message)

@ -1,6 +1,7 @@
'use strict'
import { ExternalProfile, LocationProfile, Profile } from '@remixproject/plugin-utils'
import { NightwatchBrowser } from 'nightwatch'
import { resolve } from 'url'
import init from '../helpers/init'
declare global {
@ -15,7 +16,7 @@ const localPluginData: Profile & LocationProfile & ExternalProfile = {
location: 'sidePanel'
}
const getBrowserLogs = function (browser: NightwatchBrowser) {
const getBrowserLogs = async function (browser: NightwatchBrowser) {
browser.getLog('browser', (logEntries) => {
if (logEntries && logEntries.length > 0) {
console.log('Browser log:')
@ -23,37 +24,72 @@ const getBrowserLogs = function (browser: NightwatchBrowser) {
}
})
}
const debugValues = function (browser: NightwatchBrowser, field: string, expected: string) {
browser.waitForElementVisible(`//*[@id="${field}"]`).getText(`//*[@id="${field}"]`, (result) => {
if (!result.value.toString().includes(expected)) {
console.log('Actual result:')
console.log(result.value.toString())
console.log('Expected result:')
console.log(expected)
getBrowserLogs(browser)
const debugValues = async function (browser: NightwatchBrowser, field: string, expected: any) {
return new Promise((resolve) => {
if (!expected) {
resolve(true)
return
}
browser.waitForElementVisible(`//*[@id="${field}"]`).getText(`//*[@id="${field}"]`, (result) => {
console.log(result)
if (!result.value.toString().includes(expected)) {
console.log('Actual result:')
console.log(result.value.toString())
console.log('Expected result:')
console.log(expected)
getBrowserLogs(browser)
browser.assert.ok(false, 'Returned value from call does not match expected value.')
} else {
browser.assert.ok(true)
}
resolve(true)
})
})
}
const clickAndCheckLog = function (browser: NightwatchBrowser, buttonText: string, methodResult: any, eventResult: any, payload: any) {
if (payload) {
const setPayload = async (browser: NightwatchBrowser, payload: any) => {
return new Promise((resolve) => {
if (typeof payload !== 'string') payload = JSON.stringify(payload)
browser.clearValue('//*[@id="payload"]').setValue('//*[@id="payload"]', payload).pause(1000)
}
if (methodResult && typeof methodResult !== 'string') methodResult = JSON.stringify(methodResult)
if (eventResult && typeof eventResult !== 'string') eventResult = JSON.stringify(eventResult)
browser
.useXpath().waitForElementVisible(`//*[@data-id='${buttonText}']`).click(`//*[@data-id='${buttonText}']`)
.pause(2000)
if (methodResult) {
debugValues(browser, 'methods', methodResult)
browser.waitForElementVisible('//*[@id="methods"]').verify.containsText('//*[@id="methods"]', methodResult)
}
if (eventResult) {
debugValues(browser, 'events', eventResult)
browser.waitForElementVisible('//*[@id="events"]').verify.containsText('//*[@id="events"]', eventResult)
browser.clearValue('//*[@id="payload"]').setValue('//*[@id="payload"]', payload, (result) => {
resolve(result)
})
})
}
const clickButton = async (browser: NightwatchBrowser, buttonText: string) => {
return new Promise((resolve) => {
browser.useXpath().waitForElementVisible(`//*[@data-id='${buttonText}']`)
.click(`//*[@data-id='${buttonText}']`)
.pause(2000, () => resolve(true))
})
}
const checkForAcceptAndRemember = async function (browser: NightwatchBrowser) {
return new Promise((resolve) => {
browser.frameParent().element('xpath', '//*[@data-id="modalDialogModalBody"]', (visible:any) => {
if (visible.status && visible.status === -1) {
// @ts-ignore
browser.frame(0, () => { resolve(true) })
} else {
browser.click('//*[@id="remember"]').click('//*[@id="modal-footer-ok"]', () => {
// @ts-ignore
browser.frame(0, () => { resolve(true) })
})
}
})
})
}
const clickAndCheckLog = async (browser: NightwatchBrowser, buttonText: string, methodResult: any, eventResult: any, payload: any) => {
if (payload) {
await setPayload(browser, payload)
}
if (methodResult && typeof methodResult !== 'string') { methodResult = JSON.stringify(methodResult) }
if (eventResult && typeof eventResult !== 'string') { eventResult = JSON.stringify(eventResult) }
await clickButton(browser, buttonText)
await checkForAcceptAndRemember(browser)
await debugValues(browser, 'methods', methodResult)
await debugValues(browser, 'events', eventResult)
}
const assertPluginIsActive = function (browser: NightwatchBrowser, id: string) {
@ -67,7 +103,7 @@ module.exports = {
afterEach: function (browser: NightwatchBrowser) {
browser.getLog('browser', (logEntries) => {
console.log(logEntries)
// console.log(logEntries)
})
},
@ -79,70 +115,93 @@ module.exports = {
// FILESYSTEM
'Should get current workspace': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'filePanel:getCurrentWorkspace', { name: 'default_workspace', isLocalhost: false, absolutePath: '.workspaces/default_workspace' }, null, null)
'Should get current workspace': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'filePanel:getCurrentWorkspace', { name: 'default_workspace', isLocalhost: false, absolutePath: '.workspaces/default_workspace' }, null, null)
},
'Should get current files': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:readdir', { contracts: { isDirectory: true }, scripts: { isDirectory: true }, tests: { isDirectory: true }, 'README.txt': { isDirectory: false } }, null, null)
'Should get current files': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:readdir', { contracts: { isDirectory: true }, scripts: { isDirectory: true }, tests: { isDirectory: true }, 'README.txt': { isDirectory: false } }, null, null)
},
'Should throw error on current file': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:getCurrentFile', 'Error from IDE : Error: No such file or directory No file selected', null, null)
'Should throw error on current file': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:getCurrentFile', 'Error from IDE : Error: No such file or directory No file selected', null, null)
},
'Should open readme.txt': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:open', null, { event: 'currentFileChanged', args: ['README.txt'] }, 'README.txt')
'Should open readme.txt': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:open', null, { event: 'currentFileChanged', args: ['README.txt'] }, 'README.txt')
},
'Should have current file': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:getCurrentFile', 'README.txt', null, null)
'Should have current file': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:getCurrentFile', 'README.txt', null, null)
},
'Should create dir': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:mkdir', null, null, 'testdir')
clickAndCheckLog(browser, 'fileManager:readdir', 'testdir', null, '/')
'Should create dir': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:mkdir', null, null, 'testdir')
await clickAndCheckLog(browser, 'fileManager:readdir', 'testdir', null, '/')
},
'Should get file': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:getFile', 'REMIX EXAMPLE PROJECT', null, 'README.txt')
'Should get file': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:getFile', 'REMIX EXAMPLE PROJECT', null, 'README.txt')
},
'Should close all files': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:closeAllFiles', null, { event: 'noFileSelected', args: [] }, null)
'Should close all files': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:closeAllFiles', null, { event: 'noFileSelected', args: [] }, null)
},
'Should switch to file': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:switchFile', null, { event: 'currentFileChanged', args: ['contracts/1_Storage.sol'] }, 'contracts/1_Storage.sol')
clickAndCheckLog(browser, 'fileManager:getCurrentFile', 'contracts/1_Storage.sol', null, null)
clickAndCheckLog(browser, 'fileManager:switchFile', null, { event: 'currentFileChanged', args: ['README.txt'] }, 'README.txt')
clickAndCheckLog(browser, 'fileManager:getCurrentFile', 'README.txt', null, null)
'Should switch to file': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:switchFile', null, { event: 'currentFileChanged', args: ['contracts/1_Storage.sol'] }, 'contracts/1_Storage.sol')
await clickAndCheckLog(browser, 'fileManager:getCurrentFile', 'contracts/1_Storage.sol', null, null)
await clickAndCheckLog(browser, 'fileManager:switchFile', null, { event: 'currentFileChanged', args: ['README.txt'] }, 'README.txt')
await clickAndCheckLog(browser, 'fileManager:getCurrentFile', 'README.txt', null, null)
},
'Should write to file': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'fileManager:writeFile', null, { event: 'fileSaved', args: ['README.txt'] }, ['README.txt', 'test'])
// @ts-ignore
browser.frameParent().acceptAndRemember(true, true).frame(0)
clickAndCheckLog(browser, 'fileManager:readFile', 'test', null, 'README.txt')
'Should write to file': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:writeFile', null, { event: 'fileSaved', args: ['README.txt'] }, ['README.txt', 'test'])
await clickAndCheckLog(browser, 'fileManager:readFile', 'test', null, 'README.txt')
},
'Should write to new file': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:writeFile', null, { event: 'fileAdded', args: ['testing.txt'] }, ['testing.txt', 'test'])
await clickAndCheckLog(browser, 'fileManager:readFile', 'test', null, 'testing.txt')
},
'Should rename file': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'fileManager:rename', null, null, ['testing.txt', 'testrename.txt'])
await clickAndCheckLog(browser, 'fileManager:readFile', 'test', null, 'testrename.txt')
},
'Should create workspace': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'filePanel:createWorkspace', null, null, 'testspace')
clickAndCheckLog(browser, 'filePanel:getCurrentWorkspace', { name: 'testspace', isLocalhost: false, absolutePath: '.workspaces/testspace' }, null, null)
clickAndCheckLog(browser, 'fileManager:readdir', { contracts: { isDirectory: true }, scripts: { isDirectory: true }, tests: { isDirectory: true }, 'README.txt': { isDirectory: false } }, null, null)
'Should create empty workspace': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'filePanel:createWorkspace', null, null, ['emptyworkspace', false])
await clickAndCheckLog(browser, 'filePanel:getCurrentWorkspace', { name: 'emptyworkspace', isLocalhost: false, absolutePath: '.workspaces/emptyworkspace' }, null, null)
await clickAndCheckLog(browser, 'fileManager:readdir', {}, null, '/')
},
'Should create workspace': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'filePanel:createWorkspace', null, null, 'testspace')
await clickAndCheckLog(browser, 'filePanel:getCurrentWorkspace', { name: 'testspace', isLocalhost: false, absolutePath: '.workspaces/testspace' }, null, null)
await clickAndCheckLog(browser, 'fileManager:readdir', { contracts: { isDirectory: true }, scripts: { isDirectory: true }, tests: { isDirectory: true }, 'README.txt': { isDirectory: false } }, null, null)
},
// COMPILER
'Should compile a file': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'solidity:compile', null, null, 'contracts/1_Storage.sol')
'Should compile a file': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'solidity:compile', null, null, 'contracts/1_Storage.sol')
},
'Should get compilationresults': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'solidity:getCompilationResult', 'contracts/1_Storage.sol', null, null)
'Should get compilationresults': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'solidity:getCompilationResult', 'contracts/1_Storage.sol', null, null)
},
// DGIT
'Should have changes on new workspace': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'filePanel:createWorkspace', null, null, 'dgit')
clickAndCheckLog(browser, 'dGitProvider:status', [['README.txt', 0, 2, 0], ['contracts/1_Storage.sol', 0, 2, 0], ['contracts/2_Owner.sol', 0, 2, 0], ['contracts/3_Ballot.sol', 0, 2, 0], ['scripts/deploy_ethers.js', 0, 2, 0], ['scripts/deploy_web3.js', 0, 2, 0], ['tests/4_Ballot_test.sol', 0, 2, 0]], null, null)
'Should have changes on new workspace': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'filePanel:createWorkspace', null, null, 'dgit')
await clickAndCheckLog(browser, 'dGitProvider:status', [['README.txt', 0, 2, 0], ['contracts/1_Storage.sol', 0, 2, 0], ['contracts/2_Owner.sol', 0, 2, 0], ['contracts/3_Ballot.sol', 0, 2, 0], ['scripts/deploy_ethers.js', 0, 2, 0], ['scripts/deploy_web3.js', 0, 2, 0], ['tests/4_Ballot_test.sol', 0, 2, 0]], null, null)
},
'Should stage contract': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'dGitProvider:add', null, null, {
filepath: 'contracts/1_Storage.sol'
})
await clickAndCheckLog(browser, 'dGitProvider:status', [['README.txt', 0, 2, 0], ['contracts/1_Storage.sol', 0, 2, 2], ['contracts/2_Owner.sol', 0, 2, 0], ['contracts/3_Ballot.sol', 0, 2, 0], ['scripts/deploy_ethers.js', 0, 2, 0], ['scripts/deploy_web3.js', 0, 2, 0], ['tests/4_Ballot_test.sol', 0, 2, 0]], null, null)
},
'Should commit changes': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'dGitProvider:commit', null, null, { author: { name: 'Remix', email: 'Remix' }, message: 'commit-message' })
await clickAndCheckLog(browser, 'dGitProvider:log', 'commit-message', null, null)
},
// UNIT TESTING
'Should activate solidityUnitTesting': function (browser: NightwatchBrowser) {
clickAndCheckLog(browser, 'manager:activatePlugin', null, null, 'solidityUnitTesting')
'Should activate solidityUnitTesting': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'manager:activatePlugin', null, null, 'solidityUnitTesting')
browser.frameParent()
assertPluginIsActive(browser, 'solidityUnitTesting')
// @ts-ignore

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -13,7 +13,7 @@ export class RemixEngine extends Engine {
if (name === 'dGitProvider') return { queueTimeout: 60000 * 4 }
if (name === 'slither') return { queueTimeout: 60000 * 4 } // Requires when a solc version is installed
if (name === 'hardhat') return { queueTimeout: 60000 * 4 }
if (name === 'solidityUnitTesting') return { queueTimeout: 60000 * 4 }
if (name === 'localPlugin') return { queueTimeout: 60000 * 4 }
return { queueTimeout: 10000 }
}

Loading…
Cancel
Save