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: fix flaky on `local-first-workspace-list.spec.ts` (#2727)
Himself6527b14af388e1
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 825e2bd97a..5ac85b6c01 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -91,6 +91,7 @@ jobs:ENABLE_PLUGIN: trueENABLE_ALL_PAGE_FILTER: trueENABLE_LEGACY_PROVIDER: true+ ENABLE_PRELOADING: falseCOVERAGE: true- name: Upload artifact@@ -115,6 +116,7 @@ jobs:ENABLE_PLUGIN: trueENABLE_ALL_PAGE_FILTER: trueENABLE_LEGACY_PROVIDER: false+ ENABLE_PRELOADING: falseCOVERAGE: true- name: Export static resourcesdiff --git a/apps/web/src/layouts/workspace-layout.tsx b/apps/web/src/layouts/workspace-layout.tsxindex 8e54fd4785..8523910146 100644--- a/apps/web/src/layouts/workspace-layout.tsx+++ b/apps/web/src/layouts/workspace-layout.tsx@@ -308,7 +308,9 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {assertEquals(page.id, pageId);setEditorFlags(currentWorkspace.blockSuiteWorkspace);if (config.enablePreloading) {- initPageWithPreloading(page);+ initPageWithPreloading(page).catch(error => {+ console.error('import error:', error);+ });} else {initEmptyPage(page);}@@ -333,30 +335,19 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {};}, [currentWorkspace]);- useEffect(() => {- if (!currentWorkspace) {- return;- }- const page = currentWorkspace.blockSuiteWorkspace.getPage(- DEFAULT_HELLO_WORLD_PAGE_ID+ const page = currentWorkspace.blockSuiteWorkspace.getPage(+ DEFAULT_HELLO_WORLD_PAGE_ID+ );+ if (page && page.meta.jumpOnce) {+ currentWorkspace.blockSuiteWorkspace.meta.setPageMeta(+ DEFAULT_HELLO_WORLD_PAGE_ID,+ {+ jumpOnce: false,+ });- if (page && page.meta.jumpOnce) {- currentWorkspace.blockSuiteWorkspace.meta.setPageMeta(- DEFAULT_HELLO_WORLD_PAGE_ID,- {- jumpOnce: false,- }- );- setCurrentPageId(currentPageId);- void jumpToPage(currentWorkspace.id, page.id);- }- }, [- currentPageId,- currentWorkspace,- jumpToPage,- router.query.pageId,- setCurrentPageId,- ]);+ setCurrentPageId(currentPageId);+ void jumpToPage(currentWorkspace.id, page.id);+ }const { openPage } = useRouterHelper(router);const [, setOpenWorkspacesModal] = useAtom(openWorkspacesModalAtom);diff --git a/tests/parallels/affine/affine-public-workspace.spec.ts b/tests/parallels/affine/affine-public-workspace.spec.tsindex 717add589c..43867f036d 100644--- a/tests/parallels/affine/affine-public-workspace.spec.ts+++ b/tests/parallels/affine/affine-public-workspace.spec.ts@@ -38,7 +38,7 @@ test('enable public workspace', async ({ page, context }) => {await page2.waitForSelector('thead', {timeout: 10000,});- await page2.getByText('AFFiNE - not just a note taking app').click();+ await page2.getByText('Untitled').click();});test('access public workspace page', async ({ page, browser }) => {diff --git a/tests/parallels/drag-page-to-trash-folder.spec.ts b/tests/parallels/drag-page-to-trash-folder.spec.tsindex c74c3c1deb..51a023d422 100644--- a/tests/parallels/drag-page-to-trash-folder.spec.ts+++ b/tests/parallels/drag-page-to-trash-folder.spec.ts@@ -17,7 +17,7 @@ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar t// Drag-and-drop// Ref: https://playwright.dev/docs/input#dragging-manually- await page.getByText('AFFiNE - not just a note taking app').hover();+ await page.getByText('Untitled').hover();await page.mouse.down();await page.waitForTimeout(1000);await page.getByText('Trash').hover();@@ -29,7 +29,7 @@ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar t).toBeVisible();await expect(- page.getByText('AFFiNE - not just a note taking app'),+ page.getByText('Untitled'),'The deleted post is no longer on the All Page list').toHaveCount(0);@@ -37,7 +37,7 @@ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar t// Visit trash page via urlawait page.getByText('Trash', { exact: true }).click();await expect(- page.getByText('AFFiNE - not just a note taking app'),+ page.getByText('Untitled'),'The deleted post exists in the Trash list').toHaveCount(1);});diff --git a/tests/parallels/local-first-workspace-list.spec.ts b/tests/parallels/local-first-workspace-list.spec.tsindex 06a5674c16..43d847031b 100644--- a/tests/parallels/local-first-workspace-list.spec.ts+++ b/tests/parallels/local-first-workspace-list.spec.ts@@ -103,14 +103,21 @@ test('create multi workspace in the workspace list', async ({ page }) => {await page.reload();await openWorkspaceListModal(page);- //check workspace list length+ // check workspace list length{const workspaceCards1 = await page.$$('data-testid=workspace-card');expect(workspaceCards1.length).toBe(3);}+ const workspaceChangePromise = page.evaluate(() => {+ new Promise(resolve => {+ window.addEventListener('affine:workspace:change', resolve, {+ once: true,+ });+ });+ });await page.getByTestId('draggable-item').nth(2).click();- await page.waitForTimeout(100);+ await workspaceChangePromise;// @ts-expect-errorconst nextId: string = await page.evaluate(() => currentWorkspace.id);