"""PLAN 386-2 sub7 — B05 · B06 한 페이지 자료 줄(`design_page_data.ts`). 못박는 것 - 저장분(구조물 · 관 · 정의 판 확인) = 페이지에서 한 번 — 묶음 · 두 보기 구조물 칸 · 초안 측점이 같은 줄. - 보기 전환 · 다시 보임 = 요청 0(구조물 칸 load 가 직접 안 받음). - 저장 정본이 바뀌면(`invalidateSectionDetail` → `forgetDraftStations`) · 페이지를 떠나면 비움 → 한 번 다시. - 돌려줄 때마다 사본 · 실패는 기억 안 함 · 「계산 중」 점 = 묶음 차례가 떠 있는 동안. 짝: `helper_384_2_page_data.cjs`(진짜 TS · 서버 흉내). """ from __future__ import annotations import json import subprocess from pathlib import Path import pytest HERE = Path(__file__).resolve().parent ROOT = HERE.parents[1] def _read(rel: str) -> str: return (ROOT / rel).read_text(encoding="utf-8") @pytest.fixture(scope="module") def r() -> dict: proc = subprocess.run( # noqa: S603 — 고정 실행 파일 ["node", str(HERE / "helper_384_2_page_data.cjs")], capture_output=True, text=True, encoding="utf-8", timeout=60, ) assert proc.returncode == 0, proc.stderr return json.loads(proc.stdout) def test_저장분_한_번(r): assert r["open"] == {"structures": 1, "pipes": 1, "version": 1} assert r["other"] == 2 # 다른 프로젝트는 따로 def test_돌려줄_때마다_사본(r): assert r["copy"] == {"same": False, "after": 1} def test_비우면_한_번_다시(r): assert r["afterForget"]["structures"] == 3 # p1 · p2 · 비운 뒤 p1 한 번 def test_실패는_기억_안_함(r): assert r["failed"] == "error" assert r["retry"] == 3 # 처음 · 실패 · 다시 def test_계산_중_점(r): assert r["midBusy"] is True assert r["busy"][0] is False and r["busy"][-1] is False # 듣기 시작 = 지금 상태 · 끝나면 끔 assert len(r["busy"]) <= 6 # 뗀 뒤 차례는 안 알림 @pytest.mark.parametrize( "rel", [ "A00_Common/design/design_pipeline_page.ts", "B05_Profile/B05_Profile_UI_Page_Structures.ts", "B06_Section/B06_Section_UI_Page_Structures_Panel.ts", "B06_Section/B06_Section_Section_Drafts.ts", ], ) def test_보기_전환_길은_자료_줄만(rel): src = _read(rel) assert "dropStaleStructureTypes(" not in src assert "fetchDetailPipePoints(" not in src assert "pageStructures(" in src # B05 구조물 칸은 [저장] 직전 판번호 · 저장 뒤 목록만 직접 받음 if "Page_Structures.ts" not in rel: assert "fetchStructures(" not in src def test_비우는_자리(): drafts = _read("B06_Section/B06_Section_Section_Drafts.ts") page = _read("A00_Common/design/design_page.ts") store = _read("B06_Section/B06_Section_Section_Store.ts") assert "forgetPageData(projectId)" in drafts # 저장 정본 바뀜(invalidate → forgetDraftStations) assert "forgetDraftStations(projectId)" in store assert "forgetPageData(projectId, true)" in page # 페이지를 떠남(노선 id 칸도 · 386-2b) assert "onPageBusy(projectId" in page def test_계산_중_점은_묶음_차례(): pipe = _read("A00_Common/design/design_pipeline_page.ts") dock = _read("A00_Common/design/design_dock.ts") assert pipe.count("trackPageBusy(projectId") == 2 # 열 때 start · 조작 feed assert "setBusy" in dock and "Design_Busy" in dock