fix creating workspace from gist load

pull/4550/head
yann300 9 months ago
parent 6748281240
commit cfe278d362
  1. 5
      apps/remix-ide-e2e/src/tests/gist.test.ts
  2. 10
      libs/remix-core-plugin/src/lib/gist-handler.ts

@ -143,8 +143,8 @@ module.exports = {
.modalFooterOKClick('gisthandler') .modalFooterOKClick('gisthandler')
.pause(10000) .pause(10000)
.openFile(`README.txt`) .openFile(`README.txt`)
.waitForElementVisible(`div[data-path='default_workspace/README.txt']`) .waitForElementVisible(`div[data-path='gist ${testData.validGistId}/README.txt']`)
.assert.containsText(`div[data-path='default_workspace/README.txt'] > span`, 'README.txt') .assert.containsText(`div[data-path='gist ${testData.validGistId}/README.txt'] > span`, 'README.txt')
}, },
'Load Gist from URL and verify truncated files are loaded #group3': function (browser: NightwatchBrowser) { 'Load Gist from URL and verify truncated files are loaded #group3': function (browser: NightwatchBrowser) {
@ -152,6 +152,7 @@ module.exports = {
browser browser
.url('http://127.0.0.1:8080/#gist=' + gistId) // loading the gist .url('http://127.0.0.1:8080/#gist=' + gistId) // loading the gist
.refreshPage() .refreshPage()
.currentWorkspaceIs('gist ' + gistId)
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000) .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000)
.waitForElementVisible(`#fileExplorerView li[data-path='contracts']`, 30000) .waitForElementVisible(`#fileExplorerView li[data-path='contracts']`, 30000)
.openFile(`contracts/2_Owner.sol`) .openFile(`contracts/2_Owner.sol`)

@ -114,6 +114,16 @@ export class GistHandler extends Plugin {
return return
} }
const gistIdWorkspace = 'gist ' + gistId
const workspaces = await this.call('filePanel', 'getWorkspaces')
const found = workspaces.find((workspace) => workspace.name === gistIdWorkspace)
if (found) {
await this.call('notification', 'alert', `workspace "${gistIdWorkspace}" already exist`)
return
}
await this.call('filePanel', 'createWorkspace', 'gist ' + gistId, '', true)
await this.call('filePanel', 'switchToWorkspace', { name: 'gist ' + gistId, isLocalHost: false })
const obj: StringByString = {} const obj: StringByString = {}
Object.keys(data.files).forEach((element) => { Object.keys(data.files).forEach((element) => {
const path = element.replace(/\.\.\./g, '/') const path = element.replace(/\.\.\./g, '/')

Loading…
Cancel
Save