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. 18
      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') .waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] > span')
// eslint-disable-next-line dot-notation // eslint-disable-next-line dot-notation
.execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_name_1' }) .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_name_1' })
.waitForElementVisible('[data-id="fileSystem-modal-footer-ok-react"]') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok')
.click('[data-id="fileSystemModalDialogModalFooter-react"]') // focus on footer to ensure ok click .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() })
.click('[data-id="fileSystem-modal-footer-ok-react"]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtests"]') .waitForElementVisible('*[data-id="treeViewLitreeViewItemtests"]')
.pause(2000) .pause(2000)
.waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.sol"]') .waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.sol"]')

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

@ -115,14 +115,16 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
async onActivation () { async onActivation () {
super.onActivation() super.onActivation()
this.call('filePanel', 'registerContextMenuItem', { this.on('filePanel', 'workspaceInitializationCompleted', () => {
id: 'solidity', this.call('filePanel', 'registerContextMenuItem', {
name: 'compileFile', id: 'solidity',
label: 'Compile', name: 'compileFile',
type: [], label: 'Compile',
extension: ['.sol'], type: [],
path: [], extension: ['.sol'],
pattern: [] path: [],
pattern: []
})
}) })
try { try {
this.currentFile = await this.call('fileManager', 'file') this.currentFile = await this.call('fileManager', 'file')

@ -27,20 +27,20 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
dispatch(setWorkspaces(workspaces)) dispatch(setWorkspaces(workspaces))
if (params.gist) { if (params.gist) {
await createWorkspaceTemplate('gist-sample', 'gist-template') await createWorkspaceTemplate('gist-sample', 'gist-template')
await loadWorkspacePreset('gist-template')
plugin.setWorkspace({ name: 'gist-sample', isLocalhost: false }) plugin.setWorkspace({ name: 'gist-sample', isLocalhost: false })
dispatch(setCurrentWorkspace('gist-sample')) dispatch(setCurrentWorkspace('gist-sample'))
await loadWorkspacePreset('gist-template')
} else if (params.code || params.url) { } else if (params.code || params.url) {
await createWorkspaceTemplate('code-sample', 'code-template') await createWorkspaceTemplate('code-sample', 'code-template')
await loadWorkspacePreset('code-template')
plugin.setWorkspace({ name: 'code-sample', isLocalhost: false }) plugin.setWorkspace({ name: 'code-sample', isLocalhost: false })
dispatch(setCurrentWorkspace('code-sample')) dispatch(setCurrentWorkspace('code-sample'))
await loadWorkspacePreset('code-template')
} else { } else {
if (workspaces.length === 0) { if (workspaces.length === 0) {
await createWorkspaceTemplate('default_workspace', 'default-template') await createWorkspaceTemplate('default_workspace', 'default-template')
await loadWorkspacePreset('default-template')
plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false }) plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false })
dispatch(setCurrentWorkspace('default_workspace')) dispatch(setCurrentWorkspace('default_workspace'))
await loadWorkspacePreset('default-template')
} else { } else {
if (workspaces.length > 0) { if (workspaces.length > 0) {
workspaceProvider.setWorkspace(workspaces[workspaces.length - 1]) 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' path = 'contract-' + hash.replace('0x', '').substring(0, 10) + '.sol'
content = atob(params.code) 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) { if (params.url) {
const data = await plugin.call('contentImport', 'resolve', params.url) const data = await plugin.call('contentImport', 'resolve', params.url)
path = data.cleanUrl path = data.cleanUrl
content = data.content 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)
})
} }
await plugin.fileManager.openFile(path)
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} }

Loading…
Cancel
Save