fix(test): e2e stability (#14749)

#### PR Dependency Tree


* **PR #14749** 👈

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 link preview reliability by updating request identification
to better match modern browsers.
* **Tests**
* Made end-to-end and integration tests deterministic and more robust,
improving AI chat, image generation, attachment handling, settings
visibility, and editor flows.
* **Chores**
* Updated underlying tooling versions to enhance stability and
compatibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2026-03-29 23:26:15 +08:00
committed by GitHub
parent 9ca520a81f
commit 91ad783973
12 changed files with 136 additions and 114 deletions
@@ -13,6 +13,26 @@ function expectPxCloseTo(
expect(Number.parseFloat(value)).toBeCloseTo(expected, precision);
}
async function waitForShapeElement(
surfaceView: ReturnType<typeof getSurface>,
shapeId: string,
timeout = 1000
) {
const startedAt = Date.now();
while (Date.now() - startedAt < timeout) {
const shapeElement = surfaceView.renderRoot.querySelector<HTMLElement>(
`[data-element-id="${shapeId}"]`
);
if (shapeElement) return shapeElement;
await wait(50);
}
return null;
}
describe('Shape rendering with DOM renderer', () => {
beforeEach(async () => {
const cleanup = await setupEditor('edgeless', [], {
@@ -40,10 +60,7 @@ describe('Shape rendering with DOM renderer', () => {
};
const shapeId = surfaceModel.addElement(shapeProps);
await new Promise(resolve => setTimeout(resolve, 100));
const shapeElement = surfaceView?.renderRoot.querySelector(
`[data-element-id="${shapeId}"]`
);
const shapeElement = await waitForShapeElement(surfaceView, shapeId);
expect(shapeElement).not.toBeNull();
expect(shapeElement).toBeInstanceOf(HTMLElement);
@@ -61,10 +78,7 @@ describe('Shape rendering with DOM renderer', () => {
stroke: '#000000',
};
const shapeId = surfaceModel.addElement(shapeProps);
await wait(100);
const shapeElement = surfaceView?.renderRoot.querySelector<HTMLElement>(
`[data-element-id="${shapeId}"]`
);
const shapeElement = await waitForShapeElement(surfaceView, shapeId);
expect(shapeElement).not.toBeNull();
const zoom = surfaceView.renderer.viewport.zoom;
@@ -84,16 +98,12 @@ describe('Shape rendering with DOM renderer', () => {
};
const shapeId = surfaceModel.addElement(shapeProps);
await new Promise(resolve => setTimeout(resolve, 100));
let shapeElement = surfaceView.renderRoot.querySelector(
`[data-element-id="${shapeId}"]`
);
let shapeElement = await waitForShapeElement(surfaceView, shapeId);
expect(shapeElement).not.toBeNull();
surfaceModel.deleteElement(shapeId);
await new Promise(resolve => setTimeout(resolve, 100));
await wait(100);
shapeElement = surfaceView.renderRoot.querySelector(
`[data-element-id="${shapeId}"]`
@@ -113,10 +123,7 @@ describe('Shape rendering with DOM renderer', () => {
filled: true,
};
const shapeId = surfaceModel.addElement(shapeProps);
await wait(100);
const shapeElement = surfaceView?.renderRoot.querySelector<HTMLElement>(
`[data-element-id="${shapeId}"]`
);
const shapeElement = await waitForShapeElement(surfaceView, shapeId);
expect(shapeElement).not.toBeNull();
const zoom = surfaceView.renderer.viewport.zoom;
@@ -136,10 +143,7 @@ describe('Shape rendering with DOM renderer', () => {
filled: true,
};
const shapeId = surfaceModel.addElement(shapeProps);
await wait(100);
const shapeElement = surfaceView?.renderRoot.querySelector<HTMLElement>(
`[data-element-id="${shapeId}"]`
);
const shapeElement = await waitForShapeElement(surfaceView, shapeId);
expect(shapeElement).not.toBeNull();
const zoom = surfaceView.renderer.viewport.zoom;