From fa6224d80ac062571022204b4f0e51377376b240 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 25 Jan 2024 12:51:13 +0100 Subject: [PATCH] fix saving the gist --- apps/remix-ide-e2e/src/tests/gist.test.ts | 7 ++++++- libs/remix-ui/workspace/src/lib/actions/index.ts | 5 ++++- 2 files changed, 10 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 2cbefb4d0c..97d21c8e37 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/#gist=' + gistId) + .url('http://127.0.0.1:8080/#gist=' + gistId) // loading the gist .refreshPage() .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) .waitForElementVisible(`#fileExplorerView li[data-path='gist-${gistId}/README.txt']`, 30000) @@ -158,5 +158,10 @@ module.exports = { .getEditorValue((content) => { browser.assert.ok(content !== '') }) + .rightClickCustom(`li[data-path='gist-${gistId}'] div`) // saving the gist + .click('[data-id="contextMenuItempublishFolderToGist"]') + .modalFooterOKClick('fileSystem') + .waitForElementVisible('*[data-shared="tooltipPopup"]', 5000) + .assert.containsText('*[data-shared="tooltipPopup"]', 'Saving gist (' + gistId + ') ...') } } diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 5bdd0df427..d0ec393c2b 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -226,8 +226,11 @@ export type SolidityConfiguration = { export const publishToGist = async (path?: string, type?: string) => { // If 'id' is not defined, it is not a gist update but a creation so we have to take the files from the browser explorer. const folder = path || '/' - const id = type === 'gist' ? extractNameFromKey(path).split('-')[1] : null + try { + const name = extractNameFromKey(path) + const id = name && name.startsWith('gist-') ? name.split('-')[1] : null + const packaged = await packageGistFiles(folder) // check for token const config = plugin.registry.get('config').api