diff --git a/apps/remix-ide-e2e/src/commands/executeScript.ts b/apps/remix-ide-e2e/src/commands/executeScript.ts index 77649a2664..42654b8d54 100644 --- a/apps/remix-ide-e2e/src/commands/executeScript.ts +++ b/apps/remix-ide-e2e/src/commands/executeScript.ts @@ -6,6 +6,13 @@ class ExecuteScript extends EventEmitter { this.api .clearEditableContent('*[data-id="terminalCliInput"]') .click('*[data-id="terminalCli"]') + .pause(2000) + .sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.BACK_SPACE) + .sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.BACK_SPACE) + .sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.BACK_SPACE) + .sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.BACK_SPACE) + .sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.BACK_SPACE) + .sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.BACK_SPACE) .sendKeys('*[data-id="terminalCliInput"]', script) .sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.ENTER) .sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.ENTER) diff --git a/apps/remix-ide-e2e/src/commands/testFunction.ts b/apps/remix-ide-e2e/src/commands/testFunction.ts index 8503c8fcfe..371fec9568 100644 --- a/apps/remix-ide-e2e/src/commands/testFunction.ts +++ b/apps/remix-ide-e2e/src/commands/testFunction.ts @@ -24,6 +24,7 @@ class TestFunction extends EventEmitter { .perform((done) => { browser.waitForElementVisible(`[data-id="block_tx${txHash}"]`, 60000) .click(`[data-id="block_tx${txHash}"]`) + .pause(3000) .waitForElementVisible(`*[data-id="txLoggerTable${txHash}"]`, 60000) // fetch and format transaction logs as key => pair object .elements('css selector', `*[data-shared="key_${txHash}"]`, (res) => { diff --git a/apps/remix-ide-e2e/src/tests/compiler_api.test.ts b/apps/remix-ide-e2e/src/tests/compiler_api.test.ts index 4128a057bd..cc81e5ace4 100644 --- a/apps/remix-ide-e2e/src/tests/compiler_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/compiler_api.test.ts @@ -21,7 +21,7 @@ module.exports = { browser .addFile('test_jsCompile.js', { content: jsCompile }) .executeScript('remix.exeCurrent()') - .waitForElementContainsText('*[data-id="terminalJournal"]', '"languageversion": "0.6.8+commit.0bbfe453"', 60000) + .waitForElementContainsText('*[data-id="terminalJournal"]', '"languageversion":"0.6.8+commit.0bbfe453"', 60000) .click('*[data-id="terminalClearConsole"]') }, diff --git a/apps/remix-ide-e2e/src/tests/fileManager_api.spec.ts b/apps/remix-ide-e2e/src/tests/fileManager_api.spec.ts index 26a49d9beb..b1ec96491f 100644 --- a/apps/remix-ide-e2e/src/tests/fileManager_api.spec.ts +++ b/apps/remix-ide-e2e/src/tests/fileManager_api.spec.ts @@ -11,6 +11,7 @@ module.exports = { browser .addFile('file.js', { content: executeFile }) .executeScript('remix.exeCurrent()') + .pause(5000) .waitForElementContainsText('*[data-id="terminalJournal"]', 'file.js', 60000) }, @@ -72,7 +73,8 @@ module.exports = { browser .addFile('readdirFile.js', { content: executeReaddir }) .executeScript('remix.exeCurrent()') - .waitForElementContainsText('*[data-id="terminalJournal"]', 'Test_Folder isDirectory true', 60000) + .waitForElementContainsText('*[data-id="terminalJournal"]', 'Test_Folder isDirectory', 60000) + .waitForElementContainsText('*[data-id="terminalJournal"]', 'true', 5000) }, 'Should execute `remove` api from file manager external api': function (browser: NightwatchBrowser) { @@ -175,8 +177,8 @@ const executeMkdir = ` const executeReaddir = ` const run = async () => { const result = await remix.call('fileManager', 'readdir', '/') - - console.log('Test_Folder isDirectory ', result["Test_Folder"].isDirectory) + const output = result["Test_Folder"].isDirectory + console.log('Test_Folder isDirectory ', output) } run() diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index c6407f4942..28ac94ded4 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -223,7 +223,9 @@ module.exports = { .pause(2000) .scrollAndClick('[data-id="pluginManagerComponentActivateButtonsolidityUnitTesting"]') .clickLaunchIcon('solidityUnitTesting') + .pause(5000) .scrollAndClick('#runTestsTabRunAction') + .pause(2000) .waitForElementVisible('*[data-id="testTabSolidityUnitTestsOutputheader"]', 120000) .waitForElementPresent('#solidityUnittestsOutput div[class^="testPass"]', 60000) .waitForElementContainsText('#solidityUnittestsOutput', 'tests/4_Ballot_test.sol', 60000) diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index feb9233387..e3834d1373 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -11,6 +11,7 @@ module.exports = { browser .waitForElementVisible('*[data-id="terminalCli"]', 10000) .executeScript('console.log(1 + 1)') + .pause(2000) .waitForElementContainsText('*[data-id="terminalJournal"]', '2', 60000) }, @@ -30,24 +31,14 @@ module.exports = { .assert.visible('*[data-id="autoCompletePopUpAutoCompleteItem"]') }, - // 'Should execute remix.help() command': function (browser: NightwatchBrowser) { - // browser - // .waitForElementVisible('*[data-id="terminalCli"]') - // // .executeScript('remix.help()') - // .waitForElementContainsText('*[data-id="terminalJournal"]', 'remix.loadgist(id)', 60000) - // .waitForElementContainsText('*[data-id="terminalJournal"]', 'remix.loadurl(url)', 60000) - // .waitForElementContainsText('*[data-id="terminalJournal"]', 'remix.execute(filepath)', 60000) - // .waitForElementContainsText('*[data-id="terminalJournal"]', 'remix.exeCurrent()', 60000) - // // .waitForElementContainsText('*[data-id="terminalJournal"]', 'remix.help()', 60000) - // }, - 'Async/Await Script': function (browser: NightwatchBrowser) { browser .addFile('asyncAwait.js', { content: asyncAwait }) .openFile('asyncAwait.js') - .executeScript('remix.execute(\'asyncAwait.js\')') + .executeScript('remix.execute("asyncAwait.js")') .waitForElementContainsText('*[data-id="terminalJournal"]', 'Waiting Promise', 60000) - .waitForElementContainsText('*[data-id="terminalJournal"]', 'result - Promise Resolved', 60000) + .waitForElementContainsText('*[data-id="terminalJournal"]', 'result - ', 60000) + .waitForElementContainsText('*[data-id="terminalJournal"]', 'Promise Resolved', 60000) }, 'Call Remix File Manager from a script': function (browser: NightwatchBrowser) { @@ -62,19 +53,20 @@ module.exports = { 'Call web3.eth.getAccounts() using JavaScript VM': function (browser: NightwatchBrowser) { browser .executeScript('web3.eth.getAccounts()') - .waitForElementContainsText('*[data-id="terminalJournal"]', '"0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2", "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c", "0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db", "0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB", "0x617F2E2fD72FD9D5503197092aC168c91465E7f2", "0x17F6AD8Ef982297579C203069C1DbfFE4348c372", "0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C"', 80000) + // .waitForElementContainsText('*[data-id="terminalJournal"]', '"0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2", "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c", "0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db", "0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB", "0x617F2E2fD72FD9D5503197092aC168c91465E7f2", "0x17F6AD8Ef982297579C203069C1DbfFE4348c372", "0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C"', 80000) + .waitForElementContainsText('*[data-id="terminalJournal"]', '["0x5B38Da6a701c568545dCfcB03FcB875f56beddC4","0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2","0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c","0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db","0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB","0x617F2E2fD72FD9D5503197092aC168c91465E7f2","0x17F6AD8Ef982297579C203069C1DbfFE4348c372","0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C","0x5c6B0f7Bf3E7ce046039Bd8FABdfD3f9F5021678","0x03C6FcED478cBbC9a4FAB34eF9f40767739D1Ff7","0x1aE0EA34a72D944a8C7603FfB3eC30a6669E454C","0x0A098Eda01Ce92ff4A4CCb7A4fFFb5A43EBC70DC","0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB","0x583031D1113aD414F02576BD6afaBfb302140225","0xdD870fA1b7C4700F2BD7f44238821C26f7392148"]', 80000) }, 'Call web3.eth.getAccounts() using Web3 Provider': function (browser: NightwatchBrowser) { browser - .click('*[data-id="terminalClearConsole"]') // clear the terminal + .click('*[data-id="terminalClearConsole"]') // clear the terminal .clickLaunchIcon('udapp') .click('*[data-id="settingsWeb3Mode"]') .modalFooterOKClick() .executeScript('web3.eth.getAccounts()') - .waitForElementContainsText('*[data-id="terminalJournal"]', '[ "', 60000) // we check if an array is present, don't need to check for the content - .waitForElementContainsText('*[data-id="terminalJournal"]', '" ]', 60000) - .waitForElementContainsText('*[data-id="terminalJournal"]', '", "', 60000) + .waitForElementContainsText('*[data-id="terminalJournal"]', '["', 60000) // we check if an array is present, don't need to check for the content + .waitForElementContainsText('*[data-id="terminalJournal"]', '"]', 60000) + .waitForElementContainsText('*[data-id="terminalJournal"]', '","', 60000) }, 'Call Remix File Resolver (external URL) from a script': function (browser: NightwatchBrowser) { diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts index 7dfbd968e9..55f2eadacb 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts @@ -99,7 +99,7 @@ module.exports = { 'decoded output': { 0: 'uint256: _uret 2343242', 1: 'int256: _iret -4324324', - 2: 'string: _strret string _ string _ string _ string _ string _ string _ string _ string _ string _ string _' + 2: 'string: _strret string _ string _ string _ string _ string _ string _ string _ string _ string _ string _' } }) .pause(500) @@ -147,12 +147,13 @@ module.exports = { .waitForElementPresent('.instance:nth-of-type(3)') .click('.instance:nth-of-type(3) > div > button') .clickFunction('g - transact (not payable)') + .pause(5000) .journalLastChildIncludes('Error provided by the contract:') .journalLastChildIncludes('CustomError : error description') .journalLastChildIncludes('Parameters:') - .journalLastChildIncludes('"value": "2",') - .journalLastChildIncludes('"value": "3",') - .journalLastChildIncludes('"value": "error_string_2",') + .journalLastChildIncludes('"value": "2"') + .journalLastChildIncludes('"value": "3"') + .journalLastChildIncludes('"value": "error_string_2"') .journalLastChildIncludes('"documentation": "param1"') .journalLastChildIncludes('"documentation": "param2"') .journalLastChildIncludes('"documentation": "param3"') @@ -170,9 +171,9 @@ module.exports = { .journalLastChildIncludes('Error provided by the contract:') .journalLastChildIncludes('CustomError : error description') .journalLastChildIncludes('Parameters:') - .journalLastChildIncludes('"value": "2",') - .journalLastChildIncludes('"value": "3",') - .journalLastChildIncludes('"value": "error_string_2",') + .journalLastChildIncludes('"value": "2"') + .journalLastChildIncludes('"value": "3"') + .journalLastChildIncludes('"value": "error_string_2"') .journalLastChildIncludes('"documentation": "param1"') .journalLastChildIncludes('"documentation": "param2"') .journalLastChildIncludes('"documentation": "param3"') diff --git a/libs/remix-ui/terminal/src/lib/commands.ts b/libs/remix-ui/terminal/src/lib/commands.ts index 97e2a3f2f2..cc3b5e6963 100644 --- a/libs/remix-ui/terminal/src/lib/commands.ts +++ b/libs/remix-ui/terminal/src/lib/commands.ts @@ -6,7 +6,7 @@ export const allPrograms = [ ] export const allCommands = [ - // { 'remix.execute(filepath)': 'Run the script specified by file path. If filepath is empty, script currently displayed in the editor is executed.' }, + { 'remix.execute(filepath)': 'Run the script specified by file path. If filepath is empty, script currently displayed in the editor is executed.' }, { 'remix.exeCurrent()': 'Run the script currently displayed in the editor.' }, // { 'remix.help()': 'Display this help message.' }, { 'remix.loadgist(id)': 'Load a gist in the file explorer.' }, diff --git a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx index 090d85242f..20e495a4bd 100644 --- a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx +++ b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx @@ -225,7 +225,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { if (script.indexOf('remix.') === 0) { // we keep the old feature. This will basically only be called when the command is querying the "remix" object. // for all the other case, we use the Code Executor plugin - const context = { remix: { exeCurrent: () => { return execute(undefined, undefined) }, loadgist: (id: any) => { return loadgist(id, () => {}) } } } + const context = { remix: { exeCurrent: (script: any) => { return execute(undefined, script) }, loadgist: (id: any) => { return loadgist(id, () => {}) }, execute: (fileName, callback) => { return execute(fileName, callback) } } } try { const cmds = vm.createContext(context) const result = vm.runInContext(script, cmds) @@ -345,9 +345,15 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { } if (autoCompletState.showSuggestions && (event.which === 13 || event.which === 9)) { if (autoCompletState.userInput.length === 1) { + console.log('enter with single autoComplete') setAutoCompleteState(prevState => ({ ...prevState, activeSuggestion: 0, showSuggestions: false, userInput: Object.keys(autoCompletState.data._options[0]).toString() })) } else { - setAutoCompleteState(prevState => ({ ...prevState, activeSuggestion: 0, showSuggestions: false, userInput: inputEl.current.value })) + if (autoCompletState.showSuggestions && (event.which === 13 || event.which === 9)) { + setAutoCompleteState(prevState => ({ ...prevState, activeSuggestion: 0, showSuggestions: false, userInput: autoCompletState.data._options[autoCompletState.activeSuggestion] ? Object.keys(autoCompletState.data._options[autoCompletState.activeSuggestion]).toString() : inputEl.current.value })) + } else { + console.log('enter with muti autoCOmplete', { autoCompletState }) + setAutoCompleteState(prevState => ({ ...prevState, activeSuggestion: 0, showSuggestions: false, userInput: autoCompletState.data._options.length === 1 ? Object.keys(autoCompletState.data._options[0]).toString() : inputEl.current.value })) + } } } if (event.which === 13 && !autoCompletState.showSuggestions) { @@ -1386,6 +1392,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { return (
+ { console.log({ newstate })}
{/* ${self._view.dragbar} */}
@@ -1460,7 +1467,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { return x.message.map((trans) => { return (
{ trans.tx.isCall ? renderCall(trans.tx, trans.resolvedData, trans.logs, index) : renderKnownTransactions(trans.tx, trans.receipt, trans.resolvedData, trans.logs, index)}
) }) - } else { + } else if (Array.isArray(x.message)) { return x.message.map((msg, i) => { if (typeof msg === 'object') { return ( @@ -1468,10 +1475,14 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { ) } else { return ( -
{ msg }
+
{ msg ? msg.toString().replace(/,/g, '') : msg }
) } }) + } else { + return ( +
{x.message}
+ ) } })}