From a91ccd394e4887bfa9ef351747f4febda32cee21 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Sat, 16 Oct 2021 15:18:48 +0200 Subject: [PATCH] e2e --- .../src/local-plugin/src/app/Client.ts | 23 +++++++++---- .../src/tests/plugin_api.test.ts | 33 ++++++++++++++++++- apps/remix-ide/ci/browser_tests_plugin_api.sh | 2 +- package.json | 2 +- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts b/apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts index 169af33c8d..3fbe6fe6c0 100644 --- a/apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts +++ b/apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts @@ -310,7 +310,11 @@ export class WorkSpacePlugin extends PluginClient { } 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 () { @@ -322,8 +326,13 @@ export class WorkSpacePlugin extends PluginClient { } } - async switchfile (dir: string) { - var files = await this.call('fileManager', 'switchFile', dir) + async switchfile(dir: string) { + + try { + const files = await this.call('fileManager', 'switchFile', dir) + } catch (e) { + this.setFeedback(e.message) + } } async zip () { @@ -514,13 +523,13 @@ export class WorkSpacePlugin extends PluginClient { } } ` - await this.call('fileManager', 'setFile', '/modifyVariable.sol', f) - await this.call('fileManager', 'switchFile', '/modifyVariable.sol') - await this.call('fileManager', 'setFile', '/modifyVariable_test.sol', t) + //await this.call('fileManager', 'setFile', '/modifyVariable.sol', f) + await this.call('fileManager', 'switchFile', 'tests/4_Ballot_test.sol') + //await this.call('fileManager', 'setFile', '/modifyVariable_test.sol', t) const result = await this.call( 'solidityUnitTesting', 'testFromPath', - 'modifyVariable_test.sol' + 'tests/4_Ballot_test.sol' ) this.setFeedback(result) } diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.test.ts b/apps/remix-ide-e2e/src/tests/plugin_api.test.ts index 5129345e31..8ade0fec9b 100644 --- a/apps/remix-ide-e2e/src/tests/plugin_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/plugin_api.test.ts @@ -13,6 +13,12 @@ const localPluginData = { 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) { if (payload) { 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}']`) .pause(2000) + getBrowserLogs(browser) 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 = { before: function (browser: NightwatchBrowser, done: VoidFunction) { 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) { browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]') .pause(3000) @@ -81,6 +98,20 @@ module.exports = { }, 'Should activate solidityUnitTesting': function (browser: NightwatchBrowser) { 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) } } diff --git a/apps/remix-ide/ci/browser_tests_plugin_api.sh b/apps/remix-ide/ci/browser_tests_plugin_api.sh index a5142b716b..e024d72c31 100755 --- a/apps/remix-ide/ci/browser_tests_plugin_api.sh +++ b/apps/remix-ide/ci/browser_tests_plugin_api.sh @@ -9,7 +9,7 @@ TEST_EXITCODE=0 npm run serve & npx nx serve remix-ide-e2e-src-local-plugin & sleep 5 & -npm run testcafe_local_pluginApi || TEST_EXITCODE=1 +npm run nightwatch_local_pluginApi || TEST_EXITCODE=1 echo "$TEST_EXITCODE" if [ "$TEST_EXITCODE" -eq 1 ] diff --git a/package.json b/package.json index ad8a7d9ab8..93f35b8579 100644 --- a/package.json +++ b/package.json @@ -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_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", - "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", "remixd": "nx build remixd && nx serve remixd --folder=./apps/remix-ide/contracts --remixide=http://127.0.0.1:8080", "selenium": "selenium-standalone start",