Skip to content

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.

fix: windows rust cache (#1710)

Peng Xiao5a508b1fe42f
diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml
index 2fbd56e41f..684975bc73 100644
--- a/.github/actions/setup-node/action.yml
+++ b/.github/actions/setup-node/action.yml
@@ -95,7 +95,7 @@ runs:
id: playwright-version
if: ${{ inputs.playwright-install == 'true' }}
shell: bash
- run: echo "{version}=$(yarn why --json @playwright/test | grep -h 'workspace:.' | jq --raw-output '.children[].locator' | sed -e 's/@playwright\/test@.*://')" >> GITHUB_OUTPUT
+ run: echo "version=$(yarn why --json @playwright/test | grep -h 'workspace:.' | jq --raw-output '.children[].locator' | sed -e 's/@playwright\/test@.*://')" >> $GITHUB_OUTPUT
# Attempt to restore the correct Playwright browser binaries based on the
# currently installed version of Playwright (The browser binary versions
diff --git a/.github/workflows/client-app.yml b/.github/workflows/client-app.yml
index f07b5260fd..4aa654078a 100644
--- a/.github/workflows/client-app.yml
+++ b/.github/workflows/client-app.yml
@@ -173,6 +173,11 @@ jobs:
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
+ - name: Rust cache
+ uses: swatinem/rust-cache@v2
+ with:
+ workspaces: './packages/octobase-node -> target'
+
- uses: actions/download-artifact@v3
with:
name: before-make-web-static
@@ -183,18 +188,13 @@ jobs:
name: before-make-electron-dist
path: apps/electron/dist
- - name: move octobase Binary
- run: cp ./packages/octobase-node/octobase.*.node ./apps/electron/dist/layers/main/
-
- - name: Rust cache
- uses: swatinem/rust-cache@v2
- with:
- workspaces: './packages/octobase-node -> target'
-
- name: build octobase-node
run: yarn build:octobase-node
working-directory: apps/electron
+ - name: move octobase Binary
+ run: cp ./packages/octobase-node/octobase.*.node ./apps/electron/dist/layers/main/
+
- name: make build
run: yarn make-windows-x64
working-directory: apps/electron
diff --git a/apps/web/src/utils/blocksuite.ts b/apps/web/src/utils/blocksuite.ts
index dfc52b478d..85a674ae25 100644
--- a/apps/web/src/utils/blocksuite.ts
+++ b/apps/web/src/utils/blocksuite.ts
@@ -51,6 +51,15 @@ export function _initPageWithDemoMarkdown(
const frameId = page.addBlock('affine:frame', {}, pageBlockId);
page.addBlock('affine:paragraph', {}, frameId);
const contentParser = new ContentParser(page);
- contentParser.importMarkdown(demoText, frameId);
+ contentParser.importMarkdown(demoText, frameId).then(() => {
+ document.dispatchEvent(
+ new CustomEvent('markdown:imported', {
+ detail: {
+ workspaceId: page.workspace.id,
+ pageId: page.id,
+ },
+ })
+ );
+ });
page.workspace.setPageMeta(page.id, { demoTitle });
}
diff --git a/tests/libs/page-logic.ts b/tests/libs/page-logic.ts
index 2a488953e3..902151ad59 100644
--- a/tests/libs/page-logic.ts
+++ b/tests/libs/page-logic.ts
@@ -1,7 +1,15 @@
import type { Page } from '@playwright/test';
+export async function waitMarkdownImported(page: Page) {
+ return page.evaluate(
+ () =>
+ new Promise(resolve => {
+ document.addEventListener('markdown:imported', resolve);
+ })
+ );
+}
+
export async function newPage(page: Page) {
- await page.waitForSelector('v-line');
// fixme(himself65): if too fast, the page will crash
await page.getByTestId('new-page-button').click({
delay: 100,
diff --git a/tests/parallels/affine-workspace.spec.ts b/tests/parallels/affine-workspace.spec.ts
index 4067ab5cf0..2a0c182fb2 100644
--- a/tests/parallels/affine-workspace.spec.ts
+++ b/tests/parallels/affine-workspace.spec.ts
@@ -1,5 +1,7 @@
import { expect } from '@playwright/test';
+import { waitMarkdownImported } from '../libs/page-logic';
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
const userA = require('../fixtures/userA.json');
import { test } from '../libs/playwright';
@@ -19,6 +21,7 @@ import {
test.describe('affine workspace', () => {
test('should login with user A', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const [a] = await createFakeUser();
await loginUser(page, a);
await clickSideBarCurrentWorkspaceBanner(page);
@@ -30,6 +33,7 @@ test.describe('affine workspace', () => {
test('should enable affine workspace successfully', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const [a] = await createFakeUser();
await loginUser(page, a);
const name = `test-${Date.now()}`;
diff --git a/tests/parallels/change-page-mode.spec.ts b/tests/parallels/change-page-mode.spec.ts
index 2a129ee533..4d76bcbda0 100644
--- a/tests/parallels/change-page-mode.spec.ts
+++ b/tests/parallels/change-page-mode.spec.ts
@@ -1,12 +1,13 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
-import { clickPageMoreActions } from '../libs/page-logic';
+import { clickPageMoreActions, waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test.describe('Change page mode(Page or Edgeless)', () => {
test('Switch to edgeless by switch edgeless item', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const btn = await page.getByTestId('switch-edgeless-mode-button');
await btn.click();
@@ -16,6 +17,7 @@ test.describe('Change page mode(Page or Edgeless)', () => {
test('Convert to edgeless by editor header items', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await clickPageMoreActions(page);
const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless');
await menusEdgelessItem.click({ delay: 100 });
diff --git a/tests/parallels/contact-us.spec.ts b/tests/parallels/contact-us.spec.ts
index 1b3d0f623f..4c29676bfe 100644
--- a/tests/parallels/contact-us.spec.ts
+++ b/tests/parallels/contact-us.spec.ts
@@ -1,11 +1,13 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test.describe('Open contact us', () => {
test('Click right-bottom corner contact icon', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await page.locator('[data-testid=help-island]').click();
const rightBottomContactUs = page.locator(
'[data-testid=right-bottom-contact-us-icon]'
diff --git a/tests/parallels/layout.spec.ts b/tests/parallels/layout.spec.ts
index 59cc4ceca6..44b605450f 100644
--- a/tests/parallels/layout.spec.ts
+++ b/tests/parallels/layout.spec.ts
@@ -1,11 +1,13 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test.describe('Layout ui', () => {
test('Collapse Sidebar', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await page.getByTestId('sliderBar-arrowButton-collapse').click();
const sliderBarArea = page.getByTestId('sliderBar');
await expect(sliderBarArea).not.toBeVisible();
@@ -13,6 +15,7 @@ test.describe('Layout ui', () => {
test('Expand Sidebar', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await page.getByTestId('sliderBar-arrowButton-collapse').click();
const sliderBarArea = page.getByTestId('sliderBar');
await expect(sliderBarArea).not.toBeVisible();
diff --git a/tests/parallels/local-first-avatar.spec.ts b/tests/parallels/local-first-avatar.spec.ts
index d30e72803a..b70b118ca6 100644
--- a/tests/parallels/local-first-avatar.spec.ts
+++ b/tests/parallels/local-first-avatar.spec.ts
@@ -1,13 +1,14 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
-import { newPage } from '../libs/page-logic';
+import { newPage, waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.describe('Local first create page', () => {
test('should create a page with a local first avatar', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await page.getByTestId('workspace-name').click();
await page.getByTestId('new-workspace').click({ delay: 50 });
diff --git a/tests/parallels/local-first-delete-page.spec.ts b/tests/parallels/local-first-delete-page.spec.ts
index 9ce181271d..26a7d895ab 100644
--- a/tests/parallels/local-first-delete-page.spec.ts
+++ b/tests/parallels/local-first-delete-page.spec.ts
@@ -1,7 +1,11 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
-import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
+import {
+ getBlockSuiteEditorTitle,
+ newPage,
+ waitMarkdownImported,
+} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -10,6 +14,7 @@ test.describe('Local first delete page', () => {
page,
}) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');
diff --git a/tests/parallels/local-first-delete-workspace.spec.ts b/tests/parallels/local-first-delete-workspace.spec.ts
index a17e107b42..558bdfac82 100644
--- a/tests/parallels/local-first-delete-workspace.spec.ts
+++ b/tests/parallels/local-first-delete-workspace.spec.ts
@@ -1,6 +1,7 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarSettingButton } from '../libs/sidebar';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -10,6 +11,7 @@ test.describe('Local first delete workspace', () => {
page,
}) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await clickSideBarSettingButton(page);
await page.getByTestId('delete-workspace-button').click();
const workspaceNameDom = await page.getByTestId('workspace-name');
diff --git a/tests/parallels/local-first-export-page.spec.ts b/tests/parallels/local-first-export-page.spec.ts
index 6b4395c133..5b5e423ed5 100644
--- a/tests/parallels/local-first-export-page.spec.ts
+++ b/tests/parallels/local-first-export-page.spec.ts
@@ -5,6 +5,7 @@ import {
clickPageMoreActions,
getBlockSuiteEditorTitle,
newPage,
+ waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -12,6 +13,7 @@ import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.describe('Local first export page', () => {
test.skip('New a page ,then open it and export html', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await page
diff --git a/tests/parallels/local-first-favorite-page.spec.ts b/tests/parallels/local-first-favorite-page.spec.ts
index 415c7f601d..6711705982 100644
--- a/tests/parallels/local-first-favorite-page.spec.ts
+++ b/tests/parallels/local-first-favorite-page.spec.ts
@@ -5,6 +5,7 @@ import {
clickPageMoreActions,
getBlockSuiteEditorTitle,
newPage,
+ waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -12,6 +13,7 @@ import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.describe('Local first favorite and cancel favorite page', () => {
test('New a page and open it ,then favorite it', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
@@ -29,6 +31,7 @@ test.describe('Local first favorite and cancel favorite page', () => {
});
test('Cancel favorite', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
diff --git a/tests/parallels/local-first-favorites-items.spec.ts b/tests/parallels/local-first-favorites-items.spec.ts
index b1f3827061..b228a5bd4d 100644
--- a/tests/parallels/local-first-favorites-items.spec.ts
+++ b/tests/parallels/local-first-favorites-items.spec.ts
@@ -5,6 +5,7 @@ import {
clickPageMoreActions,
getBlockSuiteEditorTitle,
newPage,
+ waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -12,6 +13,7 @@ import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.describe('Local first favorite items ui', () => {
test('Show favorite items in sidebar', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
@@ -36,6 +38,7 @@ test.describe('Local first favorite items ui', () => {
test('Show favorite items in favorite list', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
diff --git a/tests/parallels/local-first-new-page.spec.ts b/tests/parallels/local-first-new-page.spec.ts
index d60d541bb3..8da6827764 100644
--- a/tests/parallels/local-first-new-page.spec.ts
+++ b/tests/parallels/local-first-new-page.spec.ts
@@ -1,13 +1,18 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
-import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
+import {
+ getBlockSuiteEditorTitle,
+ newPage,
+ waitMarkdownImported,
+} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.describe('local first new page', () => {
test('click btn new page', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const originPageId = page.url().split('/').reverse()[0];
await newPage(page);
const newPageId = page.url().split('/').reverse()[0];
@@ -17,6 +22,7 @@ test.describe('local first new page', () => {
test('click btn bew page and find it in all pages', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page');
diff --git a/tests/parallels/local-first-openpage-newtab.spec.ts b/tests/parallels/local-first-openpage-newtab.spec.ts
index 0299e1fb8f..b043271cf7 100644
--- a/tests/parallels/local-first-openpage-newtab.spec.ts
+++ b/tests/parallels/local-first-openpage-newtab.spec.ts
@@ -1,13 +1,18 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
-import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
+import {
+ getBlockSuiteEditorTitle,
+ newPage,
+ waitMarkdownImported,
+} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.describe('local first new page', () => {
test('click btn bew page and open in tab', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page');
diff --git a/tests/parallels/local-first-restore-page.spec.ts b/tests/parallels/local-first-restore-page.spec.ts
index ecb76a9f5a..874bd87f18 100644
--- a/tests/parallels/local-first-restore-page.spec.ts
+++ b/tests/parallels/local-first-restore-page.spec.ts
@@ -1,7 +1,11 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
-import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
+import {
+ getBlockSuiteEditorTitle,
+ newPage,
+ waitMarkdownImported,
+} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -10,6 +14,7 @@ test.describe('Local first delete page', () => {
page,
}) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');
diff --git a/tests/parallels/local-first-setting-page.spec.ts b/tests/parallels/local-first-setting-page.spec.ts
index f085648a24..20fb08aa1e 100644
--- a/tests/parallels/local-first-setting-page.spec.ts
+++ b/tests/parallels/local-first-setting-page.spec.ts
@@ -1,6 +1,7 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarSettingButton } from '../libs/sidebar';
@@ -9,6 +10,7 @@ test.describe('Local first setting page', () => {
page,
}) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const element = await page.getByTestId(
'slider-bar-workspace-setting-button'
);
diff --git a/tests/parallels/local-first-show-delete-modal.spec.ts b/tests/parallels/local-first-show-delete-modal.spec.ts
index d9274c31d5..d69a0f780b 100644
--- a/tests/parallels/local-first-show-delete-modal.spec.ts
+++ b/tests/parallels/local-first-show-delete-modal.spec.ts
@@ -5,6 +5,7 @@ import {
clickPageMoreActions,
getBlockSuiteEditorTitle,
newPage,
+ waitMarkdownImported,
} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -12,6 +13,7 @@ import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.describe('Local first delete page', () => {
test('New a page ,then open it and show delete modal', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
@@ -34,6 +36,7 @@ test.describe('Local first delete page', () => {
page,
}) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
diff --git a/tests/parallels/local-first-trash-page.spec.ts b/tests/parallels/local-first-trash-page.spec.ts
index 6540373c2b..0c2766a0cb 100644
--- a/tests/parallels/local-first-trash-page.spec.ts
+++ b/tests/parallels/local-first-trash-page.spec.ts
@@ -1,7 +1,11 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
-import { getBlockSuiteEditorTitle, newPage } from '../libs/page-logic';
+import {
+ getBlockSuiteEditorTitle,
+ newPage,
+ waitMarkdownImported,
+} from '../libs/page-logic';
import { test } from '../libs/playwright';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -10,6 +14,7 @@ test.describe('Local first trash page', () => {
page,
}) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
diff --git a/tests/parallels/local-first-workspace-list.spec.ts b/tests/parallels/local-first-workspace-list.spec.ts
index 076836f738..82972c5390 100644
--- a/tests/parallels/local-first-workspace-list.spec.ts
+++ b/tests/parallels/local-first-workspace-list.spec.ts
@@ -1,6 +1,7 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarAllPageButton } from '../libs/sidebar';
import { createWorkspace } from '../libs/workspace';
@@ -8,6 +9,7 @@ import { createWorkspace } from '../libs/workspace';
test.describe('Local first workspace list', () => {
test('just one item in the workspace list at first', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const workspaceName = page.getByTestId('workspace-name');
await workspaceName.click();
expect(
@@ -20,6 +22,7 @@ test.describe('Local first workspace list', () => {
test('create one workspace in the workspace list', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const newWorkspaceNameStr = 'New Workspace';
await createWorkspace({ name: newWorkspaceNameStr }, page);
@@ -48,6 +51,7 @@ test.describe('Local first workspace list', () => {
test('create multi workspace in the workspace list', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await createWorkspace({ name: 'New Workspace 2' }, page);
await createWorkspace({ name: 'New Workspace 3' }, page);
diff --git a/tests/parallels/local-first-workspace.spec.ts b/tests/parallels/local-first-workspace.spec.ts
index 73db449e64..8fd96eca66 100644
--- a/tests/parallels/local-first-workspace.spec.ts
+++ b/tests/parallels/local-first-workspace.spec.ts
@@ -1,6 +1,7 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { clickSideBarCurrentWorkspaceBanner } from '../libs/sidebar';
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
@@ -8,6 +9,7 @@ import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
test.describe('Local first default workspace', () => {
test('preset workspace name', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const workspaceName = page.getByTestId('workspace-name');
await page.waitForTimeout(1000);
expect(await workspaceName.textContent()).toBe('Demo Workspace');
@@ -24,6 +26,7 @@ test.describe('Local first default workspace', () => {
test.describe('Language switch', () => {
test('Open language switch menu', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await clickSideBarCurrentWorkspaceBanner(page);
const languageMenuButton = page.getByTestId('language-menu-button');
await expect(languageMenuButton).toBeVisible();
diff --git a/tests/parallels/open-affine.spec.ts b/tests/parallels/open-affine.spec.ts
index 37aa5f163d..0707c3ba88 100644
--- a/tests/parallels/open-affine.spec.ts
+++ b/tests/parallels/open-affine.spec.ts
@@ -1,12 +1,14 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
import { createWorkspace } from '../libs/workspace';
test.describe('Open AFFiNE', () => {
test('Open last workspace when back to affine', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await createWorkspace({ name: 'New Workspace 2' }, page);
// FIXME: can not get when the new workspace is surely created, hack a timeout to wait
// waiting for page loading end
diff --git a/tests/parallels/quick-search.spec.ts b/tests/parallels/quick-search.spec.ts
index 77d80f9ad9..91a7bc2cbe 100644
--- a/tests/parallels/quick-search.spec.ts
+++ b/tests/parallels/quick-search.spec.ts
@@ -2,7 +2,7 @@ import { expect, type Page } from '@playwright/test';
import { withCtrlOrMeta } from '../libs/keyboard';
import { openHomePage } from '../libs/load-page';
-import { newPage } from '../libs/page-logic';
+import { newPage, waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
const openQuickSearchByShortcut = async (page: Page) =>
@@ -32,6 +32,7 @@ async function titleIsFocused(page: Page) {
test.describe('Open quick search', () => {
test('Click slider bar button', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
const quickSearchButton = page.locator(
'[data-testid=slider-bar-quick-search-button]'
@@ -43,6 +44,7 @@ test.describe('Open quick search', () => {
test('Click arrowDown icon after title', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
const quickSearchButton = page.locator(
'[data-testid=slider-bar-quick-search-button]'
@@ -54,6 +56,7 @@ test.describe('Open quick search', () => {
test('Press the shortcut key cmd+k', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
const quickSearch = page.locator('[data-testid=quickSearch]');
@@ -64,6 +67,7 @@ test.describe('Open quick search', () => {
test.describe('Add new page in quick search', () => {
test('Create a new page without keyword', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
@@ -74,6 +78,7 @@ test.describe('Add new page in quick search', () => {
test('Create a new page with keyword', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
@@ -87,6 +92,7 @@ test.describe('Add new page in quick search', () => {
test.describe('Search and select', () => {
test('Enter a keyword to search for', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
@@ -95,6 +101,7 @@ test.describe('Search and select', () => {
});
test('Create a new page and search this page', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
@@ -126,6 +133,7 @@ test.describe('Disable search on 404 page', () => {
test.describe('Open quick search on the published page', () => {
test('Open quick search on local page', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
const publishedSearchResults = page.locator('[publishedSearchResults]');
@@ -136,6 +144,7 @@ test.describe('Open quick search on the published page', () => {
test.describe('Focus event for quick search', () => {
test('Autofocus input after opening quick search', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
const locator = page.locator('[cmdk-input]');
@@ -144,6 +153,7 @@ test.describe('Focus event for quick search', () => {
});
test('Autofocus input after select', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
await page.keyboard.press('ArrowUp');
@@ -153,6 +163,7 @@ test.describe('Focus event for quick search', () => {
});
test('Focus title after creating a new page', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await newPage(page);
await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
@@ -165,6 +176,7 @@ test.describe('Novice guidance for quick search', () => {
page,
}) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
const quickSearchTips = page.locator('[data-testid=quick-search-tips]');
await expect(quickSearchTips).not.toBeVisible();
await page.getByTestId('sliderBar-arrowButton-collapse').click();
diff --git a/tests/parallels/shortcuts.spec.ts b/tests/parallels/shortcuts.spec.ts
index 55b5ee54e9..420dd50ff8 100644
--- a/tests/parallels/shortcuts.spec.ts
+++ b/tests/parallels/shortcuts.spec.ts
@@ -1,11 +1,13 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test.describe('Shortcuts Modal', () => {
test('Open shortcuts modal', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await page.locator('[data-testid=help-island]').click();
const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');
diff --git a/tests/parallels/subpage.spec.ts b/tests/parallels/subpage.spec.ts
index 2522351251..5ff749bf6e 100644
--- a/tests/parallels/subpage.spec.ts
+++ b/tests/parallels/subpage.spec.ts
@@ -1,11 +1,13 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test.describe('subpage', () => {
test('Create subpage', async ({ page }) => {
await openHomePage(page);
+ await waitMarkdownImported(page);
await page.getByTestId('sliderBar-arrowButton-collapse').click();
const sliderBarArea = page.getByTestId('sliderBar');
await expect(sliderBarArea).not.toBeVisible();
diff --git a/tests/parallels/theme.spec.ts b/tests/parallels/theme.spec.ts
index 6f218ac07c..c3390034dd 100644
--- a/tests/parallels/theme.spec.ts
+++ b/tests/parallels/theme.spec.ts
@@ -1,6 +1,7 @@
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
+import { waitMarkdownImported } from '../libs/page-logic';
import { test } from '../libs/playwright';
test.describe('Change Theme', () => {
@@ -11,6 +12,7 @@ test.describe('Change Theme', () => {
});
const page = await context.newPage();
await openHomePage(page);
+ await waitMarkdownImported(page);
await page.waitForSelector('html');
const root = page.locator('html');
const themeMode = await root.evaluate(element =>
@@ -18,10 +20,19 @@ test.describe('Change Theme', () => {
);
expect(themeMode).toBe('light');
- const lightButton = page.locator('[data-testid=change-theme-dark]');
- await page.mouse.move(0, 0);
- await page.waitForTimeout(50);
- expect(await lightButton.isVisible()).toBe(false);
+ const rightMenu = page.getByTestId('editor-option-menu');
+ const rightMenuBox = await rightMenu.boundingBox();
+ const lightButton = page.getByTestId('change-theme-light');
+ const lightButtonBox = await lightButton.boundingBox();
+ const darkButton = page.getByTestId('change-theme-dark');
+ const darkButtonBox = await darkButton.boundingBox();
+ if (!rightMenuBox || !lightButtonBox || !darkButtonBox) {
+ throw new Error('rightMenuBox or lightButtonBox or darkButtonBox is nil');
+ }
+ expect(darkButtonBox.x).toBeLessThan(rightMenuBox.x);
+ expect(darkButtonBox.y).toBeGreaterThan(rightMenuBox.y);
+ expect(lightButtonBox.y).toBeCloseTo(rightMenuBox.y);
+ expect(lightButtonBox.x).toBeCloseTo(darkButtonBox.x);
});
// test('change theme to dark', async ({ page }) => {