fix terminal tests

pull/1647/head
bunsenstraat 3 years ago
parent af3fffd3ce
commit 875a79eb17
  1. 6
      apps/remix-ide-e2e/src/commands/addFile.ts
  2. 2
      apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
  3. 9
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  4. 7
      apps/remix-ide/src/app/files/fileManager.js
  5. 16
      apps/remix-ide/src/app/files/fileProvider.js
  6. 6
      apps/remix-ide/src/app/ui/landing-page/landing-page.js
  7. 4
      apps/remix-ide/src/remixAppManager.js
  8. 1
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx
  9. 3
      libs/remix-ui/workspace/src/lib/actions/events.ts
  10. 4
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  11. 15
      libs/remix-ui/workspace/src/lib/reducers/workspace.ts

@ -28,10 +28,10 @@ function addFile (browser: NightwatchBrowser, name: string, content: NightwatchC
.waitForElementContainsText('*[data-id$="/blank"]', '', 60000)
.sendKeys('*[data-id$="/blank"] .remixui_items', name)
.sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER)
.pause(2000)
// .pause(2000)
.waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000)
.setEditorValue(content.content)
.pause(1000)
.setEditorValue(content.content).pause(5000)
// .pause(1000)
.perform(function () {
done()
})

@ -21,7 +21,7 @@ import './app.css'
const client = new RemixPlugin()
function App () {
const [payload, setPayload] = useState<string>('')
const [payload, setPayload] = useState<string>('["one/two/three/four/file.js","content"]')
const [log, setLog] = useState<any>()
const [started, setStarted] = useState<boolean>(false)
const [events, setEvents] = useState<any>()

@ -4,7 +4,7 @@ import init from '../helpers/init'
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://localhost:8080?plugins=solidity,udapp', false)
init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false)
},
'Should execution a simple console command': function (browser: NightwatchBrowser) {
@ -34,7 +34,6 @@ module.exports = {
'Async/Await Script': function (browser: NightwatchBrowser) {
browser
.addFile('asyncAwait.js', { content: asyncAwait })
.openFile('asyncAwait.js')
.executeScript('remix.execute("asyncAwait.js")')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'Waiting Promise', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', 'result - ', 60000)
@ -44,8 +43,6 @@ module.exports = {
'Call Remix File Manager from a script': function (browser: NightwatchBrowser) {
browser
.addFile('asyncAwaitWithFileManagerAccess.js', { content: asyncAwaitWithFileManagerAccess })
.openFile('asyncAwaitWithFileManagerAccess.js')
.pause(5000)
.executeScript('remix.execute(\'asyncAwaitWithFileManagerAccess.js\')')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'contract Ballot {', 60000)
},
@ -109,12 +106,12 @@ module.exports = {
.clickLaunchIcon('filePanel')
.click('*[data-id="treeViewDivtreeViewItem"]') // make sure we create the file at the root folder
.addFile('deployWithEthersJs.js', { content: deployWithEthersJs })
.openFile('deployWithEthersJs.js')
// .openFile('deployWithEthersJs.js')
.pause(1000)
.click('[data-id="treeViewDivtreeViewItemcontracts"]')
.openFile('contracts/2_Owner.sol')
.clickLaunchIcon('solidity')
.click('*[data-id="compilerContainerCompileBtn"]') // compile Owner
.click('*[data-id="compilerContainerCompileBtn"]').pause(5000) // compile Owner
.executeScript('remix.execute(\'deployWithEthersJs.js\')')
.waitForElementContainsText('*[data-id="terminalJournal"]', 'Contract Address:', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', '0xd9145CCE52D386f254917e481eB44e9943F39138', 60000)

@ -331,8 +331,7 @@ class FileManager extends Plugin {
throw createError({ code: 'EEXIST', message: `Cannot create directory ${path}` })
}
const provider = this.fileProviderOf(path)
return provider.createDir(path)
return await provider.createDir(path)
} catch (e) {
throw new Error(e)
}
@ -621,9 +620,10 @@ class FileManager extends Plugin {
const provider = resolved.provider
this._deps.config.set('currentFile', file)
this.openedFiles[file] = file
await (() => {
return new Promise((resolve, reject) => {
provider.get(file, (error, content) => {
console.log('get file content', file, content)
if (error) {
console.log(error)
reject(error)
@ -640,7 +640,6 @@ class FileManager extends Plugin {
}
})
})
})()
}
}

@ -1,7 +1,6 @@
'use strict'
import { CompilerImports } from '@remix-project/core-plugin'
import { ConsoleLogs } from 'libs/remix-lib/src/helpers/hhconsoleSigs'
const EventManager = require('events')
const modalDialogCustom = require('../ui/modal-dialog-custom')
const tooltip = require('../ui/tooltip')
@ -109,7 +108,7 @@ class FileProvider {
return null
}
await this.createDir(path.substr(0, path.lastIndexOf('/')))
await this.createDir(path.substr(0, path.lastIndexOf('/')), async () => {
try {
await window.remixFileSystem.writeFile(unprefixedpath, content, 'utf8')
} catch (e) {
@ -123,6 +122,7 @@ class FileProvider {
}
if (cb) cb()
return true
})
}
async createDir (path, cb) {
@ -135,14 +135,16 @@ class FileProvider {
if (!await window.remixFileSystem.exists(currentCheck)) {
try {
await window.remixFileSystem.mkdir(currentCheck)
console.log('folder add', currentCheck, this._normalizePath(currentCheck))
this.event.emit('folderAdded', this._normalizePath(currentCheck))
console.log("folderd added")
} catch (error) {
console.log(error)
}
}
}
currentCheck = ''
for (const value of paths) {
currentCheck = currentCheck + '/' + value
this.event.emit('folderAdded', this._normalizePath(currentCheck))
}
if (cb) cb()
}
@ -280,21 +282,17 @@ class FileProvider {
path = this.removePrefix(path)
if (path.indexOf('/') !== 0) path = '/' + path
try {
console.log('res dir', path)
const files = await window.remixFileSystem.readdir(path)
const ret = {}
console.log(files)
if (files) {
for (let element of files) {
path = path.replace(/^\/|\/$/g, '') // remove first and last slash
element = element.replace(/^\/|\/$/g, '') // remove first and last slash
const absPath = (path === '/' ? '' : path) + '/' + element
console.log("stat ", absPath, await window.remixFileSystem.stat(absPath))
ret[absPath.indexOf('/') === 0 ? absPath.substr(1, absPath.length) : absPath] = { isDirectory: (await window.remixFileSystem.stat(absPath)).isDirectory() }
// ^ ret does not accept path starting with '/'
}
}
console.log("return", ret)
if (cb) cb(null, ret)
return ret
} catch (error) {

@ -422,6 +422,9 @@ export class LandingPage extends ViewPlugin {
}, 1000)
}
}
const setDemoFile = async () => {
}
const onAcceptDownloadn = async () => {
await downloadFiles()
const el = document.getElementById('modal-dialog')
@ -472,6 +475,9 @@ export class LandingPage extends ViewPlugin {
<div class="d-flex justify-content-between">
<div class="d-flex flex-column">
<div class="border-bottom d-flex justify-content-between clearfix py-3 mb-4">
<div class="${css.text} pr-1" onclick=${async () => setDemoFile()}>SETFILE</div>
<div class="mx-4 w-100 d-flex">
${img}
<audio id="remiAudio" muted=false src="assets/audio/remiGuitar-single-power-chord-A-minor.wav"></audio>

@ -155,10 +155,6 @@ export class RemixAppManager extends PluginManager {
pattern: [],
sticky: true
})
//await this.call('filePanel', 'deleteWorkspace', `default_workspace`)
console.log("----------------------------------------------")
await this.call('filePanel', 'createWorkspace', `workspace_${Date.now()}`, true)
await this.call('fileManager', 'setFile', `one/two/files.js` ,"test")
}
}

@ -142,7 +142,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
if (cb) cb()
return
}
provider.get(file, (error, content) => {
console.log({ content })
if (error) {

@ -140,21 +140,18 @@ const fileAdded = async (filePath: string) => {
}
const folderAdded = async (folderPath: string) => {
console.log('folder add event', folderPath)
const provider = plugin.fileManager.currentFileProvider()
let path = extractParentFromKey(folderPath) || provider.workspace || provider.type || ''
const promise = new Promise((resolve) => {
provider.resolveDirectory(path, (error, fileTree) => {
if (error) console.error(error)
console.log('resolve', JSON.stringify(fileTree))
resolve(fileTree)
})
})
promise.then((files) => {
folderPath = folderPath.replace(/^\/+/, '')
console.log('folderd add success', path, folderPath, JSON.stringify(files))
dispatch(folderAddedSuccess(path, folderPath, files))
}).catch((error) => {
console.error(error)

@ -190,10 +190,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
})
}
useEffect(() => {
console.log(JSON.stringify(fs.browser.files))
},[JSON.stringify(fs.browser.files).length])
const value = {
fs,
modal,

@ -646,14 +646,25 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s
if (state.mode === 'browser') {
if (payload.path === state.browser.currentWorkspace) {
let files = normalize(payload.fileTree, payload.path, payload.type)
files = _.merge(files, state.browser.files[state.browser.currentWorkspace])
if (deletePath) delete files[deletePath]
return { [state.browser.currentWorkspace]: files }
} else {
let files = state.browser.files
const _path = splitPath(state, payload.path)
const prevFiles = _.get(files, _path)
let prevFiles = _.get(files, _path)
if(!prevFiles){
var object = {}, o = object;
for(let pa of _path) {
o = o[pa] = {};
if(pa !== _path[0])
o = o['child'] = {}
}
files = _.defaultsDeep(files, object)
prevFiles = _.get(files, _path)
}
if (prevFiles) {
prevFiles.child = _.merge(normalize(payload.fileTree, payload.path, payload.type), prevFiles.child)

Loading…
Cancel
Save