Python内核代码移除,建模界面缩放bug修复

This commit is contained in:
ljz committed 2026-09-10 11:57:39 +08:00
1 parent 743663e3a6
commit 0dcb465d84
27 files changed
+354 -6092

No files matched your search

@@ -549,6 +549,82 @@ test("正交连接线可拖动内部线段,且无连接交叉点显示跨线
expect(savedRoute?.length).toBeGreaterThan(1);
});
test("缩小画布后连接线端点仍与端口图标边缘对齐", async ({ page }) => {
await page.addInitScript((storedProject) => {
window.localStorage.setItem(
"system-simulation-flow:project:demo-system",
JSON.stringify(storedProject),
);
}, wideProject);
await page.goto("/");
await page.getByRole("button", { name: "加载工程", exact: true }).click();
const viewport = page.locator(".flow-canvas .react-flow__viewport");
const readViewportZoom = () =>
viewport.evaluate((element) => {
const values =
getComputedStyle(element)
.transform.match(/-?\d*\.?\d+(?:e[-+]?\d+)?/gi)
?.map(Number) ?? [];
return values[0] ?? 1;
});
const initialZoom = await readViewportZoom();
const pane = page.locator(".flow-canvas .react-flow__pane");
const paneBounds = await pane.boundingBox();
expect(paneBounds).not.toBeNull();
await page.mouse.move(
paneBounds!.x + paneBounds!.width / 2,
paneBounds!.y + paneBounds!.height / 2,
);
await page.keyboard.down("Control");
await page.mouse.wheel(0, 720);
await page.keyboard.up("Control");
await expect
.poll(async () => (await readViewportZoom()) / initialZoom)
.toBeLessThan(0.7);
const zoom = await readViewportZoom();
const alignment = await page.evaluate(() => {
const path = document.querySelector<SVGPathElement>(
'.flow-canvas .react-flow__edge[data-id="edge-1"] .react-flow__edge-path',
);
const source = document.querySelector<HTMLElement>(
'.flow-canvas .react-flow__node[data-id="generic_sensor_1"] .port-handle[data-port-name="port_b"]',
);
const target = document.querySelector<HTMLElement>(
'.flow-canvas .react-flow__node[data-id="generic_sensor_2"] .port-handle[data-port-name="port_a"]',
);
const matrix = path?.getScreenCTM();
if (!path || !source || !target || !matrix) {
return null;
}
const start = path.getPointAtLength(0).matrixTransform(matrix);
const end = path.getPointAtLength(path.getTotalLength()).matrixTransform(matrix);
const sourceBounds = source.getBoundingClientRect();
const targetBounds = target.getBoundingClientRect();
return {
sourceGapX: Math.abs(start.x - sourceBounds.right),
sourceGapY: Math.abs(
start.y - (sourceBounds.top + sourceBounds.height / 2),
),
sourceWidth: sourceBounds.width,
targetGapX: Math.abs(end.x - targetBounds.left),
targetGapY: Math.abs(
end.y - (targetBounds.top + targetBounds.height / 2),
),
targetWidth: targetBounds.width,
};
});
expect(alignment).not.toBeNull();
expect(Math.abs(alignment!.sourceWidth - 6 * zoom)).toBeLessThan(0.1);
expect(Math.abs(alignment!.targetWidth - 6 * zoom)).toBeLessThan(0.1);
expect(alignment!.sourceGapX).toBeLessThan(0.75);
expect(alignment!.sourceGapY).toBeLessThan(0.75);
expect(alignment!.targetGapX).toBeLessThan(0.75);
expect(alignment!.targetGapY).toBeLessThan(0.75);
});
test("直线首次折弯后即使原手柄卸载,拖动仍连续且保持正交", async ({
page,
}) => {