# -*- coding: utf-8 -*- """PLAN 291-1 — 구조물 배치: 새 구조물은 [추가] 누른 뒤에만 생김. A군(관 지점 정본) — 기준 측점 확정(`commitPosition`)은 관을 안 넣음 · 우클릭 「추가」(116-1)만 임시 배치를 만듦 · [추가](`commit`)가 관 정본에 넣음. B · C 군은 [추가] 전 기록이 없음(`liveCommit` 이 고르던 항목만). 세월교 · 물넘이 빈 월류 높이는 [추가] 뒤 재계산 유량으로 채움(126-1 `fordWaits`). """ from pathlib import Path ROOT = Path(__file__).resolve().parents[2] B05 = ROOT / "B05_Profile" def _read(name: str) -> str: return (B05 / name).read_text(encoding="utf-8") def _body(src: str, start: str, end: str) -> str: at = src.index(start) return src[at : src.index(end, at)] PANEL = _read("B05_Profile_UI_Structures_Panel.ts") def test_임시_배치는_create_일_때만_관을_넣음(): body = _body( PANEL, "function commitTempPipe(create = false): void {", "function handleStationInput" ) guard = body.index("if (!create) return;") add = body.index("callbacks.onPipeAdd(anchor, attributes);") assert body.index("if (tempPipeChainage === null) {") < guard < add # 이미 있는 임시 관(우클릭)은 기준 측점으로 옮김 그대로 assert "callbacks.onPipeUpdate(from, anchor, attributes);" in body def test_측점_확정은_관을_안_만듦(): body = _body(PANEL, "function commitPosition(): void {", "function renderOptionFields") assert "commitTempPipe();" in body assert "commitTempPipe(true)" not in body def test_우클릭_추가만_임시_배치_만듦(): body = _body(PANEL, " addAt(chainageM, typeId) {", " moveById(") assert "if (type.managed_by) commitTempPipe(true);" in body assert PANEL.count("commitTempPipe(true)") == 1 def test_추가_단추가_관_정본에_넣음(): commit = _read("B05_Profile_UI_Structures_Panel_Commit.ts") body = _body(commit, "export async function commit(", "const placement = type.placement;") assert "ctx.callbacks.onPipeAdd(anchor, attributes);" in body def test_고르던_항목만_실시간_반영(): body = _body(PANEL, "function liveCommit(): void {", "function commitSummary") assert "if (!editingId && selectedPipeChainage === null) return;" in body def test_새_세월교_물넘이_월류_높이는_추가_뒤_채움(): drainage = _read("B05_Profile_UI_Drainage_Panel.ts") # 510 — 패널 addPipe 를 함수로(자동 제안 [넣기]도 같은 길) body = _body(drainage, " function addPipe(chainageM: number, attributes?: FacilityAttributes): void {", " /** 노선 전체가") assert "fordWaits().add(chainageM)" in body def test_패널_700줄_안(): assert len(PANEL.splitlines()) <= 700