diff --git a/apps/remix-ide/src/app/components/preload.tsx b/apps/remix-ide/src/app/components/preload.tsx index dcd4e23cbe..c6515ba82f 100644 --- a/apps/remix-ide/src/app/components/preload.tsx +++ b/apps/remix-ide/src/app/components/preload.tsx @@ -5,7 +5,7 @@ import * as packageJson from '../../../../../package.json' import { fileSystem, fileSystems } from '../files/fileSystem' import { indexedDBFileSystem } from '../files/filesystems/indexedDB' import { localStorageFS } from '../files/filesystems/localStorage' -import { fileSystemUtility } from '../files/filesystems/fileSystemUtility' +import { fileSystemUtility, migrationTestData } from '../files/filesystems/fileSystemUtility' import './styles/preload.css' export const Preload = () => { @@ -56,10 +56,20 @@ export const Preload = () => { } } + const testmigration = async() => { + // load dummy data for e2e test + const testmigration = window.location.hash.includes('e2e_testmigration=true') && window.location.host === '127.0.0.1:8080' && window.location.protocol === 'http:' + const fsUtility = new fileSystemUtility() + if (testmigration) { + fsUtility.populateWorkspace(migrationTestData, remixFileSystems.current.fileSystems['localstorage'].fs) + } + } + useEffect(() => { async function loadStorage() { await remixFileSystems.current.addFileSystem(remixIndexedDB.current) await remixFileSystems.current.addFileSystem(localStorageFileSystem.current) + await testmigration() remixIndexedDB.current.loaded && await remixIndexedDB.current.checkWorkspaces() localStorageFileSystem.current.loaded && await localStorageFileSystem.current.checkWorkspaces() remixIndexedDB.current.loaded && ( (remixIndexedDB.current.hasWorkSpaces || !localStorageFileSystem.current.hasWorkSpaces)? await setFileSystems():setShowDownloader(true)) diff --git a/apps/remix-ide/src/app/files/filesystems/fileSystemUtility.ts b/apps/remix-ide/src/app/files/filesystems/fileSystemUtility.ts index 9e5e43b80a..d2d9d92550 100644 --- a/apps/remix-ide/src/app/files/filesystems/fileSystemUtility.ts +++ b/apps/remix-ide/src/app/files/filesystems/fileSystemUtility.ts @@ -18,7 +18,6 @@ export class fileSystemUtility { return true } - await this.populateWorkspace(testData, fsFrom.fs) const fromFiles = await this.copyFolderToJson('/', null, null, fsFrom.fs) console.log(fsFrom.name, hashMessage(JSON.stringify(fromFiles)), fromFiles) await this.populateWorkspace(fromFiles, fsTo.fs) @@ -150,7 +149,7 @@ export class fileSystemUtility { /* eslint-disable no-template-curly-in-string */ -const testData = { +export const migrationTestData = { '.workspaces': { children: { '.workspaces/default_workspace': {