"""421 추천 창 — 「측점 맞춤」 → 「종단 반영」 · [재계산] 늘 켜짐 + `recompute`. ./venv/Scripts/python.exe -m pytest resources/tester/test_421_recommend_profile.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_421_profile_toggle.cjs") def _read(name: str) -> str: return (B05 / name).read_text(encoding="utf-8") def test_종단_반영_값_정하기() -> None: out = json.loads( subprocess.run( ["node", str(HELPER)], capture_output=True, text=True, encoding="utf-8", check=True ).stdout ) assert out["sent"] is False # 옛 서버 = 보낸 값 assert out["server"] is True # 서버 답 `with_profile` 이 먼저 assert out["serverHasUnsnapped"] is False # 맞추기 전 선은 화면이 안 씀 assert out["oldFollow"] is False and out["oldEarth"] is True # 옛 캐시 = 갈래로 assert out["base"] is False and out["baseProfile"] is False assert out["oldBase"] is None and out["oldBaseProfile"] is True assert out["sameOff"] is True and out["sameOn"] is False and out["sameOld"] is True assert out["readBack"] is False # 캐시에 남아 다시 열 때 되살림 def test_창_단추와_재계산() -> None: rec = _read("B05_Profile_UI_RouteEdit_Recommend.ts") assert "측점 맞춤" not in rec and "snapOn" not in rec and "unsnapped" not in rec assert 'toggleButton("종단 반영", profileOn,' in rec assert "let profileOn = params.withProfile;" in rec toggle = rec[rec.index('toggleButton("종단 반영"') :][:200] assert "profileOn = active;" in toggle and "void run();" in toggle # 누르면 바로 assert "rerun.before(profileToggle);" in rec assert "rerun.disabled = busy || invalid.size > 0;" in rec # 늘 켜짐 assert 'rerun.addEventListener("click", () => void run(true));' in rec assert "const withProfile = profileOn;" in rec assert "params.onApply(preview);" in rec def test_요청과_적용에_종단_반영() -> None: init = _read("B05_Profile_UI_RouteEdit_Initial.ts") assert "with_profile: withProfile," in init assert "...(recompute ? { recompute: true } : {})," in init assert "withProfile: choice?.withProfile ?? base.withProfile ?? true," in init on_apply = init[init.index("onApply: (picked) => {") :][:900] assert "with_profile: choiceWithProfile(picked)," in on_apply assert on_apply.count("choiceWithProfile(picked)") == 2 # 저장 칸 · 균형 종단 assert "withProfileOf(" not in init assert "with_profile: choiceWithProfile(now)" in init # [저장]에도 실음 api = _read("B05_Profile_Api_RouteInitial.ts") assert "recompute?: boolean;" in api def test_도움말_글() -> None: help_ts = _read("B05_Profile_UI_RouteEdit_Recommend_Help.ts") assert "「측점 맞춤」을 끄면" not in help_ts and "끔 = 옮기기 전 선" not in help_ts assert 'name: "재계산",' in help_ts and 'name: "측점 맞춤(늘)",' in help_ts assert "단추로 켬 · 끔(기본 켬 · 다섯 갈래 모두)" in help_ts