Fixed failing url and workspace test

pull/1575/head
ioedeveloper 3 years ago
parent 036afc3172
commit c4292c9a64
  1. 5
      apps/remix-ide-e2e/src/tests/workspace.test.ts
  2. 2
      apps/remix-ide/src/app/panels/file-panel.js
  3. 2
      apps/remix-ide/src/app/tabs/compile-tab.js
  4. 6
      libs/remix-ui/workspace/src/lib/actions/index.ts
  5. 11
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -49,9 +49,8 @@ module.exports = {
.waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] > span')
// eslint-disable-next-line dot-notation
.execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_name_1' })
.waitForElementVisible('[data-id="fileSystem-modal-footer-ok-react"]')
.click('[data-id="fileSystemModalDialogModalFooter-react"]') // focus on footer to ensure ok click
.click('[data-id="fileSystem-modal-footer-ok-react"]')
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok')
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() })
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtests"]')
.pause(2000)
.waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.sol"]')

@ -58,7 +58,7 @@ module.exports = class Filepanel extends ViewPlugin {
}
onActivation () {
this.renderComponent()
this.on('editor', 'editorMounted', () => this.renderComponent())
}
render () {

@ -115,6 +115,7 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
async onActivation () {
super.onActivation()
this.on('filePanel', 'workspaceInitializationCompleted', () => {
this.call('filePanel', 'registerContextMenuItem', {
id: 'solidity',
name: 'compileFile',
@ -124,6 +125,7 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
path: [],
pattern: []
})
})
try {
this.currentFile = await this.call('fileManager', 'file')
} catch (error) {

@ -27,20 +27,20 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
dispatch(setWorkspaces(workspaces))
if (params.gist) {
await createWorkspaceTemplate('gist-sample', 'gist-template')
await loadWorkspacePreset('gist-template')
plugin.setWorkspace({ name: 'gist-sample', isLocalhost: false })
dispatch(setCurrentWorkspace('gist-sample'))
await loadWorkspacePreset('gist-template')
} else if (params.code || params.url) {
await createWorkspaceTemplate('code-sample', 'code-template')
await loadWorkspacePreset('code-template')
plugin.setWorkspace({ name: 'code-sample', isLocalhost: false })
dispatch(setCurrentWorkspace('code-sample'))
await loadWorkspacePreset('code-template')
} else {
if (workspaces.length === 0) {
await createWorkspaceTemplate('default_workspace', 'default-template')
await loadWorkspacePreset('default-template')
plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false })
dispatch(setCurrentWorkspace('default_workspace'))
await loadWorkspacePreset('default-template')
} else {
if (workspaces.length > 0) {
workspaceProvider.setWorkspace(workspaces[workspaces.length - 1])

@ -84,16 +84,21 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp
path = 'contract-' + hash.replace('0x', '').substring(0, 10) + '.sol'
content = atob(params.code)
await workspaceProvider.set(path, content)
workspaceProvider.set(path, content, async (error) => {
if (error) throw new Error(error)
await plugin.fileManager.openFile(path)
})
}
if (params.url) {
const data = await plugin.call('contentImport', 'resolve', params.url)
path = data.cleanUrl
content = data.content
await workspaceProvider.set(path, content)
}
workspaceProvider.set(path, content, async (error) => {
if (error) throw new Error(error)
await plugin.fileManager.openFile(path)
})
}
} catch (e) {
console.error(e)
}

Loading…
Cancel
Save