feat: migrate to database v3 (#3528)

This commit is contained in:
Alex Yang authored and GitHub committed 2023-08-02 16:50:10 -07:00
1 parent 28a496bc67
commit 32c08e49c5
33 files changed
+410 -282

No files matched your search

@@ -0,0 +1,3 @@
static
fixtures/*.ydoc
test-results
@@ -0,0 +1,7 @@
# AFFiNE Legacy 0.8.0-canary.7
> This package is static output of AFFiNE 0.8.0-canary.7
>
> **This package is for debug only**.
>
> DO NOT MODIFY `affine-core.zip`
Binary file not shown.
@@ -0,0 +1,83 @@
import { resolve } from 'node:path';
import { expect, test } from '@playwright/test';
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
let app: express.Express;
let server: ReturnType<express.Express['listen']>;
process.env.DEBUG = 'http-proxy-middleware*';
async function switchToNext() {
// close previous express server
await new Promise<void>((resolve, reject) => {
server.close(err => {
if (err) {
reject(err);
}
resolve();
});
});
app = express();
app.use(
createProxyMiddleware({
target: 'http://localhost:8080',
pathFilter: ['**'],
changeOrigin: true,
})
);
return new Promise<void>(resolve => {
server = app.listen(8081, () => {
console.log('proxy to next.js server');
resolve();
});
});
}
test.beforeEach(() => {
app = express();
app.use(express.static(resolve(__dirname, '..', 'static')));
server = app.listen(8081);
});
test.afterEach(() => {
server.close();
});
test('database migration', async ({ page, context }) => {
{
// make sure 8080 is ready
const page = await context.newPage();
await page.goto('http://localhost:8080/');
await page.waitForSelector('v-line', {
timeout: 10000,
});
await page.close();
}
await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line', {
timeout: 10000,
});
await page.getByTestId('new-page-button').click();
const title = page.locator('.affine-default-page-block-title');
await title.type('hello');
await page.keyboard.press('Enter', { delay: 50 });
await page.keyboard.press('/', { delay: 50 });
await page.keyboard.press('d');
await page.keyboard.press('a');
await page.keyboard.press('t');
await page.keyboard.press('a');
await page.keyboard.press('b');
await page.keyboard.press('a', { delay: 50 });
await page.keyboard.press('Enter', { delay: 50 });
await switchToNext();
await page.waitForTimeout(1000);
await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line', {
timeout: 10000,
});
expect(await page.locator('v-line').nth(0).textContent()).toBe('hello');
expect(await page.locator('affine-database').isVisible()).toBe(true);
});
@@ -0,0 +1,22 @@
{
"name": "@affine-legacy/0.8.0-canary.7",
"description": "AFFiNE 0.8.0-canary.7 static output",
"scripts": {
"unzip": "unzip affine-core -d static",
"start": "yarn exec serve -s static -l 8082",
"e2e": "yarn playwright test"
},
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@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"
},
"version": "0.8.0-canary.7"
}
@@ -0,0 +1,45 @@
import type {
PlaywrightTestConfig,
PlaywrightWorkerOptions,
} from '@playwright/test';
const config: PlaywrightTestConfig = {
testDir: './e2e',
fullyParallel: true,
timeout: process.env.CI ? 50_000 : 30_000,
use: {
baseURL: 'http://localhost:8081/',
browserName:
(process.env.BROWSER as PlaywrightWorkerOptions['browserName']) ??
'chromium',
permissions: ['clipboard-read', 'clipboard-write'],
viewport: { width: 1440, height: 800 },
actionTimeout: 5 * 1000,
locale: 'en-US',
trace: 'on-first-retry',
video: 'on-first-retry',
},
forbidOnly: !!process.env.CI,
workers: 4,
retries: 1,
reporter: process.env.CI ? 'github' : 'list',
webServer: [
// Intentionally not building the web, reminds you to run it by yourself.
{
command: 'yarn -T run start:web-static',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
},
},
],
};
if (process.env.CI) {
config.retries = 3;
config.workers = '50%';
}
export default config;
@@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"esModuleInterop": true,
"outDir": "lib"
},
"include": ["e2e"]
}