From 22d268a274c5cafe4fe470ebb13e8b4569ac3447 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 12:24:07 +0100 Subject: [PATCH 01/13] handle truncated files --- .../workspace/src/lib/actions/workspace.ts | 17 ++++++++++++++--- 1 file changed, 14 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 3a932a8f9d..8503eec8ba 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -308,11 +308,22 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe } const obj = {} - Object.keys(data.files).forEach((element) => { + for (const [element] of Object.entries(data.files)) { const path = element.replace(/\.\.\./g, '/') + let value + if (data.files[element].truncated) { + const response: AxiosResponse = await axios.get(data.files[element].raw_url) + value = { content: response.data } + console.log(data.files[element], response) + } else { + value = { content: data.files[element].content } + } - obj['/' + 'gist-' + gistId + '/' + path] = data.files[element] - }) + if (data.files[element].type === 'application/json') { + obj['/' + 'gist-' + gistId + '/' + path] = { content: JSON.stringify(value.content, null, '\t') } + } else + obj['/' + 'gist-' + gistId + '/' + path] = value + } plugin.fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => { if (errorLoadingFile) { dispatch(displayNotification('', errorLoadingFile.message || errorLoadingFile, 'OK', null, () => {}, null)) From ca0de421ac774511e964c871a14574239e5571e9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 12:24:44 +0100 Subject: [PATCH 02/13] focus on md preview --- libs/remix-ui/workspace/src/lib/actions/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 1395ae06d4..5bdd0df427 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -402,6 +402,7 @@ export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'g if (type === 'file' && path.endsWith('.md')) { // just opening the preview await plugin.call('doc-viewer' as any, 'viewDocs', [path]) + plugin.call('tabs' as any, 'focus', 'doc-viewer') } else { await plugin.fileManager.open(path) dispatch(focusElement([{ key: path, type }])) From b8f8b6ea392fb17b8c12e8715c4f2553f6688aa2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 12:33:42 +0100 Subject: [PATCH 03/13] add test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index b495527eab..d10c62453e 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -145,6 +145,17 @@ module.exports = { .openFile(`gist-${testData.validGistId}/README.txt`) .waitForElementVisible(`div[data-path='default_workspace/gist-${testData.validGistId}/README.txt']`) .assert.containsText(`div[data-path='default_workspace/gist-${testData.validGistId}/README.txt'] > span`, 'README.txt') - .end() - } + }, + + 'Load Gist from URL and verify truncated files are loaded #group3': function (browser: NightwatchBrowser) { + const gistId = '1b179bf1b92c8b0664b4cbe61774e15d' + browser + .url('http://127.0.0.1:8080/#' + gistId) + .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) + .waitForElementVisible(`div[data-path='default_workspace/gist-${gistId}/README.txt']`) + .openFile(`gist-${gistId}/scripts/deploy_with_ethers.ts`) + .getEditorValue((content) => { + browser.assert.ok(content !== '') + }) + } } From cdfb6aa5951b9cf7ef598ba53571c89faf14de35 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 14:10:06 +0100 Subject: [PATCH 04/13] remove console.log --- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 8503eec8ba..c3187c745a 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -314,7 +314,6 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe if (data.files[element].truncated) { const response: AxiosResponse = await axios.get(data.files[element].raw_url) value = { content: response.data } - console.log(data.files[element], response) } else { value = { content: data.files[element].content } } From baea5fb30baca2e5ff41d4a3a0e52880b6fa6340 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 14:27:12 +0100 Subject: [PATCH 05/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index d10c62453e..af7e786759 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -150,8 +150,9 @@ module.exports = { 'Load Gist from URL and verify truncated files are loaded #group3': function (browser: NightwatchBrowser) { const gistId = '1b179bf1b92c8b0664b4cbe61774e15d' browser - .url('http://127.0.0.1:8080/#' + gistId) + .url('http://127.0.0.1:8080/#' + gistId) .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) + .clickLaunchIcon('filePanel') .waitForElementVisible(`div[data-path='default_workspace/gist-${gistId}/README.txt']`) .openFile(`gist-${gistId}/scripts/deploy_with_ethers.ts`) .getEditorValue((content) => { From 646243c51fc1fa4d711c167694995228c4924db0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 14:37:41 +0100 Subject: [PATCH 06/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index af7e786759..8106a3188c 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -150,7 +150,7 @@ module.exports = { 'Load Gist from URL and verify truncated files are loaded #group3': function (browser: NightwatchBrowser) { const gistId = '1b179bf1b92c8b0664b4cbe61774e15d' browser - .url('http://127.0.0.1:8080/#' + gistId) + .url('http://127.0.0.1:8080/#gistid=' + gistId) .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) .clickLaunchIcon('filePanel') .waitForElementVisible(`div[data-path='default_workspace/gist-${gistId}/README.txt']`) From d4049a81fdfbc16167dc55f10046dd50020dd340 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 15:04:00 +0100 Subject: [PATCH 07/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index 8106a3188c..c03a035ee3 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -150,7 +150,7 @@ module.exports = { 'Load Gist from URL and verify truncated files are loaded #group3': function (browser: NightwatchBrowser) { const gistId = '1b179bf1b92c8b0664b4cbe61774e15d' browser - .url('http://127.0.0.1:8080/#gistid=' + gistId) + .url('http://127.0.0.1:8080/#gist=' + gistId) .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) .clickLaunchIcon('filePanel') .waitForElementVisible(`div[data-path='default_workspace/gist-${gistId}/README.txt']`) From b4f3f413bb03957ed6a01af767d4abe92471fb9a Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 15:20:59 +0100 Subject: [PATCH 08/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index c03a035ee3..78eb9be299 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -150,7 +150,8 @@ module.exports = { 'Load Gist from URL and verify truncated files are loaded #group3': function (browser: NightwatchBrowser) { const gistId = '1b179bf1b92c8b0664b4cbe61774e15d' browser - .url('http://127.0.0.1:8080/#gist=' + gistId) + .url('http://127.0.0.1:8080/#gist=' + gistId) + .refreshPage() .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) .clickLaunchIcon('filePanel') .waitForElementVisible(`div[data-path='default_workspace/gist-${gistId}/README.txt']`) From f29b0c42be19c97078951ddf1e6e6e8b834485f0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 22:38:31 +0100 Subject: [PATCH 09/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index 78eb9be299..a5874b1572 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -153,7 +153,6 @@ module.exports = { .url('http://127.0.0.1:8080/#gist=' + gistId) .refreshPage() .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) - .clickLaunchIcon('filePanel') .waitForElementVisible(`div[data-path='default_workspace/gist-${gistId}/README.txt']`) .openFile(`gist-${gistId}/scripts/deploy_with_ethers.ts`) .getEditorValue((content) => { From cd247c783e3eb4470f44655921c8648abe6402fa Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Jan 2024 23:58:42 +0100 Subject: [PATCH 10/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index a5874b1572..6dd0b4b726 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -153,7 +153,7 @@ module.exports = { .url('http://127.0.0.1:8080/#gist=' + gistId) .refreshPage() .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) - .waitForElementVisible(`div[data-path='default_workspace/gist-${gistId}/README.txt']`) + .waitForElementVisible(`div[data-path='code_sample/gist-${gistId}/README.txt']`) .openFile(`gist-${gistId}/scripts/deploy_with_ethers.ts`) .getEditorValue((content) => { browser.assert.ok(content !== '') From 69a01700f0d65f6fb55452fe9b6dd49d551410b9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 25 Jan 2024 00:09:42 +0100 Subject: [PATCH 11/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index 6dd0b4b726..04a5a76ff6 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -153,7 +153,7 @@ module.exports = { .url('http://127.0.0.1:8080/#gist=' + gistId) .refreshPage() .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) - .waitForElementVisible(`div[data-path='code_sample/gist-${gistId}/README.txt']`) + .waitForElementVisible(`div[data-path='code-sample/gist-${gistId}/README.txt']`) .openFile(`gist-${gistId}/scripts/deploy_with_ethers.ts`) .getEditorValue((content) => { browser.assert.ok(content !== '') From 941ed34b04434ee30ef5237cf8c1cd0763047820 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 25 Jan 2024 10:06:46 +0100 Subject: [PATCH 12/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index 04a5a76ff6..97d7f6509f 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -153,7 +153,7 @@ module.exports = { .url('http://127.0.0.1:8080/#gist=' + gistId) .refreshPage() .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) - .waitForElementVisible(`div[data-path='code-sample/gist-${gistId}/README.txt']`) + .waitForElementVisible(`div[data-path='code-sample/gist-${gistId}/README.txt']`, 30000) .openFile(`gist-${gistId}/scripts/deploy_with_ethers.ts`) .getEditorValue((content) => { browser.assert.ok(content !== '') From 3ccee5ea8f149bf4324e0db58109f31b82c14166 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 25 Jan 2024 10:58:15 +0100 Subject: [PATCH 13/13] fix test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index 97d7f6509f..2cbefb4d0c 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -153,7 +153,7 @@ module.exports = { .url('http://127.0.0.1:8080/#gist=' + gistId) .refreshPage() .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) - .waitForElementVisible(`div[data-path='code-sample/gist-${gistId}/README.txt']`, 30000) + .waitForElementVisible(`#fileExplorerView li[data-path='gist-${gistId}/README.txt']`, 30000) .openFile(`gist-${gistId}/scripts/deploy_with_ethers.ts`) .getEditorValue((content) => { browser.assert.ok(content !== '')