mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 19:46:32 +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:
@@ -38,7 +38,7 @@ beforeEach(async () => {
|
||||
|
||||
return async () => {
|
||||
await wait(100);
|
||||
cleanup();
|
||||
await cleanup();
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
const FRAME = 16;
|
||||
|
||||
describe('viewport turbo renderer', () => {
|
||||
let cleanup: () => void;
|
||||
let cleanup: () => Promise<void>;
|
||||
|
||||
beforeEach(async () => {
|
||||
cleanup = await setupEditor('edgeless', [
|
||||
@@ -34,7 +34,7 @@ describe('viewport turbo renderer', () => {
|
||||
return cleanup;
|
||||
});
|
||||
|
||||
afterEach(() => cleanup?.());
|
||||
afterEach(async () => await cleanup?.());
|
||||
|
||||
test('should access turbo renderer instance', async () => {
|
||||
const renderer = getRenderer();
|
||||
|
||||
@@ -29,6 +29,7 @@ const viewManager = getTestViewManager();
|
||||
effects();
|
||||
|
||||
const storeExtensions = storeManager.get('store');
|
||||
const painterWorkers = new Set<Worker>();
|
||||
|
||||
export function getRenderer() {
|
||||
return editor.std.get(
|
||||
@@ -108,6 +109,7 @@ export function createPainterWorker() {
|
||||
type: 'module',
|
||||
}
|
||||
);
|
||||
painterWorkers.add(worker);
|
||||
return worker;
|
||||
}
|
||||
|
||||
@@ -141,19 +143,30 @@ export async function setupEditor(
|
||||
|
||||
const appElement = await createEditor(collection, mode, extensions);
|
||||
|
||||
return () => {
|
||||
return async () => {
|
||||
await cleanup();
|
||||
appElement?.remove();
|
||||
cleanup();
|
||||
};
|
||||
}
|
||||
|
||||
export function cleanup() {
|
||||
export async function cleanup() {
|
||||
window.editor?.remove();
|
||||
await window.editor?.updateComplete;
|
||||
await new Promise<void>(resolve => requestAnimationFrame(() => resolve()));
|
||||
|
||||
for (const worker of painterWorkers) {
|
||||
worker.terminate();
|
||||
}
|
||||
painterWorkers.clear();
|
||||
|
||||
delete (window as any).collection;
|
||||
|
||||
delete (window as any).editor;
|
||||
|
||||
delete (window as any).doc;
|
||||
|
||||
delete (window as any).renderer;
|
||||
|
||||
delete (window as any).store;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user