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

This commit is contained in:
Joooye_34 authored and GitHub committed 2023-10-13 03:03:42 +00:00
1 parent 286347420d
commit 6ea10860b4
42 files changed
+2763 -140

No files matched your search

@@ -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,
});
});