mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-08 12:45:55 +08:00
feat: create workspace from loading existing exported file (#2122)
Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
@@ -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', {
|
||||
|
||||
Reference in New Issue
Block a user