fix(core): image preview flaky (#6292)
This commit is contained in:
@@ -5,12 +5,14 @@ import { test } from '@affine-test/kit/playwright';
|
|||||||
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
||||||
import {
|
import {
|
||||||
clickNewPageButton,
|
clickNewPageButton,
|
||||||
|
focusInlineEditor,
|
||||||
getBlockSuiteEditorTitle,
|
getBlockSuiteEditorTitle,
|
||||||
waitForEditorLoad,
|
waitForEditorLoad,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { expect, type Page } from '@playwright/test';
|
import { expect, type Page } from '@playwright/test';
|
||||||
|
|
||||||
async function importImage(page: Page, url: string) {
|
async function importImage(page: Page, url: string) {
|
||||||
|
await focusInlineEditor(page);
|
||||||
await page.evaluate(
|
await page.evaluate(
|
||||||
([url]) => {
|
([url]) => {
|
||||||
const clipData = {
|
const clipData = {
|
||||||
|
|||||||
@@ -87,3 +87,13 @@ export const dragTo = async (page: Page, locator: Locator, target: Locator) => {
|
|||||||
await target.hover();
|
await target.hover();
|
||||||
await page.mouse.up();
|
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();
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user