From 9aafaf865e22b2b50f73550750820ec1b28a7308 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 18 Sep 2023 21:08:35 -0500 Subject: [PATCH] test(electron): fix cloud test (#4411) --- apps/core/src/pages/workspace/all-page.tsx | 15 ++++++--------- tests/affine-desktop-cloud/e2e/basic.spec.ts | 6 +++++- tests/kit/utils/cloud.ts | 7 +++++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/core/src/pages/workspace/all-page.tsx b/apps/core/src/pages/workspace/all-page.tsx index bf5ebc9301..982e006186 100644 --- a/apps/core/src/pages/workspace/all-page.tsx +++ b/apps/core/src/pages/workspace/all-page.tsx @@ -1,5 +1,4 @@ import { useCollectionManager } from '@affine/component/page-list'; -import { DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX } from '@affine/env/constant'; import { WorkspaceSubPath } from '@affine/env/workspace'; import { assertExists } from '@blocksuite/global/utils'; import { getActiveBlockSuiteWorkspaceAtom } from '@toeverything/infra/__internal__/workspace'; @@ -20,14 +19,12 @@ export const loader: LoaderFunction = async args => { const workspaceAtom = getActiveBlockSuiteWorkspaceAtom(workspaceId); const workspace = await rootStore.get(workspaceAtom); for (const pageId of workspace.pages.keys()) { - if (pageId.endsWith(DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX)) { - const page = workspace.getPage(pageId); - if (page && page.meta.jumpOnce) { - workspace.meta.setPageMeta(page.id, { - jumpOnce: false, - }); - return redirect(`/workspace/${workspace.id}/${page.id}`); - } + const page = workspace.getPage(pageId); + if (page && page.meta.jumpOnce) { + workspace.meta.setPageMeta(page.id, { + jumpOnce: false, + }); + return redirect(`/workspace/${workspace.id}/${page.id}`); } } return null; diff --git a/tests/affine-desktop-cloud/e2e/basic.spec.ts b/tests/affine-desktop-cloud/e2e/basic.spec.ts index ffeae0008e..a73f1d4b13 100644 --- a/tests/affine-desktop-cloud/e2e/basic.spec.ts +++ b/tests/affine-desktop-cloud/e2e/basic.spec.ts @@ -7,6 +7,8 @@ import { import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic'; import { createLocalWorkspace } from '@affine-test/kit/utils/workspace'; +process.env.DEV_SERVER_URL = 'http://localhost:8080'; + let user: { name: string; email: string; @@ -18,7 +20,9 @@ test.beforeEach(async () => { }); test.beforeEach(async ({ page }) => { - await loginUser(page, user.email); + await loginUser(page, user.email, { + isElectron: true, + }); }); test('new page', async ({ page }) => { diff --git a/tests/kit/utils/cloud.ts b/tests/kit/utils/cloud.ts index d902907957..2d47482bbf 100644 --- a/tests/kit/utils/cloud.ts +++ b/tests/kit/utils/cloud.ts @@ -133,12 +133,15 @@ export async function loginUser( page: Page, userEmail: string, config?: { + isElectron?: boolean; beforeLogin?: () => Promise; afterLogin?: () => Promise; } ) { - await openHomePage(page); - await waitForEditorLoad(page); + if (config?.isElectron !== true) { + await openHomePage(page); + await waitForEditorLoad(page); + } await clickSideBarCurrentWorkspaceBanner(page); await page.getByTestId('cloud-signin-button').click({