mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
fix(editor): ci stability (#14704)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved Electron shutdown, diagnostics and tab teardown for more reliable exits and forced cleanup on stubborn processes. * **Tests** * Added polling-based test helpers, stronger scroll/page readiness, timeout-tolerant page selection, and async cleanup/worker teardown; updated many tests to wait for UI/model updates and rendering frames. * **Bug Fixes** * Reduced flakiness by awaiting paragraph visibility, nested counts, selection/navigation stability, tab counts, post-action renders, and safer element interactions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
} from '../utils/actions/index.js';
|
||||
import {
|
||||
assertBlockChildrenIds,
|
||||
assertRichTextInlineDeltas,
|
||||
assertRichTextInlineRange,
|
||||
assertRichTextModelType,
|
||||
assertRichTexts,
|
||||
@@ -162,20 +163,23 @@ test('use formatted cursor with hotkey', async ({ page }, testInfo) => {
|
||||
);
|
||||
});
|
||||
|
||||
test('use formatted cursor with hotkey at empty line', async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
test('use formatted cursor with hotkey at empty line', async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
await initEmptyParagraphState(page);
|
||||
await focusRichText(page);
|
||||
|
||||
// format bold
|
||||
await page.keyboard.press(`${SHORT_KEY}+b`, { delay: 50 });
|
||||
await waitNextFrame(page, 200);
|
||||
await type(page, 'aaa');
|
||||
|
||||
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
|
||||
`${testInfo.title}_bold.json`
|
||||
);
|
||||
await assertRichTextInlineDeltas(page, [
|
||||
{
|
||||
attributes: {
|
||||
bold: true,
|
||||
},
|
||||
insert: 'aaa',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('should single line format hotkey work', async ({ page }, testInfo) => {
|
||||
@@ -264,6 +268,7 @@ test('format list to h1', async ({ page }) => {
|
||||
await type(page, 'aa');
|
||||
await focusRichText(page, 0);
|
||||
await updateBlockType(page, 'affine:paragraph', 'h1');
|
||||
await waitNextFrame(page, 200);
|
||||
await assertRichTextModelType(page, 'h1');
|
||||
await undoByClick(page);
|
||||
await assertRichTextModelType(page, 'bulleted');
|
||||
@@ -280,6 +285,8 @@ test('should cut work single line', async ({ page }, testInfo) => {
|
||||
await dragBetweenIndices(page, [0, 1], [0, 4]);
|
||||
// cut
|
||||
await page.keyboard.press(`${SHORT_KEY}+x`);
|
||||
await waitNextFrame(page, 200);
|
||||
await assertRichTexts(page, ['ho']);
|
||||
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
|
||||
`${testInfo.title}_init.json`
|
||||
);
|
||||
|
||||
@@ -107,12 +107,15 @@ test('should cut work multiple line', async ({ page }, testInfo) => {
|
||||
await dragBetweenIndices(page, [0, 1], [2, 2]);
|
||||
// cut
|
||||
await page.keyboard.press(`${SHORT_KEY}+x`);
|
||||
await waitNextFrame(page, 200);
|
||||
await assertRichTexts(page, ['19']);
|
||||
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
|
||||
`${testInfo.title}_init.json`
|
||||
);
|
||||
await undoByKeyboard(page);
|
||||
const text = await readClipboardText(page);
|
||||
expect(text).toBe(`23 456 78`);
|
||||
await assertRichTexts(page, ['123', '456', '789']);
|
||||
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
|
||||
`${testInfo.title}_undo.json`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user