test(electron): fix cloud test (#4411)

This commit is contained in:
Alex Yang 2023-09-18 21:08:35 -05:00 committed by GitHub
parent 63bd1fbf02
commit 9aafaf865e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 12 deletions

View File

@ -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;

View File

@ -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 }) => {

View File

@ -133,12 +133,15 @@ export async function loginUser(
page: Page,
userEmail: string,
config?: {
isElectron?: boolean;
beforeLogin?: () => Promise<void>;
afterLogin?: () => Promise<void>;
}
) {
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({