"""PLAN 317 — 구조물 측점에서 종류를 바꾸면 횡단을 「구조물 없는 상태」부터 새로(요구 213). - 저장분과 같은 종류 = 저장분 횡단 그대로 - 다른 종류로 바꿈 = 저장분 횡단은 빼 두고 새 자리처럼 미리 뜬 횡단(옛 구조물 흔적 없음) - 저장분 종류로 되돌림 = 빼 둔 저장분 횡단이 돌아옴 실제 TS(`withDraftStations`)를 `helper_317_kind_change_station.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_317_kind_change_station.cjs")], capture_output=True, text=True, encoding="utf-8", timeout=120, check=True, ) return json.loads(out.stdout) def test_same_kind_keeps_saved_section(result: dict) -> None: assert result["same_kind"] == {"count": 2, "fresh": False, "old": True, "preview": False} def test_changed_kind_starts_from_fresh_section(result: dict) -> None: assert result["changed_kind"] == {"count": 2, "fresh": True, "old": False, "preview": True} def test_back_to_saved_kind_restores_saved_section(result: dict) -> None: assert result["back_to_saved"] == {"count": 2, "fresh": False, "old": True, "preview": False} def test_repeated_switch_leaves_no_old_kind(result: dict) -> None: # 박스 → 세월교 — 앞 종류(박스) 제원이 남아 겹치지 않음(317-3) assert result["first_switch"] == ["box"] assert result["second_switch"] == ["ford"]