diff --git a/package.json b/package.json index 52761a7d10..74cc0f1c84 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "@vitest/coverage-istanbul": "2.1.1", "@vitest/ui": "2.1.1", "cross-env": "^7.0.3", - "electron": "^32.0.0", + "electron": "^33.0.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import-x": "^0.5.0", diff --git a/packages/frontend/apps/electron/package.json b/packages/frontend/apps/electron/package.json index 7045ced7cd..33f75af603 100644 --- a/packages/frontend/apps/electron/package.json +++ b/packages/frontend/apps/electron/package.json @@ -49,7 +49,7 @@ "@vitejs/plugin-react-swc": "^3.6.0", "builder-util-runtime": "^9.2.5-alpha.2", "cross-env": "^7.0.3", - "electron": "^32.0.0", + "electron": "^33.0.0", "electron-log": "^5.1.2", "electron-squirrel-startup": "1.0.1", "electron-window-state": "^5.0.3", diff --git a/tests/affine-cloud/e2e/collaboration.spec.ts b/tests/affine-cloud/e2e/collaboration.spec.ts index 9230747393..161ad5590b 100644 --- a/tests/affine-cloud/e2e/collaboration.spec.ts +++ b/tests/affine-cloud/e2e/collaboration.spec.ts @@ -32,7 +32,7 @@ test.beforeEach(async () => { }); test.beforeEach(async ({ page }) => { - await loginUser(page, user.email); + await loginUser(page, user); }); // SKIP until BS-671 fix @@ -57,7 +57,7 @@ test.skip('can collaborate with other user and name should display when editing' const context = await browser.newContext(); await skipOnboarding(context); const page2 = await context.newPage(); - await loginUser(page2, userB.email); + await loginUser(page2, userB); await addUserToWorkspace(workspaceId, userB.id, 1 /* READ */); await page2.reload(); await waitForEditorLoad(page2); @@ -128,7 +128,7 @@ test('can sync collections between different browser', async ({ const context = await browser.newContext(); await skipOnboarding(context); const page2 = await context.newPage(); - await loginUser(page2, user.email); + await loginUser(page2, user); await page2.goto(page.url()); const collections = page2.getByTestId('explorer-collections'); await collections.getByTestId('category-divider-collapse-button').click(); @@ -193,7 +193,7 @@ test('can sync svg between different browsers', async ({ page, browser }) => { const context = await browser.newContext(); await skipOnboarding(context); const page2 = await context.newPage(); - await loginUser(page2, user.email); + await loginUser(page2, user); await page2.goto(page.url()); // second user should see the svg @@ -237,7 +237,7 @@ test('When the first sync is not completed, should always show loading', async ( const context = await browser.newContext(); await skipOnboarding(context); const page2 = await context.newPage(); - await loginUser(page2, user.email); + await loginUser(page2, user); // simulate sync stuck await page2.evaluate(() => { diff --git a/tests/affine-cloud/e2e/login.spec.ts b/tests/affine-cloud/e2e/login.spec.ts index 9ea7e65f02..782d3b35fc 100644 --- a/tests/affine-cloud/e2e/login.spec.ts +++ b/tests/affine-cloud/e2e/login.spec.ts @@ -36,7 +36,7 @@ test.describe('login first', () => { test.beforeEach(async ({ page }) => { user = await createRandomUser(); - await loginUser(page, user.email); + await loginUser(page, user); }); test('exit successfully and re-login', async ({ page }) => { diff --git a/tests/affine-cloud/e2e/migration.spec.ts b/tests/affine-cloud/e2e/migration.spec.ts index 15faac7dda..f911fe4375 100644 --- a/tests/affine-cloud/e2e/migration.spec.ts +++ b/tests/affine-cloud/e2e/migration.spec.ts @@ -30,7 +30,7 @@ test.beforeEach(async () => { }); test.beforeEach(async ({ page, context }) => { - await loginUser(page, user.email, { + await loginUser(page, user, { beforeLogin: async () => { expect(await getLoginCookie(context)).toBeUndefined(); }, @@ -56,7 +56,7 @@ test.skip('migration', async ({ page, browser }) => { // create the old cloud workspace in another browser const context = await browser.newContext(); const page = await context.newPage(); - await loginUser(page, user.email); + await loginUser(page, user); await page.reload(); await createLocalWorkspace( { diff --git a/tests/affine-cloud/e2e/page-history.spec.ts b/tests/affine-cloud/e2e/page-history.spec.ts index 0b4c03adeb..3f811e3ff6 100644 --- a/tests/affine-cloud/e2e/page-history.spec.ts +++ b/tests/affine-cloud/e2e/page-history.spec.ts @@ -23,7 +23,7 @@ let user: { test.beforeEach(async ({ page }) => { user = await createRandomUser(); - await loginUser(page, user.email); + await loginUser(page, user); }); test.afterEach(async () => { diff --git a/tests/affine-cloud/e2e/share-page.spec.ts b/tests/affine-cloud/e2e/share-page.spec.ts index 452500d5dd..d83fd29003 100644 --- a/tests/affine-cloud/e2e/share-page.spec.ts +++ b/tests/affine-cloud/e2e/share-page.spec.ts @@ -27,7 +27,7 @@ test.beforeEach(async () => { }); test.beforeEach(async ({ page }) => { - await loginUser(page, user.email); + await loginUser(page, user); }); test('can enable share page', async ({ page, browser }) => { diff --git a/tests/affine-cloud/e2e/workspace.spec.ts b/tests/affine-cloud/e2e/workspace.spec.ts index 500a36cc4e..5c10ec95a3 100644 --- a/tests/affine-cloud/e2e/workspace.spec.ts +++ b/tests/affine-cloud/e2e/workspace.spec.ts @@ -28,7 +28,7 @@ let user: { test.beforeEach(async ({ page }) => { user = await createRandomUser(); - await loginUser(page, user.email); + await loginUser(page, user); }); test('should have pagination in member list', async ({ page }) => { diff --git a/tests/affine-desktop-cloud/e2e/basic.spec.ts b/tests/affine-desktop-cloud/e2e/basic.spec.ts index a73f1d4b13..a311a4562d 100644 --- a/tests/affine-desktop-cloud/e2e/basic.spec.ts +++ b/tests/affine-desktop-cloud/e2e/basic.spec.ts @@ -19,14 +19,10 @@ test.beforeEach(async () => { user = await createRandomUser(); }); -test.beforeEach(async ({ page }) => { - await loginUser(page, user.email, { +test('new page', async ({ page }) => { + await loginUser(page, user, { isElectron: true, }); -}); - -test('new page', async ({ page }) => { - await page.reload(); await waitForEditorLoad(page); await createLocalWorkspace( { diff --git a/tests/affine-desktop-cloud/playwright.config.ts b/tests/affine-desktop-cloud/playwright.config.ts index d6227be2fc..cb6ae08bfc 100644 --- a/tests/affine-desktop-cloud/playwright.config.ts +++ b/tests/affine-desktop-cloud/playwright.config.ts @@ -14,7 +14,7 @@ import type { PlaywrightTestConfig } from '@playwright/test'; const config: PlaywrightTestConfig = { testDir: './e2e', fullyParallel: true, - timeout: process.env.CI ? 50_000 : 30_000, + timeout: process.env.CI ? 300_000 : 60_000, outputDir: testResultDir, use: { viewport: { width: 1440, height: 800 }, diff --git a/tests/kit/electron.ts b/tests/kit/electron.ts index bcdfafdfd3..ef2da1f536 100644 --- a/tests/kit/electron.ts +++ b/tests/kit/electron.ts @@ -96,6 +96,9 @@ export const test = base.extend<{ timeout: 30000, }); + // wait until the page is stable enough + await page.waitForTimeout(2000); + await use(page as Page); }, views: async ({ electronApp, page }, use) => { @@ -131,6 +134,7 @@ export const test = base.extend<{ env[key] = value; } } + env.DEBUG = 'pw:browser'; env.SKIP_ONBOARDING = '1'; diff --git a/tests/kit/utils/cloud.ts b/tests/kit/utils/cloud.ts index 75e0e52a02..29d2a9b92d 100644 --- a/tests/kit/utils/cloud.ts +++ b/tests/kit/utils/cloud.ts @@ -105,6 +105,7 @@ export async function createRandomUser(): Promise<{ password: string; id: string; }> { + const startTime = Date.now(); const user = { name: faker.internet.userName(), email: faker.internet.email().toLowerCase(), @@ -140,6 +141,8 @@ export async function createRandomUser(): Promise<{ }, }); }); + const endTime = Date.now(); + console.log(`createRandomUser takes: ${endTime - startTime}ms`); cloudUserSchema.parse(result); return { ...result, @@ -159,7 +162,10 @@ export async function deleteUser(email: string) { export async function loginUser( page: Page, - userEmail: string, + user: { + email: string; + password: string; + }, config?: { isElectron?: boolean; beforeLogin?: () => Promise; @@ -172,14 +178,12 @@ export async function loginUser( } await clickSideBarCurrentWorkspaceBanner(page); - await page.getByTestId('cloud-signin-button').click({ - delay: 200, - }); - await page.getByPlaceholder('Enter your email address').fill(userEmail); + await page.getByTestId('cloud-signin-button').click(); + await page.getByPlaceholder('Enter your email address').fill(user.email); await page.getByTestId('continue-login-button').click({ delay: 200, }); - await page.getByTestId('password-input').fill('123456'); + await page.getByTestId('password-input').fill(user.password); if (config?.beforeLogin) { await config.beforeLogin(); } diff --git a/yarn.lock b/yarn.lock index e347fd2282..6c4bce0590 100644 --- a/yarn.lock +++ b/yarn.lock @@ -492,7 +492,7 @@ __metadata: async-call-rpc: "npm:^6.4.2" builder-util-runtime: "npm:^9.2.5-alpha.2" cross-env: "npm:^7.0.3" - electron: "npm:^32.0.0" + electron: "npm:^33.0.0" electron-log: "npm:^5.1.2" electron-squirrel-startup: "npm:1.0.1" electron-updater: "npm:^6.2.1" @@ -605,7 +605,7 @@ __metadata: "@vitest/coverage-istanbul": "npm:2.1.1" "@vitest/ui": "npm:2.1.1" cross-env: "npm:^7.0.3" - electron: "npm:^32.0.0" + electron: "npm:^33.0.0" eslint: "npm:^8.57.0" eslint-config-prettier: "npm:^9.1.0" eslint-plugin-import-x: "npm:^0.5.0" @@ -18759,16 +18759,16 @@ __metadata: languageName: node linkType: hard -"electron@npm:^32.0.0": - version: 32.1.2 - resolution: "electron@npm:32.1.2" +"electron@npm:^33.0.0": + version: 33.0.0 + resolution: "electron@npm:33.0.0" dependencies: "@electron/get": "npm:^2.0.0" "@types/node": "npm:^20.9.0" extract-zip: "npm:^2.0.1" bin: electron: cli.js - checksum: 10/a4793dd12b2d1dffff53420092ac7612eee41d193f07e847783136ee296b5380abb169eb1a4c1929b01a99b1d93bf53f071f2c5128e8241e70ec930d303fba51 + checksum: 10/d6df529d990ae9a32778e66b6e9453f80bacb6ed3854ce62a81b5f0f705d762323534159fdcdb36a62eaa2901a49c384fef6333d35d68fc7ebf6d39baeeed6c6 languageName: node linkType: hard