refactor(infra): record legacy data to improve testing stability (#4590)

This commit is contained in:
Joooye_34
2023-10-13 11:03:42 +08:00
committed by GitHub
parent 286347420d
commit 6ea10860b4
42 changed files with 2763 additions and 140 deletions

View File

@@ -1,7 +1,12 @@
# AFFiNE Legacy 0.7.0-canary.18
> This package is static output of AFFiNE 0.7.0-canary.18
>
> **This package is for debug only**.
>
> DO NOT MODIFY `affine-web.zip`
This package is used to record legacy data of 0.7.0-canary.18.
Run following commands locally to record data to `tests/fixtures/legacy/0.7.0-canary.18`.
```sh
cd tests/affine-legacy/0.7.0-canary.18
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.

View File

@@ -1,36 +1,33 @@
import { resolve } from 'node:path';
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';
import {
check8080Available,
setupProxyServer,
} from '@affine-test/kit/utils/proxy';
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
import { expect } from '@playwright/test';
const { switchToNext } = setupProxyServer(
test,
resolve(__dirname, '..', 'static')
);
test.beforeEach(async ({ page }) => {
await patchDataEnhancement(page);
});
test('init page', async ({ page, context }) => {
await check8080Available(context);
test('record 0.7.0-canary.18 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 switchToNext();
await page.waitForTimeout(1000);
await page.goto('http://localhost:8081/');
await waitForEditorLoad(page);
await clickSideBarAllPageButton(page);
await page.getByText('hello').click();
await waitForEditorLoad(page);
expect(await page.locator('v-line').nth(0).textContent()).toBe('hello');
const localStorageData = await page.evaluate(() =>
window.readAffineLocalStorage()
);
const { idbData, binaries } = await page.evaluate(() =>
window.readAffineDatabase()
);
const snapshotStorage = new SnapshotStorage('0.7.0-canary.18');
await snapshotStorage.write({
idbData,
localStorageData,
binaries,
});
});

View File

@@ -3,9 +3,8 @@
"description": "AFFiNE 0.7.0-canary.18 static output",
"scripts": {
"unzip": "wget -O static.zip https://github.com/toeverything/AFFiNE/releases/download/v0.7.0-canary.18/web-static.zip && unzip static.zip -d static",
"start": "yarn exec serve -s static -l 8082",
"e2e": "yarn playwright test",
"test": "vitest --run"
"start": "yarn exec serve -s static -l 8081",
"e2e": "yarn playwright test"
},
"devDependencies": {
"@affine-test/fixtures": "workspace:*",

View File

@@ -24,15 +24,11 @@ const config: PlaywrightTestConfig = {
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,
command: 'yarn run start',
port: 8081,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
},
},
],
};

View File

@@ -1,7 +1,12 @@
# 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`
This package is used to record legacy data of 0.8.0-canary.7.
Run following commands locally to record data to `tests/fixtures/legacy/0.8.0-canary.7`.
```sh
cd tests/affine-legacy/0.8.0-canary.7
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.

View File

@@ -1,20 +1,12 @@
import { join } from 'node:path';
import { patchDataEnhancement } from '@affine-test/kit/e2e-enhance/initializer';
import { SnapshotStorage } from '@affine-test/kit/e2e-enhance/snapshot';
import { test } from '@playwright/test';
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import {
check8080Available,
setupProxyServer,
} from '@affine-test/kit/utils/proxy';
import { expect, test } from '@playwright/test';
test.beforeEach(async ({ page }) => {
await patchDataEnhancement(page);
});
const { switchToNext } = setupProxyServer(
test,
join(__dirname, '..', 'web-static')
);
test('database migration', async ({ page, context }) => {
await check8080Available(context);
test('record 0.8.0-canary.7 database legacy data', async ({ page }) => {
await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line', {
timeout: 10000,
@@ -32,22 +24,17 @@ test('database migration', async ({ page, context }) => {
await page.keyboard.press('a', { delay: 50 });
await page.keyboard.press('Enter', { delay: 50 });
const url = page.url();
const localStorageData = await page.evaluate(() =>
window.readAffineLocalStorage()
);
const { idbData, binaries } = await page.evaluate(() =>
window.readAffineDatabase()
);
await switchToNext();
await page.waitForTimeout(1000);
await page.goto(url);
//#region fixme(himself65): blocksuite issue, data cannot be loaded to store
await page.waitForTimeout(5000);
await page.reload();
//#endregion
await waitForEditorLoad(page);
// check page mode is correct
expect(await page.locator('v-line').nth(0).textContent()).toBe('hello');
expect(await page.locator('affine-database').isVisible()).toBe(true);
// check edgeless mode is correct
await clickEdgelessModeButton(page);
await page.waitForTimeout(200);
expect(await page.locator('affine-database').isVisible()).toBe(true);
const snapshotStorage = new SnapshotStorage('0.8.0-canary.7');
await snapshotStorage.write({
idbData,
localStorageData,
binaries,
});
});

View File

@@ -3,7 +3,7 @@
"description": "AFFiNE 0.8.0-canary.7 static output",
"scripts": {
"unzip": "wget -O static.zip https://github.com/toeverything/AFFiNE/releases/download/v0.8.0-canary.7/web-static.zip && unzip static.zip",
"start": "yarn exec serve -s web-static -l 8082",
"start": "yarn exec serve -s web-static -l 8081",
"e2e": "yarn playwright test"
},
"devDependencies": {

View File

@@ -24,15 +24,11 @@ const config: PlaywrightTestConfig = {
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,
command: 'yarn run start',
port: 8081,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
},
},
],
};

View File

@@ -1,7 +1,12 @@
# AFFiNE Legacy 0.8.3
# AFFiNE Legacy 0.8.4
> This package is static output of AFFiNE 0.8.3
>
> **This package is for debug only**.
>
> DO NOT MODIFY `affine-core.zip`
This package is used to record legacy data of 0.8.4.
Run following commands locally to record data to `tests/fixtures/legacy/0.8.4`.
```sh
cd tests/affine-legacy/0.8.4
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.

View File

@@ -1,23 +1,13 @@
import { join } from 'node:path';
import { patchDataEnhancement } from '@affine-test/kit/e2e-enhance/initializer';
import { SnapshotStorage } from '@affine-test/kit/e2e-enhance/snapshot';
import { getBlockSuiteEditorTitle } from '@affine-test/kit/utils/page-logic';
import { test } from '@playwright/test';
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
import {
getBlockSuiteEditorTitle,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import {
check8080Available,
setupProxyServer,
} from '@affine-test/kit/utils/proxy';
import { expect, test } from '@playwright/test';
test.beforeEach(async ({ page }) => {
await patchDataEnhancement(page);
});
const { switchToNext } = setupProxyServer(
test,
join(__dirname, '..', 'web-static')
);
test('surface migration', async ({ page, context }) => {
await check8080Available(context);
test('record 0.8.4 surface legacy data', async ({ page }) => {
await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line', {
timeout: 10000,
@@ -47,19 +37,18 @@ test('surface migration', async ({ page, context }) => {
steps: 10,
});
await page.mouse.up();
const url = page.url();
await switchToNext();
await page.waitForTimeout(1000);
await page.goto(url);
//#region fixme(himself65): blocksuite issue, data cannot be loaded to store
await page.waitForTimeout(5000);
await page.reload();
//#endregion
await waitForEditorLoad(page);
const localStorageData = await page.evaluate(() =>
window.readAffineLocalStorage()
);
const { idbData, binaries } = await page.evaluate(() =>
window.readAffineDatabase()
);
// check edgeless mode is correct
await clickEdgelessModeButton(page);
await expect(page.locator('edgeless-toolbar')).toBeVisible();
await expect(page.locator('affine-edgeless-page')).toBeVisible();
const snapshotStorage = new SnapshotStorage('0.8.4');
await snapshotStorage.write({
idbData,
localStorageData,
binaries,
});
});

View File

@@ -3,7 +3,7 @@
"description": "AFFiNE 0.8.4 static output",
"scripts": {
"unzip": "wget -O static.zip https://github.com/toeverything/AFFiNE/releases/download/v0.8.4/web-static.zip && unzip static.zip",
"start": "yarn exec serve -s web-static -l 8082",
"start": "yarn exec serve -s web-static -l 8081",
"e2e": "yarn playwright test"
},
"devDependencies": {

View File

@@ -24,15 +24,11 @@ const config: PlaywrightTestConfig = {
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,
command: 'yarn run start',
port: 8081,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
},
},
],
};