From 38d769b717537a88d3d19cba4d5cfa0ea05ce90e Mon Sep 17 00:00:00 2001 From: yann300 Date: Sun, 19 Mar 2023 13:16:39 +0100 Subject: [PATCH] fix test --- apps/remix-ide-e2e/src/tests/terminal.test.ts | 14 +++++++------- libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 8 ++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index 9136faa89b..0e64b513da 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -322,7 +322,7 @@ module.exports = { const script = `import "hardhat/console.sol"; function runSomething () view { - console.log("test running free run run"); + console.log("test running free function"); } ` browser @@ -334,13 +334,13 @@ module.exports = { .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) { + .perform(function () { + const actions = this.actions({ async: true }); + return actions + .keyDown(this.Keys.SHIFT) + .keyDown(this.Keys.ALT) + .sendKeys('r') }) - // .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 c69d81054b..eabeb3557d 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -642,6 +642,10 @@ export const EditorUI = (props: EditorUIProps) => { contextMenuOrder: 0, // choose the order contextMenuGroupId: "execute", // create a new grouping precondition: 'freeFunctionCondition', + keybindings: [ + // eslint-disable-next-line no-bitwise + monacoRef.current.KeyMod.Shift | monacoRef.current.KeyMod.Alt | monacoRef.current.KeyCode.KeyR, + ], run: async () => { const { nodesAtPosition } = await retrieveNodesAtPosition(props.editorAPI, props.plugin) // find the contract and get the nodes of the contract and the base contracts and imports @@ -661,6 +665,10 @@ export const EditorUI = (props: EditorUIProps) => { editor.addAction(formatAction) editor.addAction(zoomOutAction) editor.addAction(zoominAction) + editor.addAction(executeFreeFunctionAction) + + // we have to add the command because the menu action isn't always available (see onContextMenuHandlerForFreeFunction) + editor.addCommand(monacoRef.current.KeyMod.Shift | monacoRef.current.KeyMod.Alt | monacoRef.current.KeyCode.KeyR, () => executeFreeFunctionAction.run()) const contextmenu = editor.getContribution('editor.contrib.contextmenu') const orgContextMenuMethod = contextmenu._onContextMenu;