add e2e plugin

pull/4837/head
bunsenstraat 11 months ago
parent e99624f82f
commit bdcc099dc4
  1. 42
      apps/remixdesktop/src/plugins/fsPlugin.ts

@ -32,7 +32,7 @@ const getBaseName = (pathName: string): string => {
export class FSPlugin extends ElectronBasePlugin {
clients: FSPluginClient[] = []
constructor() {
super(profile, clientProfile, FSPluginClient)
super(profile, clientProfile, FSPluginClientE2E)
this.methods = [...super.methods, 'closeWatch', 'removeCloseListener']
}
@ -431,3 +431,43 @@ class FSPluginClient extends ElectronBasePluginClient {
createWindow(path)
}
}
import os from 'os'
export class FSPluginClientE2E extends FSPluginClient {
constructor(webContentsId: number, profile: Profile) {
super(webContentsId, profile)
}
async selectFolder(dir?: string, title?: string, button?: string): Promise<string> {
if (!dir) {
// create random directory on os homedir
const randomdir = path.join(os.homedir(), 'remix-tests' + Date.now().toString())
await fs.mkdir(randomdir)
return randomdir
}
if (!dir) return ''
return dir
}
async openFolder(dir?: string): Promise<void> {
dir = await this.selectFolder(dir)
await this.updateRecentFolders(dir)
await this.updateOpenedFolders(dir)
if (!dir) return
this.openWindow(dir)
}
async openFolderInSameWindow(dir?: string): Promise<void> {
dir = await this.selectFolder(dir)
if (!dir) return
this.workingDir = dir
await this.updateRecentFolders(dir)
await this.updateOpenedFolders(dir)
this.window.setTitle(this.workingDir)
this.watch()
this.emit('workingDirChanged', dir)
}
}

Loading…
Cancel
Save