"""476-2 추천 모달 — 「적용될 초기 종단」 선 · 한 줄 · [적용] 확인 글(요구 276). ./venv/Scripts/python.exe -m pytest resources/tester/test_476_2_recommend_initial_line.py -q """ import json import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[2] B05 = ROOT / "B05_Profile" HELPER = Path(__file__).with_name("helper_476_2_initial_profile.cjs") def _out() -> dict: return json.loads( subprocess.run( ["node", str(HELPER)], capture_output=True, text=True, encoding="utf-8", check=True ).stdout ) def test_펴기와_캐시_빼기() -> None: out = _out() p = out["parsed"] assert p["withProfile"] is False and p["curveLengthM"] == 20 assert p["pviCount"] == 3 and p["curveCount"] == 1 and p["straightened"] == 2 assert p["line"][3] == [30, 101.5] and p["planM"] == [100, 102, 101] assert "initialProfile" not in out["cached"] # 세션에 안 적음 assert out["missing"] is None # 옛 서버 답 assert out["shortLine"] is None # 선 점 하나 = 꼴 틀림 def test_한_줄과_실패_글() -> None: out = _out() assert out["line"] == "초기 종단: 꼭짓점 3 · 종단곡선 1 · 직선화 2 · 최대 종단경사 10.0%(L 20)" assert out["warnLine"].endswith("(L 20) · 알림 2건") # 알림 글은 title assert out["failed"] == {"error": "지반고 종단 — 측점이 모자랍니다"} assert out["failedLine"].startswith("초기 종단을 셈하지 못했습니다 — 지반고 종단") def test_그림_선() -> None: out = _out() # 끔 = 지반선 + 초기 종단(계획선 빔) assert 'class="is-ground" d="M6.0 90.0L300.0 6.0L594.0 62.0"' in out["svgOff"] assert 'class="is-plan" d=""' in out["svgOff"] initial = 'class="is-initial" d="M6.0 90.0L153.0 62.0L300.0 34.0L447.0 48.0L594.0 62.0"' assert initial in out["svgOff"] and initial in out["svgOn"] assert 'class="is-plan" d="M6.0 90.0L300.0 62.0L594.0 62.0"' in out["svgOn"] assert "is-initial" not in out["svgOld"] # 옛 답 = 지반 · 균형만 assert "is-plan" not in out["legendOff"] and "적용될 초기 종단" in out["legendOff"] def test_모달_배선과_확인_글() -> None: rec = (B05 / "B05_Profile_UI_RouteEdit_Recommend.ts").read_text(encoding="utf-8") assert '
' in rec assert "profileSvg(balance, initialShape)" in rec assert 'line("profile").hidden = !balance && !initialShape;' in rec apply = rec[rec.index('applyButton.addEventListener("click"') :][:400] assert ( 'showConfirmDialog(await params.confirmText(), "적용")' in apply ) # 492-2 — [저장]과 같은 글 · 수 assert apply.index("showConfirmDialog") < apply.index("params.onApply(picked);") reset = (B05 / "logic" / "B05_Profile_Route_Reset.ts").read_text(encoding="utf-8") assert ( "횡단 손 입력이 지워지고 " in reset and "새 노선으로 다시 셉니다" in reset ) # 요구 277 · 284 css = (B05 / "B05_Profile_UI_Style_RouteRecommend.css").read_text(encoding="utf-8") assert ".b05-routerec__profile .is-initial" in css and "var(--map-route" in css