mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
chore: migrate blocksuite test (#9222)
This commit is contained in:
26
blocksuite/tests-legacy/utils/inline-editor.ts
Normal file
26
blocksuite/tests-legacy/utils/inline-editor.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
import { currentEditorIndex } from './multiple-editor.js';
|
||||
|
||||
export async function getStringFromRichText(
|
||||
page: Page,
|
||||
index = 0
|
||||
): Promise<string> {
|
||||
await page.waitForTimeout(50);
|
||||
return page.evaluate(
|
||||
([index, currentEditorIndex]) => {
|
||||
const editorHost =
|
||||
document.querySelectorAll('editor-host')[currentEditorIndex];
|
||||
const richTexts = editorHost.querySelectorAll('rich-text');
|
||||
|
||||
if (!richTexts) {
|
||||
throw new Error('Cannot find rich-text');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const editor = (richTexts[index] as any).inlineEditor;
|
||||
return editor.yText.toString();
|
||||
},
|
||||
[index, currentEditorIndex]
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user