- A00_Common/design/design_store.ts — useDesignStore(projectId, routeId) get · set · subscribe
(structures · pipes · alignmentDraft · sectionDetail · selection) · 밑은 b_page_state 등록 키
(selection 등록 · alignmentDraft 는 옛 키 감쌈 — 브레인 판정 B)
- A00_Common/design/design_save.ts — saveDesign(ctx, {confirm}) 한 줄기:
관 → 구조물 → 계획고 → 암거 옵션 → 오르막 → 횡단 · B05 [임시저장] · B06 [저장] · [확정]이 같은 차례
- 계획고 초안 가게 노선마다 한 벌(B05 Profile_Edit 주인 · B06 Grade_Edit 는 useProfileEditStore)
- 관 목록 주인 = 가게 pipes(Pipes_Draft 창구)
- 시험: test_design_store_save 추가 · save_channels · save_recompute · save_roundtrip 새 차례로
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KmELpdXFDRZHhfbGuRhSmL
54 lines
2.7 KiB
Python
54 lines
2.7 KiB
Python
"""[저장]·[확정]은 **면적을 모으기 전에** 전 측점을 다시 계산한다 (2026-09-09 실측).
|
|
|
|
⚠ 잡은 자리 — 표준단면 「암 측구 상폭」을 0.69 → 0.9 로 고쳐 저장했더니 정본 한 줄에
|
|
**새 측구 기하(상폭 0.9 · 측구 0.18㎡)** 와 **옛 절토 면적(0.69 기준 3.33㎡)** 이 섞여
|
|
남았다. 브라우저는 만진 측점만 다시 계산하는데 저장은 **전 측점 면적**을 실어 보내므로,
|
|
안 만진 측점이 옛 값 그대로 정본이 된다.
|
|
(같은 입력을 주면 파이썬·TS 는 같은 값을 낸다 — 거울 문제가 아니라 **입력이 갈린 것**이다.)
|
|
|
|
⇒ `saveCurrentSections`·`confirmCurrentSections` 가 `collectSectionEdits` **앞에서**
|
|
`ctx.reconcileDesigns()` 를 부른다. 순서가 뒤집히면 옛 면적이 그대로 실린다.
|
|
(계획서 24-2a — 둘 다 저장 한 줄기 `saveDesign` 을 탄다: B06 창구 `sectionSaveContext` 의
|
|
`prepare` 가 재계산, `cross` 가 면적 수집이고, `saveDesign` 이 `prepare` 를 먼저 부른다.)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
PERSIST = ROOT / "B06_Section" / "B06_Section_UI_Page_Persist.ts"
|
|
PAGE = ROOT / "B06_Section" / "B06_Section_UI_Page.ts"
|
|
SAVE = ROOT / "A00_Common" / "design" / "design_save.ts"
|
|
|
|
|
|
def _body(source: str, marker: str) -> str:
|
|
start = source.index(marker)
|
|
return source[start : start + 1200]
|
|
|
|
|
|
def test_저장이_면적을_모으기_전에_다시_계산한다() -> None:
|
|
text = PERSIST.read_text(encoding="utf-8")
|
|
for marker in (
|
|
"export async function saveCurrentSections",
|
|
"export async function confirmCurrentSections",
|
|
):
|
|
assert "saveDesign(sectionSaveContext(" in _body(text, marker)[:400], (
|
|
f"{marker} 가 B06 창구로 저장 한 줄기를 안 탄다"
|
|
)
|
|
body = _body(text, "function sectionSaveContext")
|
|
assert "prepare: () => ctx.reconcileDesigns()" in body, "B06 창구가 재계산을 안 넘긴다"
|
|
assert "collectSectionEdits(ctx)" in body[body.index("cross:") :], "면적 수집이 횡단 차례 밖"
|
|
save = SAVE.read_text(encoding="utf-8")
|
|
run = _body(save, "export async function saveDesign")
|
|
assert run.index("ctx.prepare?.()") < run.index("ctx.cross(confirm)"), (
|
|
"저장 한 줄기가 재계산보다 면적 수집을 먼저 부른다 — 옛 면적이 실린다"
|
|
)
|
|
|
|
|
|
def test_페이지가_재계산_통로를_이어_준다() -> None:
|
|
text = PAGE.read_text(encoding="utf-8")
|
|
assert "reconcileDesigns: () => reconcileStaleDesigns({ force: true })" in text, (
|
|
"페이지가 통로를 안 이어 주면 저장이 옛 값 그대로 나간다"
|
|
)
|