mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
fix(editor): cross browser test stability (#14897)
#### PR Dependency Tree * **PR #14897** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved reliability of shape and connector detection by forcing full DOM renders during waits. * Fixed race conditions in code-block theme loading and cleanup when components unmount. * Refined viewport element discovery to correctly handle rotated/canvas-layer elements and avoid stale DOM removal. * **Tests** * Increased polling timeouts and retries to reduce flakiness. * Disabled per-file parallelism and ensured test setup performs full cleanup before starting; extended test timeout. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -29,6 +29,11 @@ async function waitForConnectorElement(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (surfaceView.renderer instanceof DomRenderer) {
|
||||
surfaceView.renderer.markElementDirty(connectorId);
|
||||
surfaceView.renderer.forceFullRender();
|
||||
}
|
||||
|
||||
const connectorElement = surfaceView.renderRoot.querySelector<HTMLElement>(
|
||||
`[data-element-id="${connectorId}"]`
|
||||
);
|
||||
|
||||
@@ -16,11 +16,16 @@ function expectPxCloseTo(
|
||||
async function waitForShapeElement(
|
||||
surfaceView: ReturnType<typeof getSurface>,
|
||||
shapeId: string,
|
||||
timeout = 1000
|
||||
timeout = 5000
|
||||
) {
|
||||
const startedAt = Date.now();
|
||||
|
||||
while (Date.now() - startedAt < timeout) {
|
||||
if (surfaceView.renderer instanceof DomRenderer) {
|
||||
surfaceView.renderer.markElementDirty(shapeId);
|
||||
surfaceView.renderer.forceFullRender();
|
||||
}
|
||||
|
||||
const shapeElement = surfaceView.renderRoot.querySelector<HTMLElement>(
|
||||
`[data-element-id="${shapeId}"]`
|
||||
);
|
||||
|
||||
@@ -275,9 +275,9 @@ describe('hotkey/bracket/linked-page', () => {
|
||||
await wait();
|
||||
const codeRichText = getRichTextByBlockId(codeId);
|
||||
setTextSelection(codeId, 1, 0);
|
||||
await wait();
|
||||
const rightContext = mockKeyboardContext();
|
||||
rightHandler(rightContext.ctx);
|
||||
expect(rightContext.preventDefault).not.toHaveBeenCalled();
|
||||
expect(codeRichText.inlineEditor.yTextString).toBe('()');
|
||||
});
|
||||
|
||||
|
||||
@@ -127,6 +127,8 @@ export async function setupEditor(
|
||||
const options: SetupEditorOptions = optionsInput ?? {};
|
||||
const enableDomRenderer = options?.enableDomRenderer ?? false;
|
||||
|
||||
await cleanup();
|
||||
|
||||
const collection = new TestWorkspace(createCollectionOptions());
|
||||
collection.storeExtensions = storeExtensions;
|
||||
collection.meta.initialize();
|
||||
|
||||
Reference in New Issue
Block a user