"""PLAN 323-9 ① — B06 [저장] 뒤 카드가 저장 전 서버 상태로 돌아가던 흠. 저장 도중 바뀜 신호(초안이 정본으로 나가며 비워짐)가 낡은 상세 캐시 · 빈 초안으로 다시 그렸고, 뒤처리는 캐시만 비우고 다시 안 그렸음 → 저장 도중엔 안 그림 · 뒤처리가 서버 새 상세로 한 번 그림. Node 헬퍼 = `helper_323_9_save_redraw.cjs`(진짜 저장 차례 · 횡단 뒤처리 · 상세 캐시). """ from __future__ import annotations import json import subprocess from pathlib import Path import pytest HERE = Path(__file__).parent ROOT = HERE.parent.parent pytestmark = pytest.mark.skipif( not (ROOT / "config" / "node_modules").is_dir(), reason="프론트엔드 의존성 미설치" ) @pytest.fixture(scope="module") def out() -> dict: run = subprocess.run( ["node", str(HERE / "helper_323_9_save_redraw.cjs")], capture_output=True, text=True, encoding="utf-8", timeout=120, check=True, ) return json.loads(run.stdout) def test_after_save_cards_show_server_new_detail(out: dict) -> None: assert out["ok"] is True assert out["before"] == "옛 자리 4+5" assert out["after"] == "새 자리 4+8 · 47+0" def test_no_redraw_from_stale_cache_while_saving(out: dict) -> None: assert out["savingSeen"] == [True, False] and out["savingIdle"] is False # 저장 도중 신호는 건너뜀 · 뒤처리가 새로 한 번 받음(오버레이 안) assert out["calls"] == [ "overlay:on", "refresh:skip", "cross:save", "fetch:새 자리 4+8 · 47+0", "overlay:off", ] def test_cross_view_wires_guard_and_redraw() -> None: view = (ROOT / "A00_Common" / "design" / "design_view_cross.ts").read_text("utf-8") body = view[view.index("async function refreshDetailForStructures") :] body = body[: body.index("loadSectionDetail")] assert "++structuresRefreshSeq" in body and "savingDesign(projectId)" in body assert "redraw: () => (host.visible() ? refreshDetailForStructures()" in view