"""346-4 떠남 확인 — B05 · B06 저장 안 한 조작이 있으면 탭 닫기 · 다른 페이지 때 물음. ./venv/Scripts/python.exe -m pytest resources/tester/test_346_4_design_leave.py -q """ from __future__ import annotations import json import subprocess from pathlib import Path import pytest HELPER = Path(__file__).resolve().parent / "helper_346_4_design_leave.cjs" @pytest.fixture(scope="module") def out() -> dict: run = subprocess.run( # noqa: S603 — 고정 실행 파일 ["node", str(HELPER)], 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["emptyDirty"] is False assert out["nonEditDirty"] is False and out["nonEditUnload"] is False assert out["nonEditLeave"] is True and out["askedNonEdit"] == 0 def test_횡단_초안이면_물음(out) -> None: assert out["editDirty"] is True and out["editUnload"] is True assert out["cancelLeave"] is False def test_B05_B06_사이는_안_묻고_다시_걺(out) -> None: assert out["samePage"] is True and out["reArmed"] is True and out["askedSamePage"] == 0 def test_저장_실패는_머묾_성공_뒤엔_안_물음(out) -> None: assert out["saveFailLeave"] is False assert out["saveLeave"] is True and out["saves"] == 2 assert out["afterSaveDirty"] is False and out["afterSaveUnload"] is False assert out["afterSaveLeave"] is True and out["askedAfterSave"] == 0 def test_버리고_넘어감은_고침_칸만_지움(out) -> None: assert out["reEditDirty"] is True and out["discardLeave"] is True left = out["left"] assert left["crossdesign"] is None and left["alignment"] is None and left["routeDraft"] is None assert left["selection"] and left["stdCross"] and left["b08"] assert out["afterDiscardDirty"] is False def test_페이지가_빠지면_안_물음(out) -> None: assert out["goneLeave"] is True and out["goneUnload"] is False and out["askedGone"] == 0