feat(B 페이지): 떠남 물음 가드 · 지금 프로젝트 = 탭마다 (PLAN 572-2 · 요구 400~403)
- 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>
This commit is contained in:
@@ -140,6 +140,8 @@ const common = {
|
||||
return true;
|
||||
},
|
||||
},
|
||||
// 572-2 지금 프로젝트 = 탭마다 · 떠남 가드는 test_560_4
|
||||
"../A00_Common/b_project_switch": { currentProjectId: () => "P1", guardProjectLeave() {} },
|
||||
"../A00_Common/b_page_state": {
|
||||
readState: (name) => store.get(name) ?? null,
|
||||
writeState: (name, v) => store.set(name, v),
|
||||
|
||||
@@ -128,6 +128,8 @@ const common = {
|
||||
return true;
|
||||
},
|
||||
},
|
||||
// 572-2 지금 프로젝트 = 탭마다 · 떠남 가드는 test_560_4
|
||||
"../A00_Common/b_project_switch": { currentProjectId: () => "P1", guardProjectLeave() {} },
|
||||
"../A00_Common/b_page_state": {
|
||||
readState: (name) => store.get(name) ?? null,
|
||||
writeState: (name, v) => store.set(name, v),
|
||||
|
||||
@@ -186,8 +186,7 @@ const toasts = [];
|
||||
const sent = [];
|
||||
globalThis.showToast = (m, k) => toasts.push([k, m]);
|
||||
globalThis.API_BASE_URL = "/api";
|
||||
globalThis.CURRENT_PROJECT_ID_KEY = "pid";
|
||||
globalThis.localStorage = { getItem: () => "P1" };
|
||||
globalThis.currentProjectId = () => "P1";
|
||||
let picker = null; // 251-6 단가연결 = 한 창(openLogicPicker · 사전조합 + 덧붙인 줄 구조물 조합)
|
||||
globalThis.openLogicPicker = (done, lib) => { picker = lib;
|
||||
sent.push(["pre", lib.layer, lib.kindFilter.map((k) => k.value), lib.title]); };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""560-4 D 단계 이동 = 저장 뒤 이동 지킴 시험 — 서버 · 화면 없이 소스만 본다.
|
||||
"""560-4 D 단계 이동 = 저장 뒤 이동 · 572-2 B 떠남 물음 지킴 시험 — 서버 · 화면 없이 소스만 본다.
|
||||
단계 아이콘 · [<] [>] · 머리 메뉴 · 뒤로가 한 함수(beforeLeave)를 거치고 · D02 첫 불러오기 실패에도 지도를 세움."""
|
||||
|
||||
import re
|
||||
@@ -25,3 +25,62 @@ def test_d02_leave_saves_and_builds_map_on_fail():
|
||||
# 불러오기 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
|
||||
|
||||
Reference in New Issue
Block a user