From c5dc0eaded70d05457ee18f0c92ab76eef30bc5c Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 14 Mar 2022 15:20:46 +0100 Subject: [PATCH 01/16] fix e2e --- apps/remix-ide-e2e/src/tests/{url.spec.ts => url.test.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/remix-ide-e2e/src/tests/{url.spec.ts => url.test.ts} (100%) diff --git a/apps/remix-ide-e2e/src/tests/url.spec.ts b/apps/remix-ide-e2e/src/tests/url.test.ts similarity index 100% rename from apps/remix-ide-e2e/src/tests/url.spec.ts rename to apps/remix-ide-e2e/src/tests/url.test.ts From e44fe2c7c5e9e58cddaa05b6822f086711d67ecc Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 14 Mar 2022 16:56:41 +0100 Subject: [PATCH 02/16] fix loading external files --- .../workspace/src/lib/actions/workspace.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 64079f315b..681f678332 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -85,7 +85,7 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp case 'code-template': // creates a new workspace code-sample and loads code from url params. try { - let path = ''; let content = '' + let path = ''; let content if (params.code) { const hash = bufferToHex(keccakFromString(params.code)) @@ -99,15 +99,20 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp path = data.cleanUrl content = data.content - if (content && typeof content === 'object') { - const standardInput = content as JSONStandardInput - if (standardInput.language && standardInput.language === "Solidity" && standardInput.sources) { + + try { + content = JSON.parse(content) as any + if (content.language && content.language === "Solidity" && content.sources) { + const standardInput: JSONStandardInput = content as JSONStandardInput for (const [fname, source] of Object.entries(standardInput.sources)) { await workspaceProvider.set(fname, source.content) } + return Object.keys(standardInput.sources)[0] + } else { + workspaceProvider.set(path, JSON.stringify(content)) } - return Object.keys(standardInput.sources)[0] - } else { + } catch (e) { + console.log(e) workspaceProvider.set(path, content) } } From b03c34a24337d832ec6088c89a5c816a89d2f574 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 14 Mar 2022 16:56:56 +0100 Subject: [PATCH 03/16] create error --- apps/remix-ide-e2e/src/tests/url.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/url.test.ts b/apps/remix-ide-e2e/src/tests/url.test.ts index 56a94e34a9..df5b772638 100644 --- a/apps/remix-ide-e2e/src/tests/url.test.ts +++ b/apps/remix-ide-e2e/src/tests/url.test.ts @@ -115,7 +115,7 @@ module.exports = { .openFile('@openzeppelin') .openFile('@openzeppelin/contracts') .openFile('@openzeppelin/contracts/access') - .openFile('@openzeppelin/contracts/access/AccessControl.sol') + .openFile('@openzeppelin/contracts/access/AccessCdsfdsfdsfsdontrol.sol') .openFile('contracts') .openFile('contracts/governance') .openFile('contracts/governance/UnionGovernor.sol') From b4d5c6f7639a8d653c4036831e603360f15a8a37 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 14 Mar 2022 18:07:52 +0100 Subject: [PATCH 04/16] reenable e2e test --- apps/remix-ide-e2e/src/checkGroupTests.js | 2 +- apps/remix-ide-e2e/src/select_tests.sh | 2 +- .../src/tests/{stress.editor.ts => stressEditor.test.ts} | 0 apps/remix-ide-e2e/src/tests/url.test.ts | 4 ++-- apps/remix-ide/ci/browser_test.sh | 2 +- apps/remix-ide/ci/browser_tests_plugin_api.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename apps/remix-ide-e2e/src/tests/{stress.editor.ts => stressEditor.test.ts} (100%) diff --git a/apps/remix-ide-e2e/src/checkGroupTests.js b/apps/remix-ide-e2e/src/checkGroupTests.js index dba67a920e..bc833723a1 100644 --- a/apps/remix-ide-e2e/src/checkGroupTests.js +++ b/apps/remix-ide-e2e/src/checkGroupTests.js @@ -6,7 +6,7 @@ fs.readdirSync(testFolder).forEach(file => { const content = fs.readFileSync(testFolder + file, 'utf8') const matches = content.match(/group\d+/g) if (matches) { - const disabled = content.includes('@disabled') + const disabled = content.includes('@disabled: true') if (!disabled) { console.log(`WARNING ${file} has group tests but is not disabled`) } diff --git a/apps/remix-ide-e2e/src/select_tests.sh b/apps/remix-ide-e2e/src/select_tests.sh index 4cd3f36c00..05fa3ce3c8 100644 --- a/apps/remix-ide-e2e/src/select_tests.sh +++ b/apps/remix-ide-e2e/src/select_tests.sh @@ -26,7 +26,7 @@ do done npm run build:e2e PS3='Select a test or command: ' -TESTFILES=( $(grep -IRiL "disabled" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test\|plugin_api" | sort ) ) +TESTFILES=( $(grep -IRiL "@disabled: true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test\|plugin_api" | sort ) ) # declare -p TESTFILES TESTFILES+=("list") diff --git a/apps/remix-ide-e2e/src/tests/stress.editor.ts b/apps/remix-ide-e2e/src/tests/stressEditor.test.ts similarity index 100% rename from apps/remix-ide-e2e/src/tests/stress.editor.ts rename to apps/remix-ide-e2e/src/tests/stressEditor.test.ts diff --git a/apps/remix-ide-e2e/src/tests/url.test.ts b/apps/remix-ide-e2e/src/tests/url.test.ts index df5b772638..b104ddf42e 100644 --- a/apps/remix-ide-e2e/src/tests/url.test.ts +++ b/apps/remix-ide-e2e/src/tests/url.test.ts @@ -108,14 +108,14 @@ module.exports = { 'Should load json files from link passed in remix URL': function (browser: NightwatchBrowser) { browser - .url('http://localhost:8080/#optimize=false&runs=200&evmVersion=null&version=soljson-v0.6.12+commit.27d51765.js&url=https://raw.githubusercontent.com/EthVM/evm-source-verification/main/contracts/1/0x011e5846975c6463a8c6337eecf3cbf64e328884/input.json') + .url('http://127.0.0.1:8080/#optimize=false&runs=200&evmVersion=null&version=soljson-v0.6.12+commit.27d51765.js&url=https://raw.githubusercontent.com/EthVM/evm-source-verification/main/contracts/1/0x011e5846975c6463a8c6337eecf3cbf64e328884/input.json') .refresh() .pause(5000) .waitForElementPresent('*[data-id="workspacesSelect"] option[value="code-sample"]') .openFile('@openzeppelin') .openFile('@openzeppelin/contracts') .openFile('@openzeppelin/contracts/access') - .openFile('@openzeppelin/contracts/access/AccessCdsfdsfdsfsdontrol.sol') + .openFile('@openzeppelin/contracts/access/AccessControl.sol') .openFile('contracts') .openFile('contracts/governance') .openFile('contracts/governance/UnionGovernor.sol') diff --git a/apps/remix-ide/ci/browser_test.sh b/apps/remix-ide/ci/browser_test.sh index 00a4158c86..745dd87b04 100755 --- a/apps/remix-ide/ci/browser_test.sh +++ b/apps/remix-ide/ci/browser_test.sh @@ -15,7 +15,7 @@ sleep 5 npm run build:e2e -TESTFILES=$(grep -IRiL "disabled" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test" | sort | circleci tests split ) +TESTFILES=$(grep -IRiL "@disabled: true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test" | sort | circleci tests split ) for TESTFILE in $TESTFILES; do npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js $TESTFILE --env=$1 || TEST_EXITCODE=1 done diff --git a/apps/remix-ide/ci/browser_tests_plugin_api.sh b/apps/remix-ide/ci/browser_tests_plugin_api.sh index 282b979c98..426e16a6a5 100755 --- a/apps/remix-ide/ci/browser_tests_plugin_api.sh +++ b/apps/remix-ide/ci/browser_tests_plugin_api.sh @@ -14,7 +14,7 @@ sleep 5 npm run build:e2e -TESTFILES=$(grep -IRiL "disabled" "dist/apps/remix-ide-e2e/src/tests" | grep "plugin_api" | sort | circleci tests split ) +TESTFILES=$(grep -IRiL "@disabled: true" "dist/apps/remix-ide-e2e/src/tests" | grep "plugin_api" | sort | circleci tests split ) for TESTFILE in $TESTFILES; do npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js $TESTFILE --env=chrome || TEST_EXITCODE=1 done From 466dd3713618ca208f121c59d36be2d73c00120a Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 15 Mar 2022 10:59:18 +0100 Subject: [PATCH 05/16] fix test name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8672f3fc26..506f4e4b94 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "nightwatch_local_verticalIconscontextmenu": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/verticalIconsPanel.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_*.js --env=chrome", "nightwatch_local_migrate_filesystem": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.js --env=chrome", - "nightwatch_local_stress_editor": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/stress.editor.js --env=chromeDesktop", + "nightwatch_local_stress_editor": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/stressEditor.test.js --env=chromeDesktop", "nightwatch_local_search": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/search.test.js --env=chromeDesktop", "onchange": "onchange apps/remix-ide/build/app.js -- npm-run-all lint", "remixd": "nx build remixd && chmod +x dist/libs/remixd/src/bin/remixd.js && dist/libs/remixd/src/bin/remixd.js -s ./apps/remix-ide/contracts --remix-ide http://127.0.0.1:8080", From c0890abe8ba286a883e578ca401fa536eacc76a5 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 15 Mar 2022 10:59:32 +0100 Subject: [PATCH 06/16] don't set default --- apps/remix-ide-e2e/nightwatch.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/apps/remix-ide-e2e/nightwatch.ts b/apps/remix-ide-e2e/nightwatch.ts index d8a111a617..7ca74fd2a7 100644 --- a/apps/remix-ide-e2e/nightwatch.ts +++ b/apps/remix-ide-e2e/nightwatch.ts @@ -20,15 +20,7 @@ module.exports = { on_failure: true, on_error: true }, - desiredCapabilities: { - browserName: 'firefox', - javascriptEnabled: true, - acceptSslCerts: true, - 'moz:firefoxOptions': { - args: ['-headless'] - } - }, - exclude: ['dist/apps/remix-ide-e2e/src/tests/runAndDeploy.js', 'dist/apps/remix-ide-e2e/src/tests/pluginManager.spec.ts'] + exclude: ['dist/apps/remix-ide-e2e/src/tests/runAndDeploy.test.js', 'dist/apps/remix-ide-e2e/src/tests/pluginManager.test.ts'] }, chrome: { From bfbf5688b338b04dc834729f1aad9abb73810e9b Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 15 Mar 2022 10:59:42 +0100 Subject: [PATCH 07/16] fix stress test --- .../src/tests/stressEditor.test.ts | 174 ++++++++++++++++-- 1 file changed, 161 insertions(+), 13 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/stressEditor.test.ts b/apps/remix-ide-e2e/src/tests/stressEditor.test.ts index ddb007b12a..43561b5f1e 100644 --- a/apps/remix-ide-e2e/src/tests/stressEditor.test.ts +++ b/apps/remix-ide-e2e/src/tests/stressEditor.test.ts @@ -11,31 +11,179 @@ module.exports = { 'Should create 10 files, reload, and check if the files are saved': function (browser: NightwatchBrowser) { const contents = {} - const checkContent = function (i, done) { + const checkContent = (i, done) => { const name = 'test_' + i + '.sol' browser .openFile(name) .pause(500) .getEditorValue((content) => { + browser.assert.ok(content === contents[i]) browser.assert.ok(content === contents[i]) done() }) } - browser.clickLaunchIcon('filePanel').perform((done) => { - let contentEditSet = content.slice() - for (let i = 0; i < 10; i++) { - contentEditSet += contentEditSet - contents[i] = contentEditSet + const fillContent = (content, mul) => { + let localContent = content + mul = 3 * mul + for (let k = 0 ; k < mul; k++) { + localContent += content + } + return localContent + } + browser.clickLaunchIcon('filePanel') + .perform((done) => { + const i = 0 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 1 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 2 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 3 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 4 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 5 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 6 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 7 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 8 + const localContent = fillContent(content, i) + contents[i] = localContent + const name = 'test_' + i + '.sol' + browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) + done() + }).perform((done) => { + const i = 9 + const localContent = fillContent(content, i) + contents[i] = localContent const name = 'test_' + i + '.sol' browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') - .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) - .sendKeys('*[data-id$="/blank"] .remixui_items', name) - .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) - .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) - .setEditorValue(contentEditSet) - } + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', name) + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .getText('.remix_ui_terminal_block', (result) => { + console.log(result) + }) + .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) + .setEditorValue(localContent) done() - }).pause(10000).refresh() + }) + .pause(10000) + .refresh() .perform(done => checkContent(0, done)) .perform(done => checkContent(1, done)) .perform(done => checkContent(2, done)) From 828fea68932ee22c264bc132261a4e19c646052e Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 15 Mar 2022 16:53:08 +0100 Subject: [PATCH 08/16] fix tests --- apps/remix-ide-e2e/src/commands/openFile.ts | 2 +- apps/remix-ide-e2e/src/tests/url.test.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/openFile.ts b/apps/remix-ide-e2e/src/commands/openFile.ts index d1cf4aa0e4..baf0a89ea2 100644 --- a/apps/remix-ide-e2e/src/commands/openFile.ts +++ b/apps/remix-ide-e2e/src/commands/openFile.ts @@ -15,7 +15,7 @@ class OpenFile extends EventEmitter { // click on fileExplorer can toggle it. We go through settings to be sure FE is open function openFile (browser: NightwatchBrowser, name: string, done: VoidFunction) { - browser.clickLaunchIcon('settings').clickLaunchIcon('filePanel') + browser.clickLaunchIcon('settings').pause(500).clickLaunchIcon('filePanel') .waitForElementVisible('li[data-id="treeViewLitreeViewItem' + name + '"', 60000) .click('li[data-id="treeViewLitreeViewItem' + name + '"') .pause(2000) diff --git a/apps/remix-ide-e2e/src/tests/url.test.ts b/apps/remix-ide-e2e/src/tests/url.test.ts index b104ddf42e..e6233ae2e7 100644 --- a/apps/remix-ide-e2e/src/tests/url.test.ts +++ b/apps/remix-ide-e2e/src/tests/url.test.ts @@ -31,7 +31,7 @@ module.exports = { .assert.containsText('*[data-id="compilerContainerCompileBtn"]', 'contract-76747f6e19.sol') .currentWorkspaceIs('code-sample') .getEditorValue((content) => { - browser.assert.ok(content.indexOf( + browser.assert.ok(content && content.indexOf( 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol') !== -1, 'code has not been loaded') }) @@ -45,7 +45,7 @@ module.exports = { .pause(5000) .currentWorkspaceIs('code-sample') .getEditorValue((content) => { - browser.assert.ok(content.indexOf( + browser.assert.ok(content && content.indexOf( 'proposals.length = _numProposals;') !== -1, 'url has not been loaded') }) @@ -59,7 +59,7 @@ module.exports = { .pause(5000) .currentWorkspaceIs('code-sample') .getEditorValue((content) => { - browser.assert.ok(content.indexOf( + browser.assert.ok(content && content.indexOf( 'proposals.length = _numProposals;') !== -1, 'code has not been loaded') }) From c72b1e7b8a5b808e82be8982a83bee89c58db581 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 15 Mar 2022 18:03:10 +0100 Subject: [PATCH 09/16] add await to set --- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 681f678332..14ce0ec355 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -92,7 +92,7 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp path = 'contract-' + hash.replace('0x', '').substring(0, 10) + '.sol' content = atob(params.code) - workspaceProvider.set(path, content) + await workspaceProvider.set(path, content) } if (params.url) { const data = await plugin.call('contentImport', 'resolve', params.url) @@ -109,11 +109,11 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp } return Object.keys(standardInput.sources)[0] } else { - workspaceProvider.set(path, JSON.stringify(content)) + await workspaceProvider.set(path, JSON.stringify(content)) } } catch (e) { console.log(e) - workspaceProvider.set(path, content) + await workspaceProvider.set(path, content) } } return path From 9723654cee6e7d1962d5b9b13163d4c3daca4d42 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 16 Mar 2022 10:02:11 +0100 Subject: [PATCH 10/16] remove uneeded clickLaunchIcon --- apps/remix-ide-e2e/src/commands/openFile.ts | 9 ++++++++- apps/remix-ide-e2e/src/tests/stressEditor.test.ts | 1 - .../vertical-icons-panel/src/lib/components/Icon.tsx | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/openFile.ts b/apps/remix-ide-e2e/src/commands/openFile.ts index baf0a89ea2..28d09a009d 100644 --- a/apps/remix-ide-e2e/src/commands/openFile.ts +++ b/apps/remix-ide-e2e/src/commands/openFile.ts @@ -15,7 +15,14 @@ class OpenFile extends EventEmitter { // click on fileExplorer can toggle it. We go through settings to be sure FE is open function openFile (browser: NightwatchBrowser, name: string, done: VoidFunction) { - browser.clickLaunchIcon('settings').pause(500).clickLaunchIcon('filePanel') + browser.perform((done) => { + browser.element('css selector', '[data-id="verticalIconsKindfilePanel"] img[data-id="selected"]', (result) => { + console.log(result) + if (result.status === 0) { + browser.clickLaunchIcon('filePanel').perform(done) + } else done() + }) + }) .waitForElementVisible('li[data-id="treeViewLitreeViewItem' + name + '"', 60000) .click('li[data-id="treeViewLitreeViewItem' + name + '"') .pause(2000) diff --git a/apps/remix-ide-e2e/src/tests/stressEditor.test.ts b/apps/remix-ide-e2e/src/tests/stressEditor.test.ts index 43561b5f1e..ed0382bcb7 100644 --- a/apps/remix-ide-e2e/src/tests/stressEditor.test.ts +++ b/apps/remix-ide-e2e/src/tests/stressEditor.test.ts @@ -15,7 +15,6 @@ module.exports = { const name = 'test_' + i + '.sol' browser .openFile(name) - .pause(500) .getEditorValue((content) => { browser.assert.ok(content === contents[i]) browser.assert.ok(content === contents[i]) diff --git a/libs/remix-ui/vertical-icons-panel/src/lib/components/Icon.tsx b/libs/remix-ui/vertical-icons-panel/src/lib/components/Icon.tsx index a0aa750e73..95764db278 100644 --- a/libs/remix-ui/vertical-icons-panel/src/lib/components/Icon.tsx +++ b/libs/remix-ui/vertical-icons-panel/src/lib/components/Icon.tsx @@ -100,7 +100,7 @@ const Icon = ({ id={`verticalIconsKind${name}`} ref={iconRef} > - {name} + {name} From e0d4ded3f391cb66491295ed3e984078ee42bca0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 16 Mar 2022 10:53:46 +0100 Subject: [PATCH 11/16] fix disabled --- apps/remix-ide-e2e/src/checkGroupTests.js | 2 +- apps/remix-ide-e2e/src/select_tests.sh | 2 +- apps/remix-ide/ci/browser_test.sh | 2 +- apps/remix-ide/ci/browser_tests_plugin_api.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide-e2e/src/checkGroupTests.js b/apps/remix-ide-e2e/src/checkGroupTests.js index bc833723a1..bb26940d1d 100644 --- a/apps/remix-ide-e2e/src/checkGroupTests.js +++ b/apps/remix-ide-e2e/src/checkGroupTests.js @@ -6,7 +6,7 @@ fs.readdirSync(testFolder).forEach(file => { const content = fs.readFileSync(testFolder + file, 'utf8') const matches = content.match(/group\d+/g) if (matches) { - const disabled = content.includes('@disabled: true') + const disabled = content.includes('\'@disabled\': true') || content.includes('\'@disabled\':true') if (!disabled) { console.log(`WARNING ${file} has group tests but is not disabled`) } diff --git a/apps/remix-ide-e2e/src/select_tests.sh b/apps/remix-ide-e2e/src/select_tests.sh index 05fa3ce3c8..65fa5c1656 100644 --- a/apps/remix-ide-e2e/src/select_tests.sh +++ b/apps/remix-ide-e2e/src/select_tests.sh @@ -26,7 +26,7 @@ do done npm run build:e2e PS3='Select a test or command: ' -TESTFILES=( $(grep -IRiL "@disabled: true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test\|plugin_api" | sort ) ) +TESTFILES=( $(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test\|plugin_api" | sort ) ) # declare -p TESTFILES TESTFILES+=("list") diff --git a/apps/remix-ide/ci/browser_test.sh b/apps/remix-ide/ci/browser_test.sh index 745dd87b04..f9385198b5 100755 --- a/apps/remix-ide/ci/browser_test.sh +++ b/apps/remix-ide/ci/browser_test.sh @@ -15,7 +15,7 @@ sleep 5 npm run build:e2e -TESTFILES=$(grep -IRiL "@disabled: true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test" | sort | circleci tests split ) +TESTFILES=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test" | sort | circleci tests split ) for TESTFILE in $TESTFILES; do npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js $TESTFILE --env=$1 || TEST_EXITCODE=1 done diff --git a/apps/remix-ide/ci/browser_tests_plugin_api.sh b/apps/remix-ide/ci/browser_tests_plugin_api.sh index 426e16a6a5..ab94f74a31 100755 --- a/apps/remix-ide/ci/browser_tests_plugin_api.sh +++ b/apps/remix-ide/ci/browser_tests_plugin_api.sh @@ -14,7 +14,7 @@ sleep 5 npm run build:e2e -TESTFILES=$(grep -IRiL "@disabled: true" "dist/apps/remix-ide-e2e/src/tests" | grep "plugin_api" | sort | circleci tests split ) +TESTFILES=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "plugin_api" | sort | circleci tests split ) for TESTFILE in $TESTFILES; do npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js $TESTFILE --env=chrome || TEST_EXITCODE=1 done From c18d33c6a40a6e9fba6534b678a38334b6a95fcb Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 16 Mar 2022 11:25:04 +0100 Subject: [PATCH 12/16] fix e2e --- apps/remix-ide-e2e/src/commands/openFile.ts | 30 ++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/openFile.ts b/apps/remix-ide-e2e/src/commands/openFile.ts index 28d09a009d..fa674e22a9 100644 --- a/apps/remix-ide-e2e/src/commands/openFile.ts +++ b/apps/remix-ide-e2e/src/commands/openFile.ts @@ -16,19 +16,25 @@ class OpenFile extends EventEmitter { // click on fileExplorer can toggle it. We go through settings to be sure FE is open function openFile (browser: NightwatchBrowser, name: string, done: VoidFunction) { browser.perform((done) => { - browser.element('css selector', '[data-id="verticalIconsKindfilePanel"] img[data-id="selected"]', (result) => { - console.log(result) - if (result.status === 0) { - browser.clickLaunchIcon('filePanel').perform(done) - } else done() + browser.isVisible('[data-id="remixIdeSidePanel"]', (result) => { + console.log(result) + if (result.value) { + // if side panel is shown, check this is the file panel + browser.element('css selector', '[data-id="verticalIconsKindfilePanel"] img[data-id="selected"]', (result) => { + console.log(result) + if (result.status === 0) { + done() + } else browser.clickLaunchIcon('filePanel').perform(done) }) - }) - .waitForElementVisible('li[data-id="treeViewLitreeViewItem' + name + '"', 60000) - .click('li[data-id="treeViewLitreeViewItem' + name + '"') - .pause(2000) - .perform(() => { - done() - }) + } else browser.clickLaunchIcon('filePanel').perform(done) + }) + }) + .waitForElementVisible('li[data-id="treeViewLitreeViewItem' + name + '"', 60000) + .click('li[data-id="treeViewLitreeViewItem' + name + '"') + .pause(2000) + .perform(() => { + done() + }) } module.exports = OpenFile From 12280f614f405ce4a04e2416ee761b3d5bcc4f45 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 16 Mar 2022 12:26:18 +0100 Subject: [PATCH 13/16] remove console --- apps/remix-ide-e2e/src/commands/openFile.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/openFile.ts b/apps/remix-ide-e2e/src/commands/openFile.ts index fa674e22a9..f8191e874f 100644 --- a/apps/remix-ide-e2e/src/commands/openFile.ts +++ b/apps/remix-ide-e2e/src/commands/openFile.ts @@ -17,11 +17,9 @@ class OpenFile extends EventEmitter { function openFile (browser: NightwatchBrowser, name: string, done: VoidFunction) { browser.perform((done) => { browser.isVisible('[data-id="remixIdeSidePanel"]', (result) => { - console.log(result) if (result.value) { // if side panel is shown, check this is the file panel browser.element('css selector', '[data-id="verticalIconsKindfilePanel"] img[data-id="selected"]', (result) => { - console.log(result) if (result.status === 0) { done() } else browser.clickLaunchIcon('filePanel').perform(done) From 5f2bc31d2cec22f62981fd0444e2339fdf7cfe44 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 16 Mar 2022 11:28:59 +0100 Subject: [PATCH 14/16] Prevent paste in within ancestor folder --- apps/remix-ide/src/app/files/fileManager.ts | 8 +++++++- apps/remix-ide/src/app/files/remixDProvider.js | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 2ad2ea4aa9..da8f97c8b0 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -272,7 +272,13 @@ class FileManager extends Plugin { await this._handleIsDir(src, `Cannot copy from ${src}. Path is not a directory.`) await this._handleExists(dest, `Cannot paste content into ${dest}. Path does not exist.`) await this._handleIsDir(dest, `Cannot paste content into ${dest}. Path is not directory.`) - await this.inDepthCopy(src, dest) + + const provider = this.fileProviderOf(src) + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', 'File(s) to paste is an ancestor of the destination folder') + } else { + await this.inDepthCopy(src, dest) + } } catch (e) { throw new Error(e) } diff --git a/apps/remix-ide/src/app/files/remixDProvider.js b/apps/remix-ide/src/app/files/remixDProvider.js index c52055e04f..27e4534263 100644 --- a/apps/remix-ide/src/app/files/remixDProvider.js +++ b/apps/remix-ide/src/app/files/remixDProvider.js @@ -1,5 +1,6 @@ 'use strict' const FileProvider = require('./fileProvider') +const pathModule = require('path') module.exports = class RemixDProvider extends FileProvider { constructor (appManager) { @@ -207,4 +208,12 @@ module.exports = class RemixDProvider extends FileProvider { if (!this._isReady) throw new Error('provider not ready') return await this._appManager.call('remixd', 'isFile', { path: unprefixedpath }) } + + isSubDirectory (parent, child) { + if (!parent) return false + if (parent === child) return true + const relative = pathModule.relative(parent, child) + + return !!relative && relative.split(pathModule.sep)[0] !== '..' + } } From 72c16efa064f2f204983c26c37f56c39d84a6313 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 16 Mar 2022 12:04:21 +0100 Subject: [PATCH 15/16] Remove duplicate tab --- apps/remix-ide/src/app/panels/tab-proxy.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index c3a897b7d6..bc8a7c4c8f 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -190,15 +190,6 @@ export class TabProxy extends Plugin { } renameTab (oldName, newName) { - this.addTab(newName, '', async () => { - await this.fileManager.open(newName) - this.event.emit('openFile', newName) - }, - async () => { - await this.fileManager.closeFile(newName) - this.event.emit('closeFile', newName) - this.emit('closeFile', newName) - }) this.removeTab(oldName) } From 89d35a20238f691b200d02c69f7e27a76f61cae0 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 16 Mar 2022 15:23:39 +0100 Subject: [PATCH 16/16] Move isSubDirectory function to fileProvider class. --- apps/remix-ide/src/app/files/fileProvider.js | 9 +++++++++ apps/remix-ide/src/app/files/remixDProvider.js | 9 --------- apps/remix-ide/src/app/files/workspaceFileProvider.js | 8 -------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index 2176bc53b8..61e751ee62 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -3,6 +3,7 @@ import { CompilerImports } from '@remix-project/core-plugin' const EventManager = require('events') const remixLib = require('@remix-project/remix-lib') +const pathModule = require('path') const Storage = remixLib.Storage class FileProvider { @@ -308,6 +309,14 @@ class FileProvider { _normalizePath (path) { return this.type + path } + + isSubDirectory (parent, child) { + if (!parent) return false + if (parent === child) return true + const relative = pathModule.relative(parent, child) + + return !!relative && relative.split(pathModule.sep)[0] !== '..' + } } module.exports = FileProvider diff --git a/apps/remix-ide/src/app/files/remixDProvider.js b/apps/remix-ide/src/app/files/remixDProvider.js index 27e4534263..c52055e04f 100644 --- a/apps/remix-ide/src/app/files/remixDProvider.js +++ b/apps/remix-ide/src/app/files/remixDProvider.js @@ -1,6 +1,5 @@ 'use strict' const FileProvider = require('./fileProvider') -const pathModule = require('path') module.exports = class RemixDProvider extends FileProvider { constructor (appManager) { @@ -208,12 +207,4 @@ module.exports = class RemixDProvider extends FileProvider { if (!this._isReady) throw new Error('provider not ready') return await this._appManager.call('remixd', 'isFile', { path: unprefixedpath }) } - - isSubDirectory (parent, child) { - if (!parent) return false - if (parent === child) return true - const relative = pathModule.relative(parent, child) - - return !!relative && relative.split(pathModule.sep)[0] !== '..' - } } diff --git a/apps/remix-ide/src/app/files/workspaceFileProvider.js b/apps/remix-ide/src/app/files/workspaceFileProvider.js index 505be72b8c..3fcd635fcf 100644 --- a/apps/remix-ide/src/app/files/workspaceFileProvider.js +++ b/apps/remix-ide/src/app/files/workspaceFileProvider.js @@ -49,14 +49,6 @@ class WorkspaceFileProvider extends FileProvider { return ret } - isSubDirectory (parent, child) { - if (!parent) return false - if (parent === child) return true - const relative = pathModule.relative(parent, child) - - return !!relative && relative.split(pathModule.sep)[0] !== '..' - } - resolveDirectory (path, callback) { super.resolveDirectory(path, (error, files) => { if (error) return callback(error)