From 5c35e324c345ac1ede2796ecede0069e0de1ab8a Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 17 Mar 2023 16:34:38 +0100 Subject: [PATCH] re-add test --- apps/remix-ide-e2e/src/tests/terminal.test.ts | 33 ++++++++++++++----- .../editor/src/lib/remix-ui-editor.tsx | 4 +-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index 25dfc34912..9136faa89b 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -317,18 +317,33 @@ module.exports = { .executeScriptInTerminal(`web3.eth.getCode('0x75F509A4eDA030470272DfBAf99A47D587E76709')`) // sepolia contract .waitForElementContainsText('*[data-id="terminalJournal"]', byteCodeInSepolia, 120000) }, - /* + 'Should run free function which logs in the terminal #group10': function (browser: NightwatchBrowser) { - const script = ` - function run () public { - console.log("test running free function"); - } ` + const script = `import "hardhat/console.sol"; + + function runSomething () view { + console.log("test running free run run"); + } + ` browser - .addFile('test.script.sol', {content: script }) - .click('*[data-id="play-editor"]') // run the script + .addFile('test.sol', { content: script }) + .scrollToLine(3) + const path = "//*[@class='view-line' and contains(.,'runSomething') and contains(.,'view')]//span//span[contains(.,'(')]" + const pathRunFunction = `//li//*[@aria-label='Run the free function "runSomething" in the Remix VM']` + browser.waitForElementVisible('#editorView') + .useXpath() + .click(path) + .pause(3000) // the parser need to parse the code + .rightClick(path) + .execute(function () { + // @ts-ignore + document.querySelector('.shadow-root-host').shadowRoot.querySelector(`.monaco-menu span[aria-label='Run the free function "runSomething" in the Remix VM']`).parentElement.click() + }, [], function (result) { + }) + // .click(pathRunFunction) // run the script + .useCss() .waitForElementContainsText('*[data-id="terminalJournal"]', 'test running free function', 120000) - }, - */ + } } diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 45f8d0ba0d..c69d81054b 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -638,7 +638,7 @@ export const EditorUI = (props: EditorUIProps) => { let freeFunctionAction const executeFreeFunctionAction = { id: "executeFreeFunction", - label: "Run free function in the Remix VM", + label: "Run a free function in the Remix VM", contextMenuOrder: 0, // choose the order contextMenuGroupId: "execute", // create a new grouping precondition: 'freeFunctionCondition', @@ -674,7 +674,7 @@ export const EditorUI = (props: EditorUIProps) => { const freeFunctionNode = nodesAtPosition.find((node) => node.kind === 'freeFunction') if (freeFunctionAction) freeFunctionAction.dispose() if (freeFunctionNode) { - executeFreeFunctionAction.label = `Execute the free function "${freeFunctionNode.name}" in the Remix VM` + executeFreeFunctionAction.label = `Run the free function "${freeFunctionNode.name}" in the Remix VM` freeFunctionAction = editor.addAction(executeFreeFunctionAction) } freeFunctionCondition.set(!!freeFunctionNode)