- B04 · B07 · B08 · B09 가 공용 guardProjectLeave 에 {dirty, save, discard} 등록 — 고침 있을 때만 [취소 · 폐기 · 저장]
- B04 = 관 지점 고침(drainageDirty) · 저장 = 관 지점 · 세부유역 영구저장
- B07 = CAD · 탭 고침 · 저장 = saveEditedDrawings · 폐기 = 고친 도면 CAD 자동백업도 버림(discardEditedRecovery)
- B08 = 세션 b08-* 칸 넷 · 저장 = saveShown · B09 = b09-estimation 칸 · 저장 = saveChanged
- 지금 프로젝트 직접 읽기(localStorage) → currentProjectId() · B02 새 프로젝트 = setCurrentProject — B02 · B03 · B04 · B07 · B08 · B09 · B11
- 다른 프로젝트 보관함 지우기 셋(B04 · B05 종단 · B11) 뺌 — enterProject 한 곳 · 다른 탭 보관분 안 지움
- B02 · B03 은 가드 없음 — 저장 안 한 프로젝트 값 없음(B03 올리기 끊김은 이어 올리기 배너가 받음)
- 시험 test_560_4 넓힘(B 가드 · 탭 프로젝트 · 보관함) · helper_298_2 · helper_481_2 · test_204_2 흉내를 currentProjectId 로
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
3.4 KiB
Python
87 lines
3.4 KiB
Python
"""560-4 D 단계 이동 = 저장 뒤 이동 · 572-2 B 떠남 물음 지킴 시험 — 서버 · 화면 없이 소스만 본다.
|
|
단계 아이콘 · [<] [>] · 머리 메뉴 · 뒤로가 한 함수(beforeLeave)를 거치고 · D02 첫 불러오기 실패에도 지도를 세움."""
|
|
|
|
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 "beforeLeave:" 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-2 B 페이지 떠남 물음 — 공용 가드에 {dirty, save} · 지금 프로젝트 = 탭마다(currentProjectId)
|
|
B_GUARDS = {
|
|
"B04_PreProcess/B04_PreProcess_UI_Page.ts": (
|
|
"mapViewer.drainageDirty",
|
|
"mapViewer.commitDrainage",
|
|
),
|
|
"B07_DesignDetail/B07_DesignDetail_UI_Page.ts": (
|
|
"cadDirty || tabs.anyDirty()",
|
|
"saveEditedDrawings(store)",
|
|
),
|
|
"B08_Quantity/B08_Quantity_UI_Page.ts": ("readState(name, projectId)", "save: saveShown"),
|
|
"B09_Estimation/B09_Estimation_UI_Shell.ts": (
|
|
'readState("b09-estimation", projectId)',
|
|
"save: saveChanged",
|
|
),
|
|
}
|
|
|
|
B_PROJECT_READS = [
|
|
"B02_ProjRegister/B02_ProjRegister_UI_Page.ts",
|
|
"B03_FileInput/B03_FileInput_UI_Page.ts",
|
|
"B03_FileInput/B03_FileInput_UI_Page_Flow.ts",
|
|
"B03_FileInput/B03_FileInput_UI_PlanImport.ts",
|
|
*B_GUARDS,
|
|
"B09_Estimation/B09_Estimation_UI_Tabs_Bill_Link.ts",
|
|
"B09_Estimation/B09_Estimation_UI_Tabs_Base_Quote.ts",
|
|
"B09_Estimation/B09_Estimation_UI_Haul_Modal.ts",
|
|
"B09_Estimation/draft/B09_Draft_Print_Page.ts",
|
|
"B11_Status/B11_Status_UI_Loading.ts",
|
|
]
|
|
|
|
|
|
def test_b_pages_guard_leave():
|
|
for path, (dirty, save) in B_GUARDS.items():
|
|
ts = _src(path)
|
|
at = ts.index("guardProjectLeave(layout.root, {")
|
|
block = ts[at : ts.index("});", at)]
|
|
assert dirty in block and save in block, path
|
|
b07 = _src("B07_DesignDetail/B07_DesignDetail_UI_Page.ts")
|
|
assert "discard: () => discardEditedRecovery(store)" in b07 # 폐기 = CAD 자동백업도
|
|
|
|
|
|
def test_b_pages_read_tab_project():
|
|
for path in B_PROJECT_READS:
|
|
ts = _src(path)
|
|
# 탭 공용 localStorage 직접 읽기 · 쓰기 없음
|
|
assert "CURRENT_PROJECT_ID_KEY" not in ts, path
|
|
assert "currentProjectId()" in ts or "setCurrentProject(" in ts, path
|
|
|
|
|
|
def test_b_pages_leave_other_project_cache_to_enter():
|
|
# 다른 프로젝트 보관함 지우기 = enterProject 한 곳(다른 탭 보관분을 지우지 않게)
|
|
for path in (
|
|
"B04_PreProcess/B04_PreProcess_UI_Page.ts",
|
|
"A00_Common/design/design_view_profile.ts",
|
|
"B11_Status/B11_Status_UI_Loading.ts",
|
|
):
|
|
assert "purgeOtherProjects" not in _src(path), path
|