feat: migrate to database v3 (#3528)
This commit is contained in:
1 parent
28a496bc67
commit
32c08e49c5
33 files changed
+410
-282
No files matched your search
@@ -63,24 +63,6 @@ test('init page', async ({ page, context }) => {
|
||||
const locator = page.locator('v-line').nth(0);
|
||||
await locator.fill('hello');
|
||||
|
||||
const currentWorkspaceId: string = await page.evaluate(
|
||||
() => (globalThis as any).currentWorkspace.id
|
||||
);
|
||||
|
||||
const downloadPromise = page.waitForEvent('download');
|
||||
await page.evaluate(() => {
|
||||
const workspace = (globalThis as any).currentWorkspace.blockSuiteWorkspace;
|
||||
workspace.exportYDoc();
|
||||
});
|
||||
|
||||
const download = await downloadPromise;
|
||||
const output = resolve(
|
||||
__dirname,
|
||||
'..',
|
||||
'fixtures',
|
||||
currentWorkspaceId + '.ydoc'
|
||||
);
|
||||
await download.saveAs(output);
|
||||
await switchToNext();
|
||||
await page.waitForTimeout(1000);
|
||||
await page.goto('http://localhost:8081/');
|
||||
|
||||
Whitespace-only changes.
@@ -10,16 +10,14 @@
|
||||
"devDependencies": {
|
||||
"@affine-test/fixtures": "workspace:*",
|
||||
"@affine-test/kit": "workspace:*",
|
||||
"@affine/env": "workspace:*",
|
||||
"@blocksuite/block-std": "0.0.0-20230731152415-fdd3d9b0-nightly",
|
||||
"@blocksuite/blocks": "0.0.0-20230731152415-fdd3d9b0-nightly",
|
||||
"@blocksuite/global": "0.0.0-20230731152415-fdd3d9b0-nightly",
|
||||
"@blocksuite/store": "0.0.0-20230731152415-fdd3d9b0-nightly",
|
||||
"@blocksuite/block-std": "0.0.0-20230802200139-381599c0-nightly",
|
||||
"@blocksuite/blocks": "0.0.0-20230802200139-381599c0-nightly",
|
||||
"@blocksuite/global": "0.0.0-20230802200139-381599c0-nightly",
|
||||
"@blocksuite/store": "0.0.0-20230802200139-381599c0-nightly",
|
||||
"@playwright/test": "^1.36.2",
|
||||
"express": "^4.18.2",
|
||||
"http-proxy-middleware": "^3.0.0-beta.1",
|
||||
"serve": "^14.2.0",
|
||||
"vitest": "^0.33.0"
|
||||
"serve": "^14.2.0"
|
||||
},
|
||||
"version": "0.8.0-canary.7"
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import { readdir, readFile } from 'node:fs/promises';
|
||||
import { extname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { migrateToSubdoc } from '@affine/env/blocksuite';
|
||||
import { Workspace } from '@blocksuite/store';
|
||||
import { test } from 'vitest';
|
||||
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
test('basic', async () => {
|
||||
const oldDoc = new Workspace.Y.Doc();
|
||||
const directory = resolve(__dirname, '..', 'fixtures');
|
||||
const files = await readdir(directory);
|
||||
for (const file of files) {
|
||||
if (extname(file) !== '.ydoc') {
|
||||
continue;
|
||||
}
|
||||
const filePath = resolve(directory, file);
|
||||
const buffer = await readFile(filePath);
|
||||
Workspace.Y.applyUpdate(oldDoc, buffer);
|
||||
const newDoc = migrateToSubdoc(oldDoc);
|
||||
const workspace = new Workspace({
|
||||
id: 'test',
|
||||
});
|
||||
Workspace.Y.applyUpdate(
|
||||
workspace.doc,
|
||||
Workspace.Y.encodeStateAsUpdate(newDoc)
|
||||
);
|
||||
newDoc.subdocs.forEach(subdoc => {
|
||||
workspace.doc.subdocs.forEach(workspaceSubDoc => {
|
||||
if (subdoc.guid === workspaceSubDoc.guid) {
|
||||
Workspace.Y.applyUpdate(
|
||||
workspaceSubDoc,
|
||||
Workspace.Y.encodeStateAsUpdate(subdoc)
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -4,10 +4,5 @@
|
||||
"esModuleInterop": true,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
}
|
||||
]
|
||||
"include": ["e2e"]
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["tests"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../../packages/env"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
include: ['./tests/**/*.spec.ts'],
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user