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

This commit is contained in:
Joooye_34
2023-10-13 03:03:42 +00:00
committed by GitHub
parent 286347420d
commit 6ea10860b4
42 changed files with 2763 additions and 140 deletions
+20 -31
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,
});
});