- 구조물 초안 쓰기 = useDesignStore().set("structures")(칸 그대로) → 관 초안과 같은 구독 · 횡단 보기 watchDrafts(구조물 = 늘 · 관 = 자리 · 종류 · 구간 · 잇기가 바뀔 때만 · 옵션만은 폼 길이 그 카드만 · 카드 줌 · 팬 지킴) · 옛 되부름 onStructuresChanged 걷음
- 종류 바꿈 = 표(catalog) swapsInPlace — 정본 다름 · 구조물 자리꼴 다름(E · F) = 지우고 같은 기준 측점에 새로(구간 = 기본 길이) · 같으면 종류 키만 · 막히면 옛 기록 · 옛 종류 폼 + 알림(전엔 [수정] 조기 반환 → 조용히 되돌림 · 드롭다운만 새 종류)
- syncApplied = 사용자가 조작한 세션이 있을 때만 깎음(카드 그리기가 자동 배치를 조정값으로 굳혀 [저장]으로 내보내던 것)
- replayDraftPipeOptions 걷음 — 그림 자료는 형상 얹기(초안 현황) · 다단 조정값은 조정 세션이 정본
- 시험: test_323_6_change(신호 · 거르기 · 표 규칙 · 그리기 · 걷음) · test_319 점형 ↔ 구간형 · 막힘 알림 · 되얹기 시험 = 형상 얹기로 · 옛 기대 글 고침
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
132 lines
5.0 KiB
Python
132 lines
5.0 KiB
Python
"""PLAN 319 — 횡단배수 종류 바꿈이 맹암거 · 개거처럼 정본이 다른 종류에서도 먹음(요구 217).
|
|
|
|
- 패널: 관 지점 ↔ 구조물로 바꿈 = 옛 것 지움(「없음」) → 같은 측점에 새 종류(우클릭 추가 길 `addAt`)
|
|
· 그 측점 옛 조정값 버림 · 처음 종류로 되돌리면 비울 자리 기록이 빠짐 · 같은 정본끼리는 종전 그대로
|
|
- 횡단 초안 맞춤: 일반 측점 자리(grid)도 종류가 바뀌거나 빠지면 구조물만 뺀 사본(측점 남음 · 고친 값
|
|
그대로)에 새 종류 · 저장분 종류로 되돌리면 저장분 그대로
|
|
|
|
실제 TS 를 `helper_319_kind_swap.cjs` 가 Node 로 돌린다(서버 부르는 곳 흉내).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
HERE = os.path.dirname(__file__)
|
|
ROOT = os.path.join(HERE, "..", "..")
|
|
|
|
pytestmark = pytest.mark.skipif(
|
|
not os.path.isdir(os.path.join(ROOT, "config", "node_modules")),
|
|
reason="프론트엔드 의존성 미설치",
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def result() -> dict:
|
|
out = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_319_kind_swap.cjs")],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=120,
|
|
check=True,
|
|
)
|
|
return json.loads(out.stdout)
|
|
|
|
|
|
def _src(*parts: str) -> str:
|
|
with open(os.path.join(ROOT, *parts), encoding="utf-8") as handle:
|
|
return handle.read()
|
|
|
|
|
|
def test_pipe_to_underdrain_removes_pipe_and_places_at_same_station(result: dict) -> None:
|
|
swap = result["pipe_to_underdrain"]
|
|
assert swap["removed"] == [80]
|
|
assert swap["pipeSet"] == [None]
|
|
assert swap["addAt"] == [[80, "cross_underdrain"]]
|
|
assert swap["reset"] == 0 and swap["live"] == 0 # 새로 놓기 폼으로 빠지지 않음
|
|
assert swap["kindreset"] == {"80.00": "pipe"} # [저장] 때 그 측점 옛 조정값 비움(318-4)
|
|
assert swap["culvertopt"] == {"300.00": {"b": 2}} # 그 측점 세션 조정값만 버림
|
|
|
|
|
|
def test_back_to_first_kind_drops_reset_mark(result: dict) -> None:
|
|
back = result["underdrain_back_to_pipe"]
|
|
assert back["left"] == [] and back["emit"] == 1 and back["editingSet"] == [None]
|
|
assert back["addAt"] == [[80, "pipe"]]
|
|
assert back["kindreset"] is None
|
|
|
|
|
|
def test_structure_to_pipe_kind(result: dict) -> None:
|
|
swap = result["open_ditch_to_box"]
|
|
assert swap["left"] == ["sign"] # 고른 개거만 빠짐
|
|
assert swap["removed"] == []
|
|
assert swap["addAt"] == [[120, "box_culvert"]]
|
|
assert swap["kindreset"]["120.00"] == "open_ditch"
|
|
|
|
|
|
def test_same_owner_switch_unchanged(result: dict) -> None:
|
|
for case in ("pipe_to_box", "underdrain_to_open_ditch"):
|
|
same = result[case]
|
|
assert same["addAt"] == [] and same["removed"] == [] and same["live"] == 1
|
|
assert result["to_blank"]["reset"] == 1 and result["to_blank"]["addAt"] == []
|
|
|
|
|
|
def test_point_interval_switch_replaces_at_same_anchor(result: dict) -> None:
|
|
# 323-6 — 표 규칙(`swapsInPlace`) · 구간 = 기본 길이(`addAt`)
|
|
up = result["point_to_interval"]
|
|
assert up["left"] == [] and up["addAt"] == [[140, "guardrail"]] and up["live"] == 0
|
|
down = result["interval_to_point"]
|
|
assert down["left"] == [] and down["addAt"] == [[105, "mirror"]]
|
|
same = result["interval_same"]
|
|
assert same["addAt"] == [] and same["live"] == 1 and same["left"] == ["work_yard"]
|
|
|
|
|
|
def test_blocked_switch_restores_with_notice(result: dict) -> None:
|
|
blocked = result["blocked"]
|
|
assert blocked["left"] == ["mirror"] and blocked["loaded"] == ["mirror"]
|
|
assert len(blocked["toasts"]) == 1 and blocked["toasts"][0][1] == "error"
|
|
|
|
|
|
def test_grid_station_kind_change_uses_bare_copy(result: dict) -> None:
|
|
# 일반 측점 자리 = 측점이 남음 — 저장분에서 구조물만 뺀 사본에 새 종류(지형 쪽 고친 값 그대로)
|
|
grid = result["grid"]
|
|
assert grid["pipe_to_underdrain"] == {
|
|
"count": 3,
|
|
"keys": [],
|
|
"structure": "맹암거",
|
|
"preview": True,
|
|
"fresh": False,
|
|
"keep": 1,
|
|
}
|
|
assert grid["pipe_to_box"]["keys"] == ["box"] and grid["pipe_to_box"]["keep"] == 1
|
|
assert grid["underdrain_to_pipe"]["keys"] == ["culvert"]
|
|
assert grid["underdrain_to_pipe"]["structure"] == "파형강관 D800"
|
|
assert grid["underdrain_to_pipe"]["keep"] == 1
|
|
|
|
|
|
def test_grid_station_emptied_keeps_station_without_facility(result: dict) -> None:
|
|
assert result["grid"]["pipe_deleted"] == {
|
|
"count": 3,
|
|
"keys": [],
|
|
"structure": None,
|
|
"preview": True,
|
|
"fresh": False,
|
|
"keep": 1,
|
|
}
|
|
|
|
|
|
def test_grid_station_back_to_saved_kind_restores_saved(result: dict) -> None:
|
|
back = result["grid"]["pipe_back"]
|
|
assert back["keys"] == ["culvert"] and not back["preview"] and back["keep"] == 1
|
|
|
|
|
|
def test_panel_wires_add_at() -> None:
|
|
panel = _src("B05_Profile", "B05_Profile_UI_Structures_Panel.ts")
|
|
assert "addAt: (at, typeId) => api.addAt(at, typeId)" in panel
|
|
assert "return api;" in panel
|
|
assert len(panel.splitlines()) <= 700
|