pull/5370/head
bunsenstraat 3 years ago
parent 7bdf308a9a
commit a91ccd394e
  1. 23
      apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts
  2. 33
      apps/remix-ide-e2e/src/tests/plugin_api.test.ts
  3. 2
      apps/remix-ide/ci/browser_tests_plugin_api.sh
  4. 2
      package.json

@ -310,7 +310,11 @@ export class WorkSpacePlugin extends PluginClient {
} }
async write (dir: string) { async write (dir: string) {
this.call('fileManager', 'setFile', dir, simpleContract) try {
this.call('fileManager', 'setFile', dir, 'simple readme')
} catch (e) {
this.setFeedback(e.message)
}
} }
async getcurrentfile () { async getcurrentfile () {
@ -322,8 +326,13 @@ export class WorkSpacePlugin extends PluginClient {
} }
} }
async switchfile (dir: string) { async switchfile(dir: string) {
var files = await this.call('fileManager', 'switchFile', dir)
try {
const files = await this.call('fileManager', 'switchFile', dir)
} catch (e) {
this.setFeedback(e.message)
}
} }
async zip () { async zip () {
@ -514,13 +523,13 @@ export class WorkSpacePlugin extends PluginClient {
} }
} }
` `
await this.call('fileManager', 'setFile', '/modifyVariable.sol', f) //await this.call('fileManager', 'setFile', '/modifyVariable.sol', f)
await this.call('fileManager', 'switchFile', '/modifyVariable.sol') await this.call('fileManager', 'switchFile', 'tests/4_Ballot_test.sol')
await this.call('fileManager', 'setFile', '/modifyVariable_test.sol', t) //await this.call('fileManager', 'setFile', '/modifyVariable_test.sol', t)
const result = await this.call( const result = await this.call(
'solidityUnitTesting', 'solidityUnitTesting',
'testFromPath', 'testFromPath',
'modifyVariable_test.sol' 'tests/4_Ballot_test.sol'
) )
this.setFeedback(result) this.setFeedback(result)
} }

@ -13,6 +13,12 @@ const localPluginData = {
pluginUrl: 'http://localhost:2020' pluginUrl: 'http://localhost:2020'
} }
const getBrowserLogs = function (browser: NightwatchBrowser) {
browser.getLog('browser', (logEntries) => {
console.log(logEntries)
})
}
const assertLog = function (browser: NightwatchBrowser, buttonText: string, msg: any, payload: string) { const assertLog = function (browser: NightwatchBrowser, buttonText: string, msg: any, payload: string) {
if (payload) { if (payload) {
browser.clearValue('//*[@id="payload"]').setValue('//*[@id="payload"]', payload).pause(1000) browser.clearValue('//*[@id="payload"]').setValue('//*[@id="payload"]', payload).pause(1000)
@ -22,16 +28,27 @@ const assertLog = function (browser: NightwatchBrowser, buttonText: string, msg:
.useXpath().waitForElementVisible(`//*[text()='${buttonText}']`).click(`//*[text()='${buttonText}']`) .useXpath().waitForElementVisible(`//*[text()='${buttonText}']`).click(`//*[text()='${buttonText}']`)
.pause(2000) .pause(2000)
getBrowserLogs(browser)
if (msg) { if (msg) {
browser.waitForElementVisible('//*[@id="log"]').assert.containsText('//*[@id="log"]', msg) browser.waitForElementVisible('//*[@id="log"]').verify.containsText('//*[@id="log"]', msg)
} }
} }
const assertPluginIsActive = function (browser: NightwatchBrowser, id: string) {
browser.waitForElementVisible(`//*[@data-id="verticalIconsKind${id}"]`)
}
module.exports = { module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) { before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', false) init(browser, done, 'http://127.0.0.1:8080', false)
}, },
afterEach: function (browser: NightwatchBrowser) {
browser.getLog('browser', (logEntries) => {
console.log(logEntries)
})
},
'Should Load Plugin Manager': function (browser: NightwatchBrowser) { 'Should Load Plugin Manager': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]') browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]')
.pause(3000) .pause(3000)
@ -81,6 +98,20 @@ module.exports = {
}, },
'Should activate solidityUnitTesting': function (browser: NightwatchBrowser) { 'Should activate solidityUnitTesting': function (browser: NightwatchBrowser) {
assertLog(browser, 'activate', null, 'solidityUnitTesting') assertLog(browser, 'activate', null, 'solidityUnitTesting')
browser.frameParent()
assertPluginIsActive(browser, 'solidityUnitTesting')
// @ts-ignore
browser.frame(0)
},
'Should switch to file': function (browser: NightwatchBrowser) {
assertLog(browser, 'switch to file', null, 'contracts/1_Storage.sol')
assertLog(browser, 'getcurrentfile', 'contracts/1_Storage.sol', null)
assertLog(browser, 'switch to file', null, 'README.txt')
assertLog(browser, 'getcurrentfile', 'README.txt', null)
},
'Should write to file': function (browser: NightwatchBrowser) {
assertLog(browser, 'write', 'README.txt', null)
} }
} }

@ -9,7 +9,7 @@ TEST_EXITCODE=0
npm run serve & npm run serve &
npx nx serve remix-ide-e2e-src-local-plugin & npx nx serve remix-ide-e2e-src-local-plugin &
sleep 5 & sleep 5 &
npm run testcafe_local_pluginApi || TEST_EXITCODE=1 npm run nightwatch_local_pluginApi || TEST_EXITCODE=1
echo "$TEST_EXITCODE" echo "$TEST_EXITCODE"
if [ "$TEST_EXITCODE" -eq 1 ] if [ "$TEST_EXITCODE" -eq 1 ]

@ -90,7 +90,7 @@
"nightwatch_local_runAndDeploy": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/runAndDeploy.js --env=chrome-runAndDeploy", "nightwatch_local_runAndDeploy": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/runAndDeploy.js --env=chrome-runAndDeploy",
"nightwatch_local_url": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/url.spec.js --env=chrome", "nightwatch_local_url": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/url.spec.js --env=chrome",
"nightwatch_local_verticalIconscontextmenu": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/verticalIconsPanel.spec.js --env=chrome", "nightwatch_local_verticalIconscontextmenu": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/verticalIconsPanel.spec.js --env=chrome",
"testcafe_local_pluginApi": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/plugin_api.test.js --env=chrome", "nightwatch_local_pluginApi": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/plugin_api.test.js --env=chrome",
"onchange": "onchange apps/remix-ide/build/app.js -- npm-run-all lint", "onchange": "onchange apps/remix-ide/build/app.js -- npm-run-all lint",
"remixd": "nx build remixd && nx serve remixd --folder=./apps/remix-ide/contracts --remixide=http://127.0.0.1:8080", "remixd": "nx build remixd && nx serve remixd --folder=./apps/remix-ide/contracts --remixide=http://127.0.0.1:8080",
"selenium": "selenium-standalone start", "selenium": "selenium-standalone start",

Loading…
Cancel
Save