Files
Aislo/resources/tester/test_560_4_leave_save.py
T
eomsangdonandClaude Opus 5.5 2b1f54aa4c fix(D03): 못 읽은 채 떠남 = 고침 없음 — 처음 깨끗한 값 = 빈 선 (PLAN 572-3)
- 프로젝트 없음 · 불러오기 실패 때 savedJson "" 라 dirty 참 → 떠남 셋 물음이 잘못 뜸(ORCA 실측)
- test_560_4 한 줄 덧

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 18:20:12 +09:00

87 lines
3.5 KiB
Python

"""560-4 D 단계 이동 = 저장 뒤 이동 지킴 시험 — 서버 · 화면 없이 소스만 본다.
단계 아이콘 · [<] [>] · 머리 메뉴 · 뒤로가 한 함수(beforeLeave)를 거치고 · D02 첫 불러오기 실패에도 지도를 세움.
572-3 — D · E 페이지는 공용 가드에 {dirty, save} 를 둠(말없이 저장 없음) · 캐시 = 등록표 · 프로젝트 = currentProjectId."""
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def _src(path: str) -> str:
return (ROOT / path).read_text(encoding="utf-8")
def test_group_step_waits_before_leave():
ts = _src("A00_Common/group_workflow.ts")
assert "beforeLeave?: () => Promise<boolean>" in ts
assert "setLeaveGuard(" in ts # 머리 메뉴 · 뒤로
assert "leave().then((ok) => ok && navigateTo(" in ts # 단계 아이콘 · [<] [>]
def test_d02_leave_saves_and_builds_map_on_fail():
ts = _src("D02_PlanBase/D02_PlanBase_UI_Page.ts")
assert "dirty:" in ts and "save:" in ts and "ui-step-nav" not in ts # 따로 듣개 없음
tail = ts[ts.rindex(" try {") :]
# 불러오기 catch 뒤에 paint() — 실패해도 지도 · 표를 세움
assert re.search(r"\} catch \(error\) \{[^}]*\}\s*active = firstEmpty\(\);\s*paint\(\);", tail)
assert "sameBase" in ts # 옛 캐시는 그때 서버 값이 지금과 같을 때만
# 572-3 D · E — 고침 판별 · 저장 · [폐기] 때 지울 등록표 칸(E03 = 별 저장 진행 중만 · 지울 칸 없음)
DE_GUARDED = {
"D02_PlanBase/D02_PlanBase_UI_Page.ts": "d02-points",
"D03_PlanAnalysis/D03_PlanAnalysis_UI_Page.ts": "d03-plan",
"D04_PlanConfirm/D04_PlanConfirm_UI_Page.ts": "d04-assignees",
"E02_StabGround/E02_StabGround_UI_Page.ts": "e02-ground",
"E03_StabSection/E03_StabSection_UI_Page.ts": None,
"E05_StabReport/E05_StabReport_UI_Page.ts": "e05-report",
"E06_StabRock/E06_StabRock_UI_Page.ts": "e06-rock",
}
DE_PAGES = [
*DE_GUARDED,
"E03_StabSection/E03_StabSection_UI_Prob.ts",
"E04_Stab3D/E04_Stab3D_UI_Page.ts",
"E07_StabArea/E07_StabArea_UI_Page.ts",
]
DE_STATES = [
"d02-points",
"e02-ground",
"e03-prob",
"e04-settings",
"e05-report",
"e06-rock",
"e07-settings",
]
def test_de_pages_guard_leave():
for path, name in DE_GUARDED.items():
ts = _src(path)
call = ts[ts.index("mountGroupStep(root") :]
call = call[: call.index("});")]
assert "dirty: () =>" in call and "save" in call, path
assert "beforeLeave" not in ts, path # 말없이 저장 없음 — 공용 셋 물음
if name:
assert f'discard: () => clearState("{name}", projectId)' in call, path
# D03 — 못 읽은 채(프로젝트 없음 · 불러오기 실패) 떠나면 고침 없음
assert "let savedJson = JSON.stringify(network);" in _src(
"D03_PlanAnalysis/D03_PlanAnalysis_UI_Page.ts"
)
e03 = _src("E03_StabSection/E03_StabSection_UI_Page.ts")
assert "dirty: () => repPending > 0" in e03 and "repPending -= 1" in e03
def test_de_pages_shared_project_and_registry():
for path in DE_PAGES:
ts = _src(path)
assert "CURRENT_PROJECT_ID_KEY" not in ts and "localStorage" not in ts, path
assert "sessionStorage" not in ts, path
if path.endswith("_UI_Page.ts"):
assert "const projectId = currentProjectId();" in ts, path
registry = _src("A00_Common/b_page_state.ts")
for name in DE_STATES:
assert re.search(rf'"{name}": \{{[^}}]*bucket: "draft",[^}}]*scope: "project"', registry), (
name
)