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: cover share page e2e (#4126)
Alex Yang4f97ea8a5d7c
diff --git a/apps/server/src/modules/workspaces/permission.ts b/apps/server/src/modules/workspaces/permission.tsindex 2c2b82c06c..c35e65815a 100644--- a/apps/server/src/modules/workspaces/permission.ts+++ b/apps/server/src/modules/workspaces/permission.ts@@ -48,7 +48,11 @@ export class PermissionService {return true;} else {// check if this is a public subpage- return subpages.map(page => `space:${page}`).includes(id);++ // why use `endsWith`?+ // because there might have `${wsId}:space:${subpageId}`,+ // but subpages only have `${subpageId}`+ return subpages.some(subpage => id.endsWith(subpage));}}}diff --git a/packages/component/src/components/share-menu/share-menu.tsx b/packages/component/src/components/share-menu/share-menu.tsxindex 61dc87f328..c64c75b01f 100644--- a/packages/component/src/components/share-menu/share-menu.tsx+++ b/packages/component/src/components/share-menu/share-menu.tsx@@ -9,6 +9,7 @@ import type { Page } from '@blocksuite/store';import { Button } from '@toeverything/components/button';import { Divider } from '@toeverything/components/divider';import { useAtom } from 'jotai';+import { useCallback } from 'react';import { Menu } from '../../ui/menu/menu';import * as styles from './index.css';@@ -62,15 +63,15 @@ export const ShareMenu = (props: ShareMenuProps) => {trigger={['click']}width={410}disablePortal={true}- onClickAway={() => {+ onClickAway={useCallback(() => {setOpen(false);- }}+ }, [setOpen])}><Buttondata-testid="share-menu-button"- onClick={() => {- setOpen(!open);- }}+ onClick={useCallback(() => {+ setOpen(value => !value);+ }, [setOpen])}type={'plain'}><divdiff --git a/packages/component/src/components/share-menu/share-page.tsx b/packages/component/src/components/share-menu/share-page.tsxindex e97223dec3..7581a1d0f1 100644--- a/packages/component/src/components/share-menu/share-page.tsx+++ b/packages/component/src/components/share-menu/share-page.tsx@@ -132,13 +132,18 @@ export const AffineSharePage = (props: ShareMenuProps) => {readOnly/>{isPublic ? (- <Button onClick={onClickCopyLink} style={{ padding: '4px 12px' }}>+ <Button+ onClick={onClickCopyLink}+ data-testid="share-menu-copy-link-button"+ style={{ padding: '4px 12px' }}+ >{t.Copy()}</Button>) : (<ButtononClick={onClickCreateLink}type="primary"+ data-testid="share-menu-create-link-button"style={{ padding: '4px 12px' }}>{t.Create()}diff --git a/tests/affine-cloud/e2e/collaboration.spec.ts b/tests/affine-cloud/e2e/collaboration.spec.tsnew file mode 100644index 0000000000..47864a0456--- /dev/null+++ b/tests/affine-cloud/e2e/collaboration.spec.ts@@ -0,0 +1,70 @@+import { test } from '@affine-test/kit/playwright';+import { createRandomUser, loginUser } from '@affine-test/kit/utils/cloud';+import {+ clickNewPageButton,+ getBlockSuiteEditorTitle,+ waitForEditorLoad,+} from '@affine-test/kit/utils/page-logic';+import { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';+import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';+import { expect } from '@playwright/test';++let user: {+ name: string;+ email: string;+ password: string;+};++test.beforeEach(async () => {+ user = await createRandomUser();+});++test.beforeEach(async ({ page }) => {+ await loginUser(page, user);+});++test.describe('collaboration', () => {+ test('can enable share page', async ({ page, browser }) => {+ await page.reload();+ await waitForEditorLoad(page);+ await createLocalWorkspace(+ {+ name: 'test',+ },+ page+ );+ await clickSideBarSettingButton(page);+ await page.getByTestId('current-workspace-label').click();+ await page.getByTestId('publish-enable-affine-cloud-button').click();+ await page.getByTestId('confirm-enable-affine-cloud-button').click();+ // wait for upload and delete local workspace+ await page.waitForTimeout(2000);+ await waitForEditorLoad(page);+ await clickNewPageButton(page);+ const title = getBlockSuiteEditorTitle(page);+ await title.type('TEST TITLE', {+ delay: 50,+ });+ await page.keyboard.press('Enter', { delay: 50 });+ await page.keyboard.type('TEST CONTENT', { delay: 50 });+ await page.getByTestId('share-menu-button').click();+ await page.getByTestId('share-menu-create-link-button').click();+ await page.getByTestId('share-menu-copy-link-button').click();++ // check share page is accessible+ {+ const context = await browser.newContext();+ const url: string = await page.evaluate(() =>+ navigator.clipboard.readText()+ );+ const page2 = await context.newPage();+ await page2.goto(url);+ await waitForEditorLoad(page2);+ const title = getBlockSuiteEditorTitle(page2);+ expect(await title.innerText()).toBe('TEST TITLE');+ expect(await page2.textContent('affine-paragraph')).toContain(+ 'TEST CONTENT'+ );+ }+ });+});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 55fde1fc3a..7c0ef5925f 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,7 +1,10 @@import { resolve } from 'node:path';import { test } from '@affine-test/kit/playwright';-import { newPage, waitForEditorLoad } from '@affine-test/kit/utils/page-logic';+import {+ clickNewPageButton,+ waitForEditorLoad,+} from '@affine-test/kit/utils/page-logic';import {check8080Available,setupProxyServer,@@ -17,7 +20,7 @@ test('init page', async ({ page, context }) => {await check8080Available(context);await page.goto('http://localhost:8081/');await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const locator = page.locator('v-line').nth(0);await locator.fill('hello');diff --git a/tests/affine-local/e2e/all-page.spec.ts b/tests/affine-local/e2e/all-page.spec.tsindex 02d903fa4a..061392eed0 100644--- a/tests/affine-local/e2e/all-page.spec.ts+++ b/tests/affine-local/e2e/all-page.spec.ts@@ -15,8 +15,8 @@ import {} from '@affine-test/kit/utils/filter';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,waitForAllPagesLoad,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';@@ -88,7 +88,7 @@ test('allow creation of filters by favorite', async ({ page }) => {test('allow creation of filters by created time', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await clickSideBarAllPageButton(page);await waitForAllPagesLoad(page);const pages = await page.locator('[data-testid="title"]').all();@@ -123,7 +123,7 @@ test('creation of filters by created time, then click date picker to modify the}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await clickSideBarAllPageButton(page);await waitForAllPagesLoad(page);const pages = await page.locator('[data-testid="title"]').all();diff --git a/tests/affine-local/e2e/blocksuite/editor.spec.ts b/tests/affine-local/e2e/blocksuite/editor.spec.tsindex 651768d7ef..8166236a88 100644--- a/tests/affine-local/e2e/blocksuite/editor.spec.ts+++ b/tests/affine-local/e2e/blocksuite/editor.spec.ts@@ -1,8 +1,8 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import type { Page } from '@playwright/test';@@ -20,7 +20,7 @@ const addDatabase = async (page: Page) => {test('database is useable', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await waitForEditorLoad(page);const title = getBlockSuiteEditorTitle(page);await title.type('test title');@@ -31,7 +31,7 @@ test('database is useable', async ({ page }) => {await expect(database).toBeVisible();await page.reload();await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await waitForEditorLoad(page);const title2 = getBlockSuiteEditorTitle(page);await title2.type('test title2');@@ -46,13 +46,13 @@ test('database is useable', async ({ page }) => {test('link page is useable', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(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 clickNewPageButton(page);await waitForEditorLoad(page);const title2 = await getBlockSuiteEditorTitle(page);await title2.type('page2');diff --git a/tests/affine-local/e2e/duplicate-page.spec.ts b/tests/affine-local/e2e/duplicate-page.spec.tsindex 9df4f54906..c5f3675f54 100644--- a/tests/affine-local/e2e/duplicate-page.spec.ts+++ b/tests/affine-local/e2e/duplicate-page.spec.ts@@ -1,9 +1,9 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,clickPageMoreActions,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -11,7 +11,7 @@ import { expect } from '@playwright/test';test('Duplicate page should work', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const title = getBlockSuiteEditorTitle(page);await title.type('test');await clickPageMoreActions(page);diff --git a/tests/affine-local/e2e/image-preview.spec.ts b/tests/affine-local/e2e/image-preview.spec.tsindex 70bafb4195..a1b8317b5e 100644--- a/tests/affine-local/e2e/image-preview.spec.ts+++ b/tests/affine-local/e2e/image-preview.spec.ts@@ -1,7 +1,7 @@import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import type { Page } from '@playwright/test';@@ -43,7 +43,7 @@ async function closeImagePreviewModal(page: Page) {test('image preview should be shown', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const title = await getBlockSuiteEditorTitle(page);await title.click();await page.keyboard.press('Enter');@@ -58,7 +58,7 @@ test('image preview should be shown', async ({ page }) => {test('image go left and right', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -105,7 +105,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 waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -158,7 +158,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 waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -204,7 +204,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 waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -258,7 +258,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 waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -315,7 +315,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 waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -368,7 +368,7 @@ test('image able to reset zoom to 100%', async ({ page }) => {test('image able to copy to clipboard', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -395,7 +395,7 @@ test('image able to copy to clipboard', async ({ page }) => {test('image able to download', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -427,7 +427,7 @@ test('image should only able to move when image is larger than viewport', async}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -484,7 +484,7 @@ test('image should able to delete and when delete, it will move to previous/next}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -559,7 +559,7 @@ test('tooltips for all buttons should be visible when hovering', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);let blobId: string;{const title = await getBlockSuiteEditorTitle(page);@@ -654,7 +654,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 waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const title = await getBlockSuiteEditorTitle(page);await title.click();await page.keyboard.press('Enter');@@ -672,7 +672,7 @@ test('when mouse moves outside, the modal should be closed', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const title = await getBlockSuiteEditorTitle(page);await title.click();await page.keyboard.press('Enter');@@ -693,7 +693,7 @@ test('caption should be visible and different styles were applied if image zoomeconst sampleCaption = 'affine owns me and all';await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const title = await getBlockSuiteEditorTitle(page);await title.click();await page.keyboard.press('Enter');diff --git a/tests/affine-local/e2e/local-first-avatar.spec.ts b/tests/affine-local/e2e/local-first-avatar.spec.tsindex 063b1d52d2..44e27770f9 100644--- a/tests/affine-local/e2e/local-first-avatar.spec.ts+++ b/tests/affine-local/e2e/local-first-avatar.spec.ts@@ -2,7 +2,10 @@ import { resolve } from 'node:path';import { rootDir, test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';-import { newPage, waitForEditorLoad } from '@affine-test/kit/utils/page-logic';+import {+ clickNewPageButton,+ waitForEditorLoad,+} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';test('should create a page with a local first avatar', async ({@@ -11,7 +14,7 @@ test('should create a page with a local first avatar', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await page.getByTestId('workspace-name').click();await page.getByTestId('new-workspace').click({ delay: 50 });await pagediff --git a/tests/affine-local/e2e/local-first-collections-items.spec.ts b/tests/affine-local/e2e/local-first-collections-items.spec.tsindex 8451d0de71..53596a9bf4 100644--- a/tests/affine-local/e2e/local-first-collections-items.spec.ts+++ b/tests/affine-local/e2e/local-first-collections-items.spec.ts@@ -5,8 +5,8 @@ import {} from '@affine-test/kit/utils/filter';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import type { Page } from '@playwright/test';@@ -20,7 +20,7 @@ const createAndPinCollection = async () => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('test page');await page.getByTestId('all-pages').click();@@ -141,7 +141,7 @@ test('edit collection and change filter date', async ({ page }) => {test('create temporary filter by click tag', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('test page');await page.locator('affine-page-meta-data').click();@@ -163,7 +163,7 @@ test('create temporary filter by click tag', async ({ page }) => {test('add collection from sidebar', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('test page');await page.getByTestId('all-pages').click();diff --git a/tests/affine-local/e2e/local-first-delete-page.spec.ts b/tests/affine-local/e2e/local-first-delete-page.spec.tsindex 89daf71a43..aed262384a 100644--- a/tests/affine-local/e2e/local-first-delete-page.spec.ts+++ b/tests/affine-local/e2e/local-first-delete-page.spec.ts@@ -1,8 +1,8 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -13,7 +13,7 @@ test('page delete -> refresh page -> it should be disappear', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page delete');const newPageId = page.url().split('/').reverse()[0];@@ -56,7 +56,7 @@ test('page delete -> create new page -> refresh page -> new page should be appea}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page delete');const newPageDeleteId = page.url().split('/').reverse()[0];@@ -87,12 +87,12 @@ test('page delete -> create new page -> refresh page -> new page should be appeaexpect(page.getByText("There's no page here yet")).not.toBeUndefined();await page.getByTestId('all-pages').click();- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page1');const newPageId1 = page.url().split('/').reverse()[0];await page.getByTestId('all-pages').click();- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page2');const newPageId2 = page.url().split('/').reverse()[0];@@ -115,13 +115,13 @@ test('delete multiple pages -> create multiple pages -> refresh', async ({await openHomePage(page);await waitForEditorLoad(page);// create 1st page- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page1');const newPageId1 = page.url().split('/').reverse()[0];await page.getByTestId('all-pages').click();// create 2nd page- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page2');const newPageId2 = page.url().split('/').reverse()[0];diff --git a/tests/affine-local/e2e/local-first-export-page.spec.ts b/tests/affine-local/e2e/local-first-export-page.spec.tsindex 0c97859e5c..d592860392 100644--- a/tests/affine-local/e2e/local-first-export-page.spec.ts+++ b/tests/affine-local/e2e/local-first-export-page.spec.ts@@ -1,9 +1,9 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,clickPageMoreActions,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -14,7 +14,7 @@ test.skip('New a page ,then open it and export html', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await page.getByPlaceholder('Title')@@ -48,7 +48,7 @@ test.skip('New a page ,then open it and export markdown', async ({page,workspace,}) => {- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await page.getByPlaceholder('Title')diff --git a/tests/affine-local/e2e/local-first-favorite-page.spec.ts b/tests/affine-local/e2e/local-first-favorite-page.spec.tsindex ebc24fa1f6..92d08c2b91 100644--- a/tests/affine-local/e2e/local-first-favorite-page.spec.ts+++ b/tests/affine-local/e2e/local-first-favorite-page.spec.ts@@ -1,9 +1,9 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,clickPageMoreActions,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { waitForLogMessage } from '@affine-test/kit/utils/utils';@@ -15,7 +15,7 @@ test('New a page and open it ,then favorite it', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');await page.getByTestId('all-pages').click();@@ -81,7 +81,7 @@ test.skip('Export to pdf', async ({ page }) => {test('Cancel favorite', async ({ page, workspace }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');await page.getByTestId('all-pages').click();diff --git a/tests/affine-local/e2e/local-first-favorites-items.spec.ts b/tests/affine-local/e2e/local-first-favorites-items.spec.tsindex 1938fab0a6..e4e66fcce8 100644--- a/tests/affine-local/e2e/local-first-favorites-items.spec.ts+++ b/tests/affine-local/e2e/local-first-favorites-items.spec.ts@@ -1,10 +1,10 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,clickPageMoreActions,createLinkedPage,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -12,7 +12,7 @@ import { expect } from '@playwright/test';test('Show favorite items in sidebar', async ({ page, workspace }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');const newPageId = page.url().split('/').reverse()[0];@@ -40,7 +40,7 @@ test('Show favorite items in sidebar', async ({ page, workspace }) => {test('Show favorite reference in sidebar', async ({ page, workspace }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');@@ -83,7 +83,7 @@ test("Deleted page's reference will not be shown in sidebar", async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(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 0bb9185dd2..44cbca9f18 100644--- a/tests/affine-local/e2e/local-first-new-page.spec.ts+++ b/tests/affine-local/e2e/local-first-new-page.spec.ts@@ -1,8 +1,8 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -11,7 +11,7 @@ test('click btn new page', async ({ page, workspace }) => {await openHomePage(page);await waitForEditorLoad(page);const originPageId = page.url().split('/').reverse()[0];- await newPage(page);+ await clickNewPageButton(page);const newPageId = page.url().split('/').reverse()[0];expect(newPageId).not.toBe(originPageId);const currentWorkspace = await workspace.current();@@ -25,7 +25,7 @@ test('click btn bew page and find it in all pages', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page');await page.getByTestId('all-pages').click();diff --git a/tests/affine-local/e2e/local-first-openpage-newtab.spec.ts b/tests/affine-local/e2e/local-first-openpage-newtab.spec.tsindex 158fd4e9a9..59da8aa440 100644--- a/tests/affine-local/e2e/local-first-openpage-newtab.spec.ts+++ b/tests/affine-local/e2e/local-first-openpage-newtab.spec.ts@@ -1,8 +1,8 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -10,7 +10,7 @@ import { expect } from '@playwright/test';test('click btn bew page and open in tab', async ({ page, workspace }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page');const newPageUrl = page.url();diff --git a/tests/affine-local/e2e/local-first-restore-page.spec.ts b/tests/affine-local/e2e/local-first-restore-page.spec.tsindex a413323958..bfdf1e57e4 100644--- a/tests/affine-local/e2e/local-first-restore-page.spec.ts+++ b/tests/affine-local/e2e/local-first-restore-page.spec.ts@@ -1,8 +1,8 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,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, restore it', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');const newPageId = page.url().split('/').reverse()[0];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 da07ef6c8e..fcc8a8fc08 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@@ -1,9 +1,9 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,clickPageMoreActions,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -14,7 +14,7 @@ test('New a page ,then open it and show delete modal', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');await page.getByTestId('all-pages').click();@@ -40,7 +40,7 @@ test('New a page ,then go to all pages and show delete modal', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');const newPageId = page.url().split('/').reverse()[0];diff --git a/tests/affine-local/e2e/local-first-trash-page.spec.ts b/tests/affine-local/e2e/local-first-trash-page.spec.tsindex eefe895aa1..d8a186628a 100644--- a/tests/affine-local/e2e/local-first-trash-page.spec.ts+++ b/tests/affine-local/e2e/local-first-trash-page.spec.ts@@ -1,9 +1,9 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,clickPageMoreActions,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect } from '@playwright/test';@@ -14,7 +14,7 @@ test('New a page , then delete it in all pages, finally find it in trash', async}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');const newPageId = page.url().split('/').reverse()[0];@@ -50,7 +50,7 @@ test('New a page , then delete it in page, blockHub and option menu will not app}) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const title = getBlockSuiteEditorTitle(page);await title.type('test');await clickPageMoreActions(page);diff --git a/tests/affine-local/e2e/local-first-workspace-list.spec.ts b/tests/affine-local/e2e/local-first-workspace-list.spec.tsindex b269c9f945..ae755df440 100644--- a/tests/affine-local/e2e/local-first-workspace-list.spec.ts+++ b/tests/affine-local/e2e/local-first-workspace-list.spec.ts@@ -3,7 +3,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';import {- createWorkspace,+ createLocalWorkspace,openWorkspaceListModal,} from '@affine-test/kit/utils/workspace';import { expect } from '@playwright/test';@@ -34,7 +34,7 @@ test('create one workspace in the workspace list', async ({await openHomePage(page);await waitForEditorLoad(page);const newWorkspaceNameStr = 'New Workspace';- await createWorkspace({ name: newWorkspaceNameStr }, page);+ await createLocalWorkspace({ name: newWorkspaceNameStr }, page);// check new workspace nameconst newWorkspaceName = page.getByTestId('workspace-name');@@ -67,8 +67,8 @@ test('create multi workspace in the workspace list', async ({}) => {await openHomePage(page);await waitForEditorLoad(page);- await createWorkspace({ name: 'New Workspace 2' }, page);- await createWorkspace({ name: 'New Workspace 3' }, page);+ await createLocalWorkspace({ name: 'New Workspace 2' }, page);+ await createLocalWorkspace({ name: 'New Workspace 3' }, page);// show workspace listconst workspaceName = page.getByTestId('workspace-name');diff --git a/tests/affine-local/e2e/open-affine.spec.ts b/tests/affine-local/e2e/open-affine.spec.tsindex 48d048abed..9c80920342 100644--- a/tests/affine-local/e2e/open-affine.spec.ts+++ b/tests/affine-local/e2e/open-affine.spec.ts@@ -1,13 +1,13 @@import { test } from '@affine-test/kit/playwright';import { openHomePage } from '@affine-test/kit/utils/load-page';import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';-import { createWorkspace } from '@affine-test/kit/utils/workspace';+import { createLocalWorkspace } 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 waitForEditorLoad(page);- await createWorkspace({ name: 'New Workspace 2' }, page);+ await createLocalWorkspace({ name: 'New Workspace 2' }, page);await waitForEditorLoad(page);// show workspace listawait page.getByTestId('workspace-name').click();diff --git a/tests/affine-local/e2e/quick-search.spec.ts b/tests/affine-local/e2e/quick-search.spec.tsindex 7bc3c26dd4..7319ef1e76 100644--- a/tests/affine-local/e2e/quick-search.spec.ts+++ b/tests/affine-local/e2e/quick-search.spec.ts@@ -2,8 +2,8 @@ import { test } from '@affine-test/kit/playwright';import { withCtrlOrMeta } from '@affine-test/kit/utils/keyboard';import { openHomePage } from '@affine-test/kit/utils/load-page';import {+ clickNewPageButton,getBlockSuiteEditorTitle,- newPage,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';import { expect, type Page } from '@playwright/test';@@ -39,7 +39,7 @@ async function titleIsFocused(page: Page) {test('Click slider bar button', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const quickSearchButton = page.locator('[data-testid=slider-bar-quick-search-button]');@@ -51,7 +51,7 @@ test('Click slider bar button', async ({ page }) => {test('Click arrowDown icon after title', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);const quickSearchButton = page.locator('[data-testid=slider-bar-quick-search-button]');@@ -63,7 +63,7 @@ test('Click arrowDown icon after title', async ({ page }) => {test('Press the shortcut key cmd+k', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);const quickSearch = page.locator('[data-testid=quickSearch]');await expect(quickSearch).toBeVisible();@@ -72,7 +72,7 @@ test('Press the shortcut key cmd+k', async ({ page }) => {test('Create a new page without keyword', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');await addNewPage.click();@@ -83,7 +83,7 @@ test('Create a new page without keyword', async ({ page }) => {test('Create a new page with keyword', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);await page.keyboard.insertText('test123456');const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');@@ -95,7 +95,7 @@ test('Create a new page with keyword', async ({ page }) => {test('Enter a keyword to search for', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);await page.keyboard.insertText('test123456');const actual = await page.locator('[cmdk-input]').inputValue();@@ -105,7 +105,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 waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);// input title and create new pageawait page.keyboard.insertText('test123456');@@ -147,7 +147,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 waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);const publishedSearchResults = page.locator('[publishedSearchResults]');await expect(publishedSearchResults).toBeVisible({ visible: false });@@ -156,7 +156,7 @@ test('Open quick search on local page', async ({ page }) => {test('Autofocus input after opening quick search', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);const locator = page.locator('[cmdk-input]');await expect(locator).toBeVisible();@@ -165,7 +165,7 @@ test('Autofocus input after opening quick search', async ({ page }) => {test('Autofocus input after select', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);await page.keyboard.press('ArrowUp');const locator = page.locator('[cmdk-input]');@@ -175,7 +175,7 @@ test('Autofocus input after select', async ({ page }) => {test('Focus title after creating a new page', async ({ page }) => {await openHomePage(page);await waitForEditorLoad(page);- await newPage(page);+ await clickNewPageButton(page);await openQuickSearchByShortcut(page);const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');await addNewPage.click();@@ -198,7 +198,7 @@ test('assert the recent browse pages are on the recent list', async ({await waitForEditorLoad(page);// create first page- await newPage(page);+ await clickNewPageButton(page);{const title = getBlockSuiteEditorTitle(page);await title.type('sgtokidoki', {diff --git a/tests/affine-local/e2e/settings.spec.ts b/tests/affine-local/e2e/settings.spec.tsindex d9bed4880d..a522dd7e15 100644--- a/tests/affine-local/e2e/settings.spec.ts+++ b/tests/affine-local/e2e/settings.spec.ts@@ -8,7 +8,7 @@ import {openSettingModal,openShortcutsPanel,} from '@affine-test/kit/utils/setting';-import { createWorkspace } from '@affine-test/kit/utils/workspace';+import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';import { expect } from '@playwright/test';test('Open settings modal', async ({ page }) => {@@ -118,8 +118,8 @@ test('Different workspace should have different name in the setting panel', asyn}) => {await openHomePage(page);await waitForEditorLoad(page);- await createWorkspace({ name: 'New Workspace 2' }, page);- await createWorkspace({ name: 'New Workspace 3' }, page);+ await createLocalWorkspace({ name: 'New Workspace 2' }, page);+ await createLocalWorkspace({ name: 'New Workspace 3' }, page);await openSettingModal(page);await page.getByTestId('current-workspace-label').click();expect(await page.getByTestId('workspace-name-input').inputValue()).toBe(diff --git a/tests/kit/utils/filter.ts b/tests/kit/utils/filter.tsindex 6282917acb..bcb3a204c0 100644--- a/tests/kit/utils/filter.ts+++ b/tests/kit/utils/filter.ts@@ -1,7 +1,7 @@import type { Page } from '@playwright/test';import { expect } from '@playwright/test';-import { getBlockSuiteEditorTitle, newPage } from './page-logic';+import { clickNewPageButton, getBlockSuiteEditorTitle } from './page-logic';const monthNames = ['Jan',@@ -189,7 +189,7 @@ export const createPageWithTag = async (}) => {await page.getByTestId('all-pages').click();- await newPage(page);+ await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('test page');await page.locator('affine-page-meta-data').click();diff --git a/tests/kit/utils/page-logic.ts b/tests/kit/utils/page-logic.tsindex 771e89fb40..62f56f3090 100644--- a/tests/kit/utils/page-logic.ts+++ b/tests/kit/utils/page-logic.ts@@ -14,7 +14,7 @@ export async function waitForAllPagesLoad(page: Page) {});}-export async function newPage(page: Page) {+export async function clickNewPageButton(page: Page) {// fixme(himself65): if too fast, the page will crashawait page.getByTestId('new-page-button').click({delay: 100,diff --git a/tests/kit/utils/workspace.ts b/tests/kit/utils/workspace.tsindex c5dba9ee77..a5d8fc23ec 100644--- a/tests/kit/utils/workspace.ts+++ b/tests/kit/utils/workspace.ts@@ -5,11 +5,12 @@ interface CreateWorkspaceParams {}export async function openWorkspaceListModal(page: Page) {- const workspaceName = page.getByTestId('workspace-name');- await workspaceName.click();+ await page.getByTestId('workspace-name').click({+ delay: 50,+ });}-export async function createWorkspace(+export async function createLocalWorkspace(params: CreateWorkspaceParams,page: Page) {