From 0c2e4e6db2b49659c94b6ecc6e7e26e5b27e86b0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 22 Sep 2020 11:52:50 +0200 Subject: [PATCH] call plugin using URL params after page load --- .../remix-ide-e2e/src/tests/workspace.test.ts | 12 +++++++-- apps/remix-ide/src/app.js | 25 ++++++++++++------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index ecd87bd9c0..d2739b2e64 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -5,14 +5,22 @@ import sauce from './sauce' module.exports = { before: function (browser: NightwatchBrowser, done: VoidFunction) { - init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false) + init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp&plugincall=fileManager//open//3_Ballot.sol', false) }, 'CheckSolidityActivatedAndUDapp': function (browser: NightwatchBrowser) { browser .waitForElementVisible('#icon-panel', 10000) .clickLaunchIcon('solidity') - .clickLaunchIcon('udapp') + .clickLaunchIcon('udapp') + }, + + 'Editor should be focused on the 3_Ballot.sol': function (browser: NightwatchBrowser) { + browser + .pause(5000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf('contract Ballot {') != -1, 'content doesn\'t include Ballot contract') + }) .end() }, diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 8e049113e2..87fab9f7c5 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -403,12 +403,22 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const params = queryParams.get() // Set workspace after initial activation - if (Array.isArray(workspace)) { - try { - await appManager.activatePlugin(workspace) - } catch (e) { - console.error(e) - } + if (Array.isArray(workspace)) { + appManager.activatePlugin(workspace).then(() => { + // If plugins are loaded from the URL params, we focus on the last one. + if (pluginLoader.current === 'queryParams' && workspace.length > 0) menuicons.select(workspace[workspace.length - 1]) + + if (params.plugincall) { + const callDetails = params.plugincall.split('//') + if (callDetails.length > 1) { + toolTip(`initiating ${callDetails[0]} ...`) + // @todo(remove the timeout when activatePlugin is on 0.3.0) + setTimeout(() => { + appManager.call(...callDetails).catch(console.error) + }, 5000) + } + } + }).catch(console.error) } else { // activate solidity plugin appManager.ensureActivated('solidity') @@ -419,9 +429,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const framingService = new FramingService(sidePanel, menuicons, mainview, this._components.resizeFeature) framingService.start(params) - // If plugins are loaded from the URL params, we focus on the last one. - if (pluginLoader.current === 'queryParams' && Array.isArray(workspace) && workspace.length > 0) menuicons.select(workspace[workspace.length - 1]) - // get the file list from the parent iframe loadFileFromParent(fileManager)