mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 10:31:50 +08:00
test(e2e): add subdoc migration test (#4921)
test(e2e): add subdoc migration test fix: remove .only
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
static
|
||||
fixtures/*.ydoc
|
||||
test-results
|
||||
*.zip
|
||||
@@ -0,0 +1,12 @@
|
||||
# AFFiNE Legacy 0.6.1-beta.1
|
||||
|
||||
This package is used to record legacy data of 0.6.1-beta.1.
|
||||
Run following commands locally to record data to `tests/fixtures/legacy/0.6.1-beta.1`.
|
||||
|
||||
```sh
|
||||
cd tests/affine-legacy/0.6.1-beta.1
|
||||
yarn run unzip
|
||||
yarn run e2e
|
||||
```
|
||||
|
||||
If you want to debug, running `yarn run e2e --ui` is ok. Or using https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright is more better.
|
||||
@@ -0,0 +1,36 @@
|
||||
import { patchDataEnhancement } from '@affine-test/kit/e2e-enhance/initializer';
|
||||
import { SnapshotStorage } from '@affine-test/kit/e2e-enhance/snapshot';
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
waitForEditorLoad,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await patchDataEnhancement(page);
|
||||
});
|
||||
|
||||
test('record 0.6.1-beta.1 legacy data', async ({ page }) => {
|
||||
await page.goto('http://localhost:8081/');
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
const locator = page.locator('v-line').nth(0);
|
||||
await locator.fill('hello');
|
||||
|
||||
await page.keyboard.press('Enter');
|
||||
await page.keyboard.type('TEST CONTENT', { delay: 50 });
|
||||
|
||||
const localStorageData = await page.evaluate(() =>
|
||||
window.readAffineLocalStorage()
|
||||
);
|
||||
const { idbData, binaries } = await page.evaluate(() =>
|
||||
window.readAffineDatabase()
|
||||
);
|
||||
|
||||
const snapshotStorage = new SnapshotStorage('0.6.1-beta.1');
|
||||
await snapshotStorage.write({
|
||||
idbData,
|
||||
localStorageData,
|
||||
binaries,
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@affine-legacy/0.6.1-beta.1",
|
||||
"description": "AFFiNE 0.6.1-beta.1 static output",
|
||||
"scripts": {
|
||||
"unzip": "wget -O static.zip https://github.com/toeverything/AFFiNE/releases/download/v0.6.1-beta.1/web-static.zip && unzip static.zip -d static",
|
||||
"start": "yarn exec serve -s static -l 8081",
|
||||
"e2e": "yarn playwright test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@affine-test/fixtures": "workspace:*",
|
||||
"@affine-test/kit": "workspace:*",
|
||||
"@blocksuite/block-std": "0.0.0-20231110042432-4fdac4dc-nightly",
|
||||
"@blocksuite/blocks": "0.0.0-20231110042432-4fdac4dc-nightly",
|
||||
"@blocksuite/global": "0.0.0-20231110042432-4fdac4dc-nightly",
|
||||
"@blocksuite/store": "0.0.0-20231110042432-4fdac4dc-nightly",
|
||||
"@playwright/test": "^1.39.0",
|
||||
"express": "^4.18.2",
|
||||
"http-proxy-middleware": "^3.0.0-beta.1",
|
||||
"serve": "^14.2.1"
|
||||
},
|
||||
"version": "0.10.0"
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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: [
|
||||
{
|
||||
command: 'yarn run start',
|
||||
port: 8081,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
if (process.env.CI) {
|
||||
config.retries = 3;
|
||||
config.workers = '50%';
|
||||
}
|
||||
|
||||
export default config;
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../../tests/kit"
|
||||
},
|
||||
{
|
||||
"path": "../../../tests/fixtures"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user