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(core): image preview flaky (#6292)

pengx17578d4c9775ed
diff --git a/tests/affine-local/e2e/image-preview.spec.ts b/tests/affine-local/e2e/image-preview.spec.ts
index 61850d9281..51b89140a5 100644
--- a/tests/affine-local/e2e/image-preview.spec.ts
+++ b/tests/affine-local/e2e/image-preview.spec.ts
@@ -5,12 +5,14 @@ import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
+ focusInlineEditor,
getBlockSuiteEditorTitle,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { expect, type Page } from '@playwright/test';
async function importImage(page: Page, url: string) {
+ await focusInlineEditor(page);
await page.evaluate(
([url]) => {
const clipData = {
diff --git a/tests/kit/utils/page-logic.ts b/tests/kit/utils/page-logic.ts
index 84f6f04358..1807b5f842 100644
--- a/tests/kit/utils/page-logic.ts
+++ b/tests/kit/utils/page-logic.ts
@@ -87,3 +87,13 @@ export const dragTo = async (page: Page, locator: Locator, target: Locator) => {
await target.hover();
await page.mouse.up();
};
+
+// sometimes editor loses focus, this function is to focus the editor
+export const focusInlineEditor = async (page: Page) => {
+ await page
+ .locator(
+ `.affine-paragraph-rich-text-wrapper:has(.visible):has-text("Type '/' for commands")`
+ )
+ .locator('.inline-editor')
+ .focus();
+};