"""346-4 되돌리기 한 줄 — 평면 점 옮김 → 계획고 ▲ → 횡단 카드 고침 → Ctrl+Z 세 번이 거꾸로. ./venv/Scripts/python.exe -m pytest resources/tester/test_346_4_one_undo.py -q 사진 크기(300 KB 칸 셋 × 100단 heap)는 `test_346_4_profile_history.py`. """ from __future__ import annotations import json import subprocess from pathlib import Path import pytest HERE = Path(__file__).resolve().parent ROOT = HERE.parents[1] @pytest.fixture(scope="module") def out() -> dict: run = subprocess.run( # noqa: S603 — 고정 실행 파일 ["node", str(HERE / "helper_346_4_one_undo.cjs")], capture_output=True, text=True, encoding="utf-8", ) assert run.returncode == 0, run.stderr return json.loads(run.stdout) def test_끄는_중간은_안_찍고_놓을_때_한_걸음(out) -> None: assert out["start"]["undo"] is False assert out["heldUndo"] is False edited = out["afterEdits"] assert edited["route"] == 70 and edited["grade"] and edited["cross"] and edited["undo"] def test_Ctrl_Z_세_번이_거꾸로(out) -> None: u1, u2, u3 = out["undo1"], out["undo2"], out["undo3"] assert u1["cross"] is None and u1["grade"] and u1["route"] == 70 # 횡단부터 assert u2["grade"] is None and u2["route"] == 70 # 그다음 계획고 assert out["editorBeforeRouteUndo"] == 0 # 노선이 그대로인 걸음은 편집기를 안 건드림 assert u3["route"] is None and u3["undo"] is False and u3["redo"] # 마지막 평면 · 열 때로 assert out["editorAfterUndo"] == [[50, False, "tag-open", "되돌렸습니다."]] def test_다시하기는_앞으로(out) -> None: assert out["redo1"]["route"] == 70 and out["redo1"]["grade"] is None r3 = out["redo3"] assert r3["route"] == 70 and r3["grade"] and r3["cross"] and r3["redo"] is False # 옮긴 걸음의 고정 · 추천 꼬리표까지 되살림(같은 선의 옛 걸음) assert out["editorAfterRedo"] == [[70, True, "tag-moved", "다시 했습니다."]] assert out["profileReads"] == 6 # 종단도도 걸음마다 다시 읽음 def test_단축키는_사진첩_한_곳(): tools = (ROOT / "B05_Profile/B05_Profile_UI_Profile_Panel_Tools.ts").read_text(encoding="utf-8") assert "undoOwner" not in tools assert 'isCtrlKey(event, "y")' in tools and "setPageHistory(history)" in tools plan = (ROOT / "B05_Profile/B05_Profile_UI_RouteEdit_History.ts").read_text(encoding="utf-8") assert '"keydown"' not in plan assert not (ROOT / "B05_Profile/B05_Profile_UI_RouteEdit_UndoOwner.ts").exists()