Python内核代码移除,建模界面缩放bug修复
This commit is contained in:
1 parent
743663e3a6
commit
0dcb465d84
27 files changed
+354
-6092
No files matched your search
@@ -3319,7 +3319,7 @@ test("端口图标随画布缩小且物理端口始终保持标准圆形", async
|
||||
?.map(Number) ?? [];
|
||||
return values[0] ?? 1;
|
||||
});
|
||||
const readPortShapes = async () => {
|
||||
const readPortShapes = async (currentZoom: number) => {
|
||||
const shapes = await scalablePorts.evaluateAll((elements) =>
|
||||
elements.map((element) => {
|
||||
const handleBounds = element.getBoundingClientRect();
|
||||
@@ -3352,8 +3352,8 @@ test("端口图标随画布缩小且物理端口始终保持标准圆形", async
|
||||
}),
|
||||
);
|
||||
for (const shape of shapes) {
|
||||
expect(Math.abs(shape.handleWidth - 6)).toBeLessThan(0.05);
|
||||
expect(Math.abs(shape.handleHeight - 6)).toBeLessThan(0.05);
|
||||
expect(Math.abs(shape.handleWidth - 6 * currentZoom)).toBeLessThan(0.1);
|
||||
expect(Math.abs(shape.handleHeight - 6 * currentZoom)).toBeLessThan(0.1);
|
||||
expect(shape.glyphWidth).not.toBeNull();
|
||||
expect(shape.glyphHeight).not.toBeNull();
|
||||
expect(Math.abs(shape.glyphWidth! - shape.glyphHeight!)).toBeLessThan(0.01);
|
||||
@@ -3371,7 +3371,10 @@ test("端口图标随画布缩小且物理端口始终保持标准圆形", async
|
||||
return shapes;
|
||||
};
|
||||
const initialZoom = await readViewportZoom();
|
||||
const initialShapes = await readPortShapes();
|
||||
const initialShapes = await readPortShapes(initialZoom);
|
||||
const initialPortStyles = await scalablePorts.evaluateAll((elements) =>
|
||||
elements.map((element) => element.getAttribute("style")),
|
||||
);
|
||||
for (const shape of initialShapes) {
|
||||
expect(Math.abs(shape.glyphWidth! - 6 * initialZoom)).toBeLessThan(0.05);
|
||||
expect(Math.abs(shape.glyphHeight! - 6 * initialZoom)).toBeLessThan(0.05);
|
||||
@@ -3391,7 +3394,23 @@ test("端口图标随画布缩小且物理端口始终保持标准圆形", async
|
||||
.poll(async () => (await readViewportZoom()) / initialZoom)
|
||||
.toBeLessThan(0.7);
|
||||
const zoomedZoom = await readViewportZoom();
|
||||
const zoomedShapes = await readPortShapes();
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const hitScale = await page
|
||||
.locator(".flow-canvas")
|
||||
.evaluate((element) =>
|
||||
Number(
|
||||
element.style.getPropertyValue("--port-handle-hit-scale"),
|
||||
),
|
||||
);
|
||||
return Math.abs(hitScale - 1 / zoomedZoom);
|
||||
})
|
||||
.toBeLessThan(0.02);
|
||||
const zoomedShapes = await readPortShapes(zoomedZoom);
|
||||
const zoomedPortStyles = await scalablePorts.evaluateAll((elements) =>
|
||||
elements.map((element) => element.getAttribute("style")),
|
||||
);
|
||||
expect(zoomedPortStyles).toEqual(initialPortStyles);
|
||||
const zoomRatio = zoomedZoom / initialZoom;
|
||||
for (const [index, shape] of zoomedShapes.entries()) {
|
||||
expect(Math.abs(shape.glyphWidth! - 6 * zoomedZoom)).toBeLessThan(0.1);
|
||||
@@ -3400,6 +3419,25 @@ test("端口图标随画布缩小且物理端口始终保持标准圆形", async
|
||||
Math.abs(shape.glyphWidth! / initialShapes[index].glyphWidth! - zoomRatio),
|
||||
).toBeLessThan(0.02);
|
||||
}
|
||||
|
||||
// 可见端口随画布缩小,但透明命中区仍保持易于点击的屏幕尺寸。
|
||||
const firstZoomedPort = scalablePorts.first();
|
||||
const firstZoomedPortBounds = await firstZoomedPort.boundingBox();
|
||||
expect(firstZoomedPortBounds).not.toBeNull();
|
||||
const hitPortName = await page.evaluate(
|
||||
({ x, y }) =>
|
||||
document
|
||||
.elementFromPoint(x, y)
|
||||
?.closest(".port-handle")
|
||||
?.getAttribute("data-port-name") ?? null,
|
||||
{
|
||||
x: firstZoomedPortBounds!.x - 3,
|
||||
y: firstZoomedPortBounds!.y + firstZoomedPortBounds!.height / 2,
|
||||
},
|
||||
);
|
||||
expect(hitPortName).toBe(
|
||||
await firstZoomedPort.getAttribute("data-port-name"),
|
||||
);
|
||||
});
|
||||
|
||||
test("放大画面后接触吸附仍保留足够的画布判定半径", async ({ page }) => {
|
||||
|
||||
Reference in new issue
Block a user