There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
test: improve data migration suite (#4124)
Alex Yang70b5a9deeb89
diff --git a/tests/affine-cloud/e2e/basic.spec.ts b/tests/affine-cloud/e2e/basic.spec.tsindex 84866289d5..beb5669497 100644--- a/tests/affine-cloud/e2e/basic.spec.ts+++ b/tests/affine-cloud/e2e/basic.spec.ts@@ -5,7 +5,7 @@ import {getLoginCookie,loginUser,} from '@affine-test/kit/utils/cloud';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';let user: {@@ -37,7 +37,7 @@ test('enable cloud success', async ({ page, context }) => {afterLogin: async () => {expect(await getLoginCookie(context)).toBeTruthy();await page.reload();- await waitEditorLoad(page);+ await waitForEditorLoad(page);expect(await getLoginCookie(context)).toBeTruthy();},});diff --git a/tests/affine-cloud/e2e/login.spec.ts b/tests/affine-cloud/e2e/login.spec.tsindex 90596b79bc..0cc007a477 100644--- a/tests/affine-cloud/e2e/login.spec.ts+++ b/tests/affine-cloud/e2e/login.spec.ts@@ -1,13 +1,13 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';import { expect } from '@playwright/test';test.describe('login', () => {test('can open login modal in workspace list', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarCurrentWorkspaceBanner(page);await page.getByTestId('cloud-signin-button').click({delay: 200,diff --git a/tests/affine-legacy/0.7.0-canary.18/e2e/basic.spec.ts b/tests/affine-legacy/0.7.0-canary.18/e2e/basic.spec.tsindex 28650bf2db..55fde1fc3a 100644--- a/tests/affine-legacy/0.7.0-canary.18/e2e/basic.spec.ts+++ b/tests/affine-legacy/0.7.0-canary.18/e2e/basic.spec.ts@@ -1,74 +1,29 @@import { resolve } from 'node:path';import { test } from '@affine-test/kit/playwright';+import { newPage, waitForEditorLoad } from '@affine-test/kit/utils/page-logic';+import {+ check8080Available,+ setupProxyServer,+} from '@affine-test/kit/utils/proxy';import { expect } 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();-});+const { switchToNext } = setupProxyServer(+ test,+ resolve(__dirname, '..', 'static')+);test('init page', 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 check8080Available(context);await page.goto('http://localhost:8081/');- await page.waitForSelector('v-line', {- timeout: 10000,- });- await page.getByTestId('new-page-button').click();+ await waitForEditorLoad(page);+ await newPage(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 page.waitForSelector('v-line', {- timeout: 10000,- });+ await waitForEditorLoad(page);expect(await page.locator('v-line').nth(0).textContent()).toBe('hello');});diff --git a/tests/affine-legacy/0.7.0-canary.18/tsconfig.json b/tests/affine-legacy/0.7.0-canary.18/tsconfig.jsonindex 9d9cf8b360..85fae184b9 100644--- a/tests/affine-legacy/0.7.0-canary.18/tsconfig.json+++ b/tests/affine-legacy/0.7.0-canary.18/tsconfig.json@@ -6,6 +6,9 @@},"include": ["e2e"],"references": [+ {+ "path": "../../fixtures"+ },{"path": "../../kit"}diff --git a/tests/affine-legacy/0.8.0-canary.7/e2e/basic.spec.ts b/tests/affine-legacy/0.8.0-canary.7/e2e/basic.spec.tsindex ee847c66bb..e7acb20630 100644--- a/tests/affine-legacy/0.8.0-canary.7/e2e/basic.spec.ts+++ b/tests/affine-legacy/0.8.0-canary.7/e2e/basic.spec.ts@@ -1,60 +1,20 @@import { resolve } from 'node:path';+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';-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();-});+const { switchToNext } = setupProxyServer(+ test,+ resolve(__dirname, '..', 'static')+);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 check8080Available(context);await page.goto('http://localhost:8081/');await page.waitForSelector('v-line', {timeout: 10000,@@ -76,9 +36,14 @@ test('database migration', async ({ page, context }) => {await page.waitForTimeout(1000);await page.goto('http://localhost:8081/');await page.click('text=hello');- await page.waitForSelector('v-line', {- timeout: 10000,- });+ await waitForEditorLoad(page);+ // check page mode is correctexpect(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 page.getByTestId('switch-edgeless-mode-button').click();+ await clickEdgelessModeButton(page);+ await page.waitForTimeout(200);+ expect(await page.locator('affine-database').isVisible()).toBe(true);});diff --git a/tests/affine-legacy/0.8.0-canary.7/tsconfig.json b/tests/affine-legacy/0.8.0-canary.7/tsconfig.jsonindex 0b284713e8..85fae184b9 100644--- a/tests/affine-legacy/0.8.0-canary.7/tsconfig.json+++ b/tests/affine-legacy/0.8.0-canary.7/tsconfig.json@@ -4,5 +4,13 @@"esModuleInterop": true,"outDir": "lib"},- "include": ["e2e"]+ "include": ["e2e"],+ "references": [+ {+ "path": "../../fixtures"+ },+ {+ "path": "../../kit"+ }+ ]}diff --git a/tests/affine-local/e2e/all-page.spec.ts b/tests/affine-local/e2e/all-page.spec.tsindex 6b74b3007a..02d903fa4a 100644--- a/tests/affine-local/e2e/all-page.spec.ts+++ b/tests/affine-local/e2e/all-page.spec.ts@@ -17,8 +17,8 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,waitForAllPagesLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';import type { Page } from '@playwright/test';@@ -45,14 +45,14 @@ function getAllPage(page: Page) {test('all page', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarAllPageButton(page);});test('all page can create new page', async ({ page }) => {const { clickNewPageButton } = getAllPage(page);await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarAllPageButton(page);await clickNewPageButton();const title = getBlockSuiteEditorTitle(page);@@ -65,7 +65,7 @@ test('all page can create new page', async ({ page }) => {test('all page can create new edgeless page', async ({ page }) => {const { clickNewEdgelessDropdown } = getAllPage(page);await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarAllPageButton(page);await clickNewEdgelessDropdown();await expect(page.locator('affine-edgeless-page')).toBeVisible();@@ -73,7 +73,7 @@ test('all page can create new edgeless page', async ({ page }) => {test('allow creation of filters by favorite', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarAllPageButton(page);await createFirstFilter(page, 'Favourited');await page@@ -87,7 +87,7 @@ test('allow creation of filters by favorite', async ({ page }) => {test('allow creation of filters by created time', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await clickSideBarAllPageButton(page);await waitForAllPagesLoad(page);@@ -122,7 +122,7 @@ test('creation of filters by created time, then click date picker to modify thepage,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await clickSideBarAllPageButton(page);await waitForAllPagesLoad(page);@@ -155,7 +155,7 @@ test('creation of filters by created time, then click date picker to modify thetest('use monthpicker to modify the month of datepicker', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarAllPageButton(page);await createFirstFilter(page, 'Created');await checkFilterName(page, 'after');@@ -179,7 +179,7 @@ test('use monthpicker to modify the month of datepicker', async ({ page }) => {test('allow creation of filters by tags', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarAllPageButton(page);await waitForAllPagesLoad(page);const pages = await page.locator('[data-testid="title"]').all();diff --git a/tests/affine-local/e2e/blocksuite/block-hub.spec.ts b/tests/affine-local/e2e/blocksuite/block-hub.spec.tsindex 4109a90955..b4c13a0760 100644--- a/tests/affine-local/e2e/blocksuite/block-hub.spec.ts+++ b/tests/affine-local/e2e/blocksuite/block-hub.spec.ts@@ -1,10 +1,10 @@import { test } from '@affine-test/kit/playwright';import { checkBlockHub } from '@affine-test/kit/utils/editor';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';test('block-hub should work', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await checkBlockHub(page);});diff --git a/tests/affine-local/e2e/blocksuite/editor.spec.ts b/tests/affine-local/e2e/blocksuite/editor.spec.tsindex 2812857032..651768d7ef 100644--- a/tests/affine-local/e2e/blocksuite/editor.spec.ts+++ b/tests/affine-local/e2e/blocksuite/editor.spec.ts@@ -3,7 +3,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import type { Page } from '@playwright/test';import { expect } from '@playwright/test';@@ -19,9 +19,9 @@ const addDatabase = async (page: Page) => {test('database is useable', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const title = getBlockSuiteEditorTitle(page);await title.type('test title');await page.keyboard.press('Enter');@@ -30,9 +30,9 @@ test('database is useable', async ({ page }) => {const database = page.locator('affine-database');await expect(database).toBeVisible();await page.reload();- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const title2 = getBlockSuiteEditorTitle(page);await title2.type('test title2');await page.waitForTimeout(500);@@ -45,15 +45,15 @@ test('database is useable', async ({ page }) => {test('link page is useable', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const title = await getBlockSuiteEditorTitle(page);await title.type('page1');await page.keyboard.press('Enter');expect(await title.innerText()).toBe('page1');await newPage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const title2 = await getBlockSuiteEditorTitle(page);await title2.type('page2');await page.keyboard.press('Enter');diff --git a/tests/affine-local/e2e/change-page-mode.spec.ts b/tests/affine-local/e2e/change-page-mode.spec.tsindex 46dd6c2275..bca29585b6 100644--- a/tests/affine-local/e2e/change-page-mode.spec.ts+++ b/tests/affine-local/e2e/change-page-mode.spec.ts@@ -2,7 +2,7 @@ import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {clickPageMoreActions,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -14,7 +14,7 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {});}await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const btn = await page.getByTestId('switch-edgeless-mode-button');await page.evaluate(() => {// @ts-expect-error@@ -55,7 +55,7 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {test('Convert to edgeless by editor header items', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickPageMoreActions(page);const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless');await menusEdgelessItem.click({ delay: 100 });@@ -65,7 +65,7 @@ test('Convert to edgeless by editor header items', async ({ page }) => {test('Able to insert the title of an untitled page', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const titleBarTextContent = await page.getByTestId('title-edit-button');await titleBarTextContent.click({ delay: 100 });const titleContent = await page.getByTestId('title-content');@@ -76,7 +76,7 @@ test('Able to insert the title of an untitled page', async ({ page }) => {test('Able to edit the title of an existing page', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const titleBarTextContent = await page.getByTestId('title-edit-button');await titleBarTextContent.click({ delay: 100 });const titleContent = await page.getByTestId('title-content');@@ -93,7 +93,7 @@ test('Clearing out the title bar will remove the page title', async ({page,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const titleBarTextContent = await page.getByTestId('title-edit-button');await titleBarTextContent.click({ delay: 100 });const titleContent = await page.getByTestId('title-content');@@ -108,7 +108,7 @@ test('Clearing out the title bar will remove the page title', async ({test('Rename by editor header items, save with shortcut', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickPageMoreActions(page);const menusRenameItem = page.getByTestId('editor-option-menu-rename');await menusRenameItem.click({ delay: 100 });diff --git a/tests/affine-local/e2e/contact-us.spec.ts b/tests/affine-local/e2e/contact-us.spec.tsindex 4b38849763..4922c3ce17 100644--- a/tests/affine-local/e2e/contact-us.spec.ts+++ b/tests/affine-local/e2e/contact-us.spec.ts@@ -1,11 +1,11 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('Click right-bottom corner contact icon', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await page.locator('[data-testid=help-island]').click();const rightBottomContactUs = page.locator('[data-testid=right-bottom-contact-us-icon]'diff --git a/tests/affine-local/e2e/drag-page-to-trash-folder.spec.ts b/tests/affine-local/e2e/drag-page-to-trash-folder.spec.tsindex b6ae44ccbe..2aee67f757 100644--- a/tests/affine-local/e2e/drag-page-to-trash-folder.spec.ts+++ b/tests/affine-local/e2e/drag-page-to-trash-folder.spec.ts@@ -1,6 +1,6 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('drag a page from "All pages" list onto the "Trash" folder in the sidebar to move it to trash list', async ({@@ -10,7 +10,7 @@ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar t// Init test db with known workspaces and open "All Pages" page via url directly{await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await page.getByText('All Pages').click();await page.waitForTimeout(500);}diff --git a/tests/affine-local/e2e/duplicate-page.spec.ts b/tests/affine-local/e2e/duplicate-page.spec.tsindex cf592cd18c..9df4f54906 100644--- a/tests/affine-local/e2e/duplicate-page.spec.ts+++ b/tests/affine-local/e2e/duplicate-page.spec.ts@@ -4,13 +4,13 @@ import {clickPageMoreActions,getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('Duplicate page should work', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);const title = getBlockSuiteEditorTitle(page);await title.type('test');diff --git a/tests/affine-local/e2e/image-preview.spec.ts b/tests/affine-local/e2e/image-preview.spec.tsindex 9f239be369..70bafb4195 100644--- a/tests/affine-local/e2e/image-preview.spec.ts+++ b/tests/affine-local/e2e/image-preview.spec.ts@@ -2,7 +2,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import type { Page } from '@playwright/test';import { expect, test } from '@playwright/test';@@ -42,7 +42,7 @@ async function closeImagePreviewModal(page: Page) {test('image preview should be shown', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);const title = await getBlockSuiteEditorTitle(page);await title.click();@@ -57,7 +57,7 @@ test('image preview should be shown', async ({ page }) => {test('image go left and right', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -104,7 +104,7 @@ test('image go left and right', async ({ page }) => {test('image able to zoom in and out with mouse scroll', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -157,7 +157,7 @@ test('image able to zoom in and out with mouse scroll', async ({ page }) => {test('image able to zoom in and out with button click', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -203,7 +203,7 @@ test('image able to zoom in and out with button click', async ({ page }) => {test('image should able to go left and right by buttons', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -257,7 +257,7 @@ test('image should able to go left and right by buttons', async ({ page }) => {test('image able to fit to screen by button', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -314,7 +314,7 @@ test('image able to fit to screen by button', async ({ page }) => {test('image able to reset zoom to 100%', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -367,7 +367,7 @@ test('image able to reset zoom to 100%', async ({ page }) => {test('image able to copy to clipboard', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -394,7 +394,7 @@ test('image able to copy to clipboard', async ({ page }) => {test('image able to download', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -426,7 +426,7 @@ test('image should only able to move when image is larger than viewport', asyncpage,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -483,7 +483,7 @@ test('image should able to delete and when delete, it will move to previous/nextpage,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -558,7 +558,7 @@ test('tooltips for all buttons should be visible when hovering', async ({page,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);let blobId: string;{@@ -653,7 +653,7 @@ test('tooltips for all buttons should be visible when hovering', async ({test('keypress esc should close the modal', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);const title = await getBlockSuiteEditorTitle(page);await title.click();@@ -671,7 +671,7 @@ test('when mouse moves outside, the modal should be closed', async ({page,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);const title = await getBlockSuiteEditorTitle(page);await title.click();@@ -692,7 +692,7 @@ test('caption should be visible and different styles were applied if image zoome}) => {const sampleCaption = 'affine owns me and all';await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);const title = await getBlockSuiteEditorTitle(page);await title.click();diff --git a/tests/affine-local/e2e/layout.spec.ts b/tests/affine-local/e2e/layout.spec.tsindex 57d1fa4ce2..c051f46a7a 100644--- a/tests/affine-local/e2e/layout.spec.ts+++ b/tests/affine-local/e2e/layout.spec.ts@@ -1,11 +1,11 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('Collapse Sidebar', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await page.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]').click();@@ -15,7 +15,7 @@ test('Collapse Sidebar', async ({ page }) => {test('Expand Sidebar', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await page.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]').click();@@ -30,7 +30,7 @@ test('Expand Sidebar', async ({ page }) => {test('Click resizer can close sidebar', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const sliderBarArea = page.getByTestId('sliderBar-inner');await expect(sliderBarArea).toBeVisible();@@ -40,7 +40,7 @@ test('Click resizer can close sidebar', async ({ page }) => {test('Drag resizer can resize sidebar', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const sliderBarArea = page.getByTestId('sliderBar-inner');await expect(sliderBarArea).toBeVisible();@@ -57,7 +57,7 @@ test('Drag resizer can resize sidebar', async ({ page }) => {test('Sidebar in between sm & md breakpoint', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const sliderBarArea = page.getByTestId('sliderBar-inner');const sliderBarModalBackground = page.getByTestId('app-sidebar-float-mask');await expect(sliderBarArea).toBeInViewport();diff --git a/tests/affine-local/e2e/local-first-avatar.spec.ts b/tests/affine-local/e2e/local-first-avatar.spec.tsindex bc9cb101c6..063b1d52d2 100644--- a/tests/affine-local/e2e/local-first-avatar.spec.ts+++ b/tests/affine-local/e2e/local-first-avatar.spec.ts@@ -2,7 +2,7 @@ import { resolve } from 'node:path';import { rootDir, test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { newPage, waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { newPage, waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('should create a page with a local first avatar', async ({@@ -10,7 +10,7 @@ test('should create a page with a local first avatar', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await page.getByTestId('workspace-name').click();await page.getByTestId('new-workspace').click({ delay: 50 });diff --git a/tests/affine-local/e2e/local-first-collections-items.spec.ts b/tests/affine-local/e2e/local-first-collections-items.spec.tsindex 168a7266f5..8451d0de71 100644--- a/tests/affine-local/e2e/local-first-collections-items.spec.ts+++ b/tests/affine-local/e2e/local-first-collections-items.spec.ts@@ -7,7 +7,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import type { Page } from '@playwright/test';import { expect } from '@playwright/test';@@ -19,7 +19,7 @@ const createAndPinCollection = async (}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('test page');@@ -140,7 +140,7 @@ test('edit collection and change filter date', async ({ page }) => {test('create temporary filter by click tag', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('test page');@@ -162,7 +162,7 @@ test('create temporary filter by click tag', async ({ page }) => {test('add collection from sidebar', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('test page');diff --git a/tests/affine-local/e2e/local-first-delete-page.spec.ts b/tests/affine-local/e2e/local-first-delete-page.spec.tsindex 762c2ac51e..89daf71a43 100644--- a/tests/affine-local/e2e/local-first-delete-page.spec.ts+++ b/tests/affine-local/e2e/local-first-delete-page.spec.ts@@ -3,7 +3,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -12,7 +12,7 @@ test('page delete -> refresh page -> it should be disappear', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page delete');@@ -55,7 +55,7 @@ test('page delete -> create new page -> refresh page -> new page should be appeaworkspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page delete');@@ -113,7 +113,7 @@ test('delete multiple pages -> create multiple pages -> refresh', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);// create 1st pageawait newPage(page);await getBlockSuiteEditorTitle(page).click();diff --git a/tests/affine-local/e2e/local-first-delete-workspace.spec.ts b/tests/affine-local/e2e/local-first-delete-workspace.spec.tsindex b67b20c1f8..0f43a85e4e 100644--- a/tests/affine-local/e2e/local-first-delete-workspace.spec.ts+++ b/tests/affine-local/e2e/local-first-delete-workspace.spec.ts@@ -1,6 +1,6 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { openWorkspaceSettingPanel } from '@affine-test/kit/utils/setting';import { openSettingModal } from '@affine-test/kit/utils/setting';import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';@@ -8,7 +8,7 @@ import { expect } from '@playwright/test';test('Create new workspace, then delete it', async ({ page, workspace }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarCurrentWorkspaceBanner(page);await page.getByTestId('new-workspace').click();await page@@ -49,7 +49,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {//FIXME: this test is brokentest('Delete last workspace', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const workspaceNameDom = await page.getByTestId('workspace-name');const currentWorkspaceName = await workspaceNameDom.evaluate(node => node.textContentdiff --git a/tests/affine-local/e2e/local-first-export-page.spec.ts b/tests/affine-local/e2e/local-first-export-page.spec.tsindex aac4ea06c7..0c97859e5c 100644--- a/tests/affine-local/e2e/local-first-export-page.spec.ts+++ b/tests/affine-local/e2e/local-first-export-page.spec.ts@@ -4,7 +4,7 @@ import {clickPageMoreActions,getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -13,7 +13,7 @@ test.skip('New a page ,then open it and export html', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await pagediff --git a/tests/affine-local/e2e/local-first-favorite-page.spec.ts b/tests/affine-local/e2e/local-first-favorite-page.spec.tsindex ad0911139a..ebc24fa1f6 100644--- a/tests/affine-local/e2e/local-first-favorite-page.spec.ts+++ b/tests/affine-local/e2e/local-first-favorite-page.spec.ts@@ -4,7 +4,7 @@ import {clickPageMoreActions,getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { waitForLogMessage } from '@affine-test/kit/utils/utils';import { expect } from '@playwright/test';@@ -14,7 +14,7 @@ test('New a page and open it ,then favorite it', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');@@ -35,7 +35,7 @@ test('New a page and open it ,then favorite it', async ({test('Export to html, markdown and png', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);{await clickPageMoreActions(page);await page.getByTestId('export-menu').click();@@ -69,7 +69,7 @@ test.skip('Export to pdf', async ({ page }) => {});});await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);{await clickPageMoreActions(page);await page.getByTestId('export-menu').click();@@ -80,7 +80,7 @@ test.skip('Export to pdf', async ({ page }) => {test('Cancel favorite', async ({ page, workspace }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');diff --git a/tests/affine-local/e2e/local-first-favorites-items.spec.ts b/tests/affine-local/e2e/local-first-favorites-items.spec.tsindex d672fb9af1..1938fab0a6 100644--- a/tests/affine-local/e2e/local-first-favorites-items.spec.ts+++ b/tests/affine-local/e2e/local-first-favorites-items.spec.ts@@ -5,13 +5,13 @@ import {createLinkedPage,getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('Show favorite items in sidebar', async ({ page, workspace }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');@@ -39,7 +39,7 @@ test('Show favorite items in sidebar', async ({ page, workspace }) => {test('Show favorite reference in sidebar', async ({ page, workspace }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');@@ -82,7 +82,7 @@ test("Deleted page's reference will not be shown in sidebar", async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');diff --git a/tests/affine-local/e2e/local-first-new-page.spec.ts b/tests/affine-local/e2e/local-first-new-page.spec.tsindex 11a75330e2..0bb9185dd2 100644--- a/tests/affine-local/e2e/local-first-new-page.spec.ts+++ b/tests/affine-local/e2e/local-first-new-page.spec.ts@@ -3,13 +3,13 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('click btn new page', async ({ page, workspace }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const originPageId = page.url().split('/').reverse()[0];await newPage(page);const newPageId = page.url().split('/').reverse()[0];@@ -24,7 +24,7 @@ test('click btn bew page and find it in all pages', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page');diff --git a/tests/affine-local/e2e/local-first-openpage-newtab.spec.ts b/tests/affine-local/e2e/local-first-openpage-newtab.spec.tsindex eaebd1b3ae..158fd4e9a9 100644--- a/tests/affine-local/e2e/local-first-openpage-newtab.spec.ts+++ b/tests/affine-local/e2e/local-first-openpage-newtab.spec.ts@@ -3,13 +3,13 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('click btn bew page and open in tab', async ({ page, workspace }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page');diff --git a/tests/affine-local/e2e/local-first-restore-page.spec.ts b/tests/affine-local/e2e/local-first-restore-page.spec.tsindex a28bfcabb0..a413323958 100644--- a/tests/affine-local/e2e/local-first-restore-page.spec.ts+++ b/tests/affine-local/e2e/local-first-restore-page.spec.ts@@ -3,7 +3,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -12,7 +12,7 @@ test('New a page , then delete it in all pages, restore it', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');diff --git a/tests/affine-local/e2e/local-first-show-delete-modal.spec.ts b/tests/affine-local/e2e/local-first-show-delete-modal.spec.tsindex c58fdebd68..da07ef6c8e 100644--- a/tests/affine-local/e2e/local-first-show-delete-modal.spec.ts+++ b/tests/affine-local/e2e/local-first-show-delete-modal.spec.ts@@ -4,7 +4,7 @@ import {clickPageMoreActions,getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -13,7 +13,7 @@ test('New a page ,then open it and show delete modal', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');@@ -39,7 +39,7 @@ test('New a page ,then go to all pages and show delete modal', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');diff --git a/tests/affine-local/e2e/local-first-trash-page.spec.ts b/tests/affine-local/e2e/local-first-trash-page.spec.tsindex be63f53142..eefe895aa1 100644--- a/tests/affine-local/e2e/local-first-trash-page.spec.ts+++ b/tests/affine-local/e2e/local-first-trash-page.spec.ts@@ -4,7 +4,7 @@ import {clickPageMoreActions,getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -13,7 +13,7 @@ test('New a page , then delete it in all pages, finally find it in trash', asyncworkspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');@@ -49,7 +49,7 @@ test('New a page , then delete it in page, blockHub and option menu will not apppage,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);const title = getBlockSuiteEditorTitle(page);await title.type('test');diff --git a/tests/affine-local/e2e/local-first-workspace-list.spec.ts b/tests/affine-local/e2e/local-first-workspace-list.spec.tsindex aca697fc22..b269c9f945 100644--- a/tests/affine-local/e2e/local-first-workspace-list.spec.ts+++ b/tests/affine-local/e2e/local-first-workspace-list.spec.ts@@ -1,6 +1,6 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';import {createWorkspace,@@ -13,7 +13,7 @@ test('just one item in the workspace list at first', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const workspaceName = page.getByTestId('workspace-name');await workspaceName.click();expect(@@ -32,7 +32,7 @@ test('create one workspace in the workspace list', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const newWorkspaceNameStr = 'New Workspace';await createWorkspace({ name: newWorkspaceNameStr }, page);@@ -66,7 +66,7 @@ test('create multi workspace in the workspace list', async ({workspace,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await createWorkspace({ name: 'New Workspace 2' }, page);await createWorkspace({ name: 'New Workspace 3' }, page);diff --git a/tests/affine-local/e2e/local-first-workspace.spec.ts b/tests/affine-local/e2e/local-first-workspace.spec.tsindex af602c8e99..875b156690 100644--- a/tests/affine-local/e2e/local-first-workspace.spec.ts+++ b/tests/affine-local/e2e/local-first-workspace.spec.ts@@ -1,11 +1,11 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('preset workspace name', async ({ page, workspace }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const workspaceName = page.getByTestId('workspace-name');await page.waitForTimeout(1000);expect(await workspaceName.textContent()).toBe('Demo Workspace');diff --git a/tests/affine-local/e2e/open-affine.spec.ts b/tests/affine-local/e2e/open-affine.spec.tsindex 531dac020c..48d048abed 100644--- a/tests/affine-local/e2e/open-affine.spec.ts+++ b/tests/affine-local/e2e/open-affine.spec.ts@@ -1,14 +1,14 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { createWorkspace } from '@affine-test/kit/utils/workspace';import { expect } from '@playwright/test';test('Open last workspace when back to affine', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await createWorkspace({ name: 'New Workspace 2' }, page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);// show workspace listawait page.getByTestId('workspace-name').click();@@ -46,7 +46,7 @@ test.skip('Download client tip', async ({ page }) => {test('Check the class name for the scrollbar', async ({ page }) => {//Because the scroll bar in page mode depends on the class name of blocksuiteawait openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const affineDocViewport = page.locator('.affine-doc-viewport');await expect(affineDocViewport).toBeVisible();});diff --git a/tests/affine-local/e2e/quick-search.spec.ts b/tests/affine-local/e2e/quick-search.spec.tsindex 5f8ce4e0e5..7bc3c26dd4 100644--- a/tests/affine-local/e2e/quick-search.spec.ts+++ b/tests/affine-local/e2e/quick-search.spec.ts@@ -4,7 +4,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import {getBlockSuiteEditorTitle,newPage,- waitEditorLoad,+ waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect, type Page } from '@playwright/test';@@ -38,7 +38,7 @@ async function titleIsFocused(page: Page) {test('Click slider bar button', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);const quickSearchButton = page.locator('[data-testid=slider-bar-quick-search-button]'@@ -50,7 +50,7 @@ test('Click slider bar button', async ({ page }) => {test('Click arrowDown icon after title', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);const quickSearchButton = page.locator('[data-testid=slider-bar-quick-search-button]'@@ -62,7 +62,7 @@ test('Click arrowDown icon after title', async ({ page }) => {test('Press the shortcut key cmd+k', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);const quickSearch = page.locator('[data-testid=quickSearch]');@@ -71,7 +71,7 @@ test('Press the shortcut key cmd+k', async ({ page }) => {test('Create a new page without keyword', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');@@ -82,7 +82,7 @@ test('Create a new page without keyword', async ({ page }) => {test('Create a new page with keyword', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);await page.keyboard.insertText('test123456');@@ -94,7 +94,7 @@ test('Create a new page with keyword', async ({ page }) => {test('Enter a keyword to search for', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);await page.keyboard.insertText('test123456');@@ -104,7 +104,7 @@ test('Enter a keyword to search for', async ({ page }) => {test('Create a new page and search this page', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);// input title and create new page@@ -124,7 +124,7 @@ test('Create a new page and search this page', async ({ page }) => {await assertTitle(page, 'test123456');await page.reload();- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openQuickSearchByShortcut(page);await page.keyboard.insertText('test123456');await page.waitForTimeout(300);@@ -146,7 +146,7 @@ test('Navigate to the 404 page and try to open quick search', async ({test('Open quick search on local page', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);const publishedSearchResults = page.locator('[publishedSearchResults]');@@ -155,7 +155,7 @@ test('Open quick search on local page', async ({ page }) => {test('Autofocus input after opening quick search', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);const locator = page.locator('[cmdk-input]');@@ -164,7 +164,7 @@ test('Autofocus input after opening quick search', async ({ page }) => {});test('Autofocus input after select', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);await page.keyboard.press('ArrowUp');@@ -174,7 +174,7 @@ test('Autofocus input after select', async ({ page }) => {});test('Focus title after creating a new page', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await newPage(page);await openQuickSearchByShortcut(page);const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');@@ -186,7 +186,7 @@ test('Not show navigation path if page is not a subpage or current page is not ipage,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openQuickSearchByShortcut(page);expect(await page.getByTestId('navigation-path').count()).toBe(0);});@@ -195,7 +195,7 @@ test('assert the recent browse pages are on the recent list', async ({page,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);// create first pageawait newPage(page);@@ -242,7 +242,7 @@ test('assert the recent browse pages are on the recent list', async ({// create forth page, and check does the recent page list only contains three pagesawait page.reload();- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openQuickSearchByShortcut(page);{const addNewPage = page.getByTestId('quick-search-add-new-page');diff --git a/tests/affine-local/e2e/router.spec.ts b/tests/affine-local/e2e/router.spec.tsindex 39477dd6c8..55590169c5 100644--- a/tests/affine-local/e2e/router.spec.ts+++ b/tests/affine-local/e2e/router.spec.ts@@ -1,11 +1,11 @@import { test } from '@affine-test/kit/playwright';import { coreUrl, openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('goto not found page', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const currentUrl = page.url();const invalidUrl = currentUrl.replace('hello-world', 'invalid');await page.goto(invalidUrl);@@ -14,7 +14,7 @@ test('goto not found page', async ({ page }) => {test('goto not found workspace', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);// if doesn't wait for timeout, data won't be saved into indexedDBawait page.waitForTimeout(1000);await page.goto(new URL('/workspace/invalid/all', coreUrl).toString());diff --git a/tests/affine-local/e2e/settings.spec.ts b/tests/affine-local/e2e/settings.spec.tsindex 8cb985ed49..d9bed4880d 100644--- a/tests/affine-local/e2e/settings.spec.ts+++ b/tests/affine-local/e2e/settings.spec.ts@@ -1,6 +1,6 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import {openAboutPanel,openAppearancePanel,@@ -13,7 +13,7 @@ import { expect } from '@playwright/test';test('Open settings modal', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openSettingModal(page);const modal = await page.getByTestId('setting-modal');@@ -22,7 +22,7 @@ test('Open settings modal', async ({ page }) => {test('change language using keyboard', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openSettingModal(page);const locator = page.getByTestId('language-menu-button');@@ -55,7 +55,7 @@ test('change language using keyboard', async ({ page }) => {test('Change theme', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openSettingModal(page);await openAppearancePanel(page);const root = page.locator('html');@@ -75,7 +75,7 @@ test('Change theme', async ({ page }) => {test('Change layout width', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openSettingModal(page);await openAppearancePanel(page);@@ -88,7 +88,7 @@ test('Change layout width', async ({ page }) => {test('Open shortcuts panel', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openSettingModal(page);await openShortcutsPanel(page);const title = await page.getByTestId('keyboard-shortcuts-title');@@ -97,7 +97,7 @@ test('Open shortcuts panel', async ({ page }) => {test('Open plugins panel', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openSettingModal(page);await openPluginsPanel(page);const title = await page.getByTestId('plugins-title');@@ -106,7 +106,7 @@ test('Open plugins panel', async ({ page }) => {test('Open about panel', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await openSettingModal(page);await openAboutPanel(page);const title = await page.getByTestId('about-title');@@ -117,7 +117,7 @@ test('Different workspace should have different name in the setting panel', asynpage,}) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await createWorkspace({ name: 'New Workspace 2' }, page);await createWorkspace({ name: 'New Workspace 3' }, page);await openSettingModal(page);diff --git a/tests/affine-local/e2e/shortcuts.spec.ts b/tests/affine-local/e2e/shortcuts.spec.tsindex 5ff457c537..83642deacf 100644--- a/tests/affine-local/e2e/shortcuts.spec.ts+++ b/tests/affine-local/e2e/shortcuts.spec.ts@@ -1,11 +1,11 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('Open shortcuts modal', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await page.locator('[data-testid=help-island]').click();const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');diff --git a/tests/affine-local/e2e/subpage.spec.ts b/tests/affine-local/e2e/subpage.spec.tsindex 5d52e60084..60bd74e999 100644--- a/tests/affine-local/e2e/subpage.spec.ts+++ b/tests/affine-local/e2e/subpage.spec.ts@@ -1,11 +1,11 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('Create subpage', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await page.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]').click();diff --git a/tests/affine-local/e2e/theme.spec.ts b/tests/affine-local/e2e/theme.spec.tsindex f74be753af..2e4d3c39b2 100644--- a/tests/affine-local/e2e/theme.spec.ts+++ b/tests/affine-local/e2e/theme.spec.ts@@ -2,7 +2,7 @@ import { resolve } from 'node:path';import { test, testResultDir } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';// default could be anything, according to the system@@ -12,7 +12,7 @@ test('default white', async ({ browser }) => {});const page = await context.newPage();await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);const root = page.locator('html');const themeMode = await root.evaluate(element =>element.getAttribute('data-theme')diff --git a/tests/affine-plugin/e2e/basic.spec.ts b/tests/affine-plugin/e2e/basic.spec.tsindex c494fe524c..b6004dff60 100644--- a/tests/affine-plugin/e2e/basic.spec.ts+++ b/tests/affine-plugin/e2e/basic.spec.ts@@ -1,6 +1,6 @@import { test } from '@affine-test/kit/playwright';import { openHomePage, openPluginPage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('plugin map should valid', async ({ page }) => {@@ -10,7 +10,7 @@ test('plugin map should valid', async ({ page }) => {test('plugin should exist', async ({ page }) => {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await page.route('**/plugins/**/package.json', route => route.fetch(), {times: 5,});diff --git a/tests/kit/package.json b/tests/kit/package.jsonindex 2cb24f3821..c9569490ab 100644--- a/tests/kit/package.json+++ b/tests/kit/package.json@@ -8,9 +8,13 @@},"devDependencies": {"@node-rs/argon2": "^1.5.2",- "@playwright/test": "^1.37.1"+ "@playwright/test": "^1.37.1",+ "express": "^4.18.2",+ "http-proxy-middleware": "^3.0.0-beta.1"},"peerDependencies": {- "@playwright/test": "*"+ "@playwright/test": "*",+ "express": "*",+ "http-proxy-middleware": "*"}}diff --git a/tests/kit/utils/cloud.ts b/tests/kit/utils/cloud.tsindex 7e33711ed9..18e9621a8f 100644--- a/tests/kit/utils/cloud.ts+++ b/tests/kit/utils/cloud.ts@@ -1,5 +1,5 @@import { openHomePage } from '@affine-test/kit/utils/load-page';-import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';+import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';import { faker } from '@faker-js/faker';import { hash } from '@node-rs/argon2';@@ -76,7 +76,7 @@ export async function loginUser(}) {await openHomePage(page);- await waitEditorLoad(page);+ await waitForEditorLoad(page);await clickSideBarCurrentWorkspaceBanner(page);await page.getByTestId('cloud-signin-button').click({diff --git a/tests/kit/utils/editor.ts b/tests/kit/utils/editor.tsindex f562fdc883..4a2425605d 100644--- a/tests/kit/utils/editor.ts+++ b/tests/kit/utils/editor.ts@@ -10,3 +10,15 @@ export async function checkBlockHub(page: Page) {if (!box2) throw new Error('block-hub not found');expect(box2.height).toBeGreaterThan(box.height);}++export async function clickEdgelessModeButton(page: Page) {+ await page.getByTestId('switch-edgeless-mode-button').click({+ delay: 50,+ });+}++export async function clickPageModeButton(page: Page) {+ return page.getByTestId('switch-page-mode-button').click({+ delay: 50,+ });+}diff --git a/tests/kit/utils/page-logic.ts b/tests/kit/utils/page-logic.tsindex aab8ffacd1..771e89fb40 100644--- a/tests/kit/utils/page-logic.ts+++ b/tests/kit/utils/page-logic.ts@@ -1,7 +1,7 @@import type { Page } from '@playwright/test';import { expect } from '@playwright/test';-export async function waitEditorLoad(page: Page) {+export async function waitForEditorLoad(page: Page) {await page.waitForSelector('v-line', {timeout: 10000,});@@ -19,7 +19,7 @@ export async function newPage(page: Page) {await page.getByTestId('new-page-button').click({delay: 100,});- await waitEditorLoad(page);+ await waitForEditorLoad(page);}export function getBlockSuiteEditorTitle(page: Page) {@@ -30,11 +30,6 @@ export async function type(page: Page, content: string, delay = 50) {await page.keyboard.type(content, { delay });}-export async function pressEnter(page: Page) {- // avoid flaky test by simulate real user input- await page.keyboard.press('Enter', { delay: 50 });-}-export const createLinkedPage = async (page: Page, pageName?: string) => {await page.keyboard.type('@', { delay: 50 });const linkedPagePopover = page.locator('.linked-page-popover');diff --git a/tests/kit/utils/proxy.ts b/tests/kit/utils/proxy.tsnew file mode 100644index 0000000000..9222c3789d--- /dev/null+++ b/tests/kit/utils/proxy.ts@@ -0,0 +1,62 @@+import type Test from '@playwright/test';+import type { BrowserContext } from '@playwright/test';+import express from 'express';+import { createProxyMiddleware } from 'http-proxy-middleware';++import { waitForEditorLoad } from './page-logic';++export async function check8080Available(context: BrowserContext) {+ // make sure 8080 is ready+ const page = await context.newPage();+ await page.goto('http://localhost:8080/');+ await waitForEditorLoad(page);+ await page.close();+}++export function setupProxyServer(test: typeof Test, dir: string) {+ let app: express.Express;+ let server: ReturnType<express.Express['listen']>;+ test.beforeEach(() => {+ app = express();+ app.use(express.static(dir));+ server = app.listen(8081);+ });++ test.afterEach(() => {+ server.close();+ });++ return {+ get app() {+ return app;+ },+ get server() {+ return server;+ },+ switchToNext: async function () {+ // 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();+ });+ });+ },+ };+}diff --git a/yarn.lock b/yarn.lockindex c035c2a8dc..f151107516 100644--- a/yarn.lock+++ b/yarn.lock@@ -105,8 +105,12 @@ __metadata:dependencies:"@node-rs/argon2": ^1.5.2"@playwright/test": ^1.37.1+ express: ^4.18.2+ http-proxy-middleware: ^3.0.0-beta.1peerDependencies:"@playwright/test": "*"+ express: "*"+ http-proxy-middleware: "*"languageName: unknownlinkType: soft