test: cover auto-position and auto-edge-handle; fix negative-cell clamp
Add backend API tests for the two issue #265 features that shipped untested: auto-positioning root nodes into a free grid slot (first at origin, collision avoidance, child origin default, explicit coords and explicit zero preserved) and auto-assigning edge handles from absolute canvas Y (source above/below/equal target, partial handle fill, child abs-Y resolved through parent). Drop the max(0, round()) clamp in _find_free_position: it folded negative-positioned nodes onto cell (0,0), falsely blocking or freeing the origin slot. Negative nodes now keep their true cells and never intersect the positive search space.
This commit is contained in:
@@ -37,10 +37,13 @@ async def _find_free_position(db: AsyncSession, design_id: str | None) -> tuple[
|
||||
if not positions:
|
||||
return 0.0, 0.0
|
||||
|
||||
# Snap each existing node to its true grid cell (negatives kept as-is). The
|
||||
# search below only visits col >= 0 / row >= 0, so nodes parked in negative
|
||||
# space never falsely block — or falsely free — a positive slot.
|
||||
occupied: set[tuple[int, int]] = set()
|
||||
for (px, py) in positions:
|
||||
col = max(0, round(px / _SLOT_W))
|
||||
row = max(0, round(py / _SLOT_H))
|
||||
col = round(px / _SLOT_W)
|
||||
row = round(py / _SLOT_H)
|
||||
occupied.add((col, row))
|
||||
|
||||
for row in range(10_000):
|
||||
|
||||
Reference in New Issue
Block a user