"""255-1 거리이정표 시점 모달 — 중점 측점 km 로 보이고 받음(저장은 m) · 설명 줄 지움 · 지도 = 공용 카카오 지도(시점 · 중점 표지).""" import json import re import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[2] IMPORTS = re.compile(r"^import[^;]*;\n", re.MULTILINE) def _read(rel): return (ROOT / rel).read_text(encoding="utf-8") def _node(expr): src = _read("B08_Quantity/B08_Quantity_Milestone_Layout.ts") result = subprocess.run( ["node", "--experimental-strip-types", "--no-warnings", "--input-type=module-typescript", "-e", IMPORTS.sub("", src) + f"\nconsole.log(JSON.stringify({expr}));"], capture_output=True, text=True, encoding="utf-8", timeout=60, ) # fmt: skip assert result.returncode == 0, result.stderr return json.loads(result.stdout) def _site(km): data = {"site": {"mid_station_m": 999, "mid_road": "비포장"}, "base": {}, "routes": []} return _node(f'setLeg({json.dumps(data)}, "start", 0, {{ km: {json.dumps(km)} }}).site') def test_중점_km_저장_m(): assert _site(1.2345)["mid_station_m"] == 1234.5 assert _site(0.0005)["mid_station_m"] == 0.5 assert _site(None)["mid_station_m"] is None # 빈칸 = 노선 ÷ 2 def test_시점_모달_km_카카오_지도(): modal = _read("B08_Quantity/B08_Quantity_UI_Milestone_Modal.ts") site = modal[modal.index("export function openSiteInfo") :] assert 'label: "중점 측점 (km)"' in site assert "fmtKm(data.site.mid_station_m / 1000)" in site # 보임 = km(261-1 끝수 정리) assert 'setLeg(fresh, "start", 0, {' in site # 받음 km → 저장 m # 설명 줄 · 등록 주소 · 브이월드 주소 줄 · B01 타일 지도 없음 for gone in ("시점 = 노선 첫 점", "프로젝트 등록 주소", "브이월드 주소", "buildAddressMap"): assert gone not in modal assert "editMap({" in site assert '["start", "시점", s.start_lonlat]' in site and '["mid", "중점", s.mid_lonlat]' in site assert 'dialogClass: "b08-milestone__modal"' in site # 다른 모달과 같은 창 · 지도 높이