feat: create workspace from loading existing exported file (#2122)

Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
Peng Xiao
2023-05-09 15:30:01 +08:00
committed by GitHub
parent 5432aae85c
commit 7c2574b1ca
93 changed files with 2999 additions and 1406 deletions
@@ -21,7 +21,7 @@ const mockedAddBlob = vi.fn();
vi.stubGlobal('window', {
apis: {
db: {
getDoc: async () => {
getDocAsUpdates: async () => {
return Y.encodeStateAsUpdate(offlineYdoc);
},
applyDocUpdate: async (id: string, update: Uint8Array) => {
@@ -31,15 +31,24 @@ vi.stubGlobal('window', {
// todo: may need to hack the way to get hash keys of blobs
return [];
},
onDBUpdate: (fn: (id: string) => void) => {
addBlob: mockedAddBlob,
} satisfies Partial<NonNullable<typeof window.apis>['db']>,
},
events: {
db: {
onDbFileUpdate: (fn: (id: string) => void) => {
triggerDBUpdate = fn;
return () => {
triggerDBUpdate = null;
};
},
addBlob: mockedAddBlob,
} satisfies Partial<typeof window.apis.db>,
},
// not used in this test
onDbFileMissing: () => {
return () => {};
},
},
} satisfies Partial<NonNullable<typeof window.events>>,
});
vi.stubGlobal('environment', {