Files
Aislo/resources/tester/test_401_project_isolation.py
T
eomsangdonandClaude Opus 5.5 6d7657aeb9 fix(공용): 떠남 [취소] 뒤 단계 [<] [>] 흐려짐 — 주소 되돌림 알림 (PLAN 572)
- main.ts 취소 갈래 = replaceState 뒤 aislo:route-restored 냄(hashchange 가 안 뜸)
- ui_template_help [<] [>] sync 가 그 알림에도 다시 맞춤 · 화면에서 빠지면 둘 다 풂
- test_401 소스 대조 하나 더함

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

121 lines
5.4 KiB
Python

"""401 프로젝트마다 따로 동작(요구 400~403 · PLAN 572).
- 지금 프로젝트 = 탭마다(탭 세션 칸 먼저 · 새 탭 = 마지막 값) · 다른 프로젝트 화면을 그리려 하면 새로 엶
- 떠남 = 그 프로젝트 세션 칸 · 준비 표식 · 3D 보관함 몫만 지움 · 밖 칸 · 취향 · CAD 복구본 · 다른 탭은 그대로
- 떠남 물음 = 화면에 붙은 가드 {dirty, save} 를 모아 [취소 · 폐기 · 저장] 한 번
`helper_401_project_isolation.cjs` 가 진짜 TS 를 가짜 저장소 · 가짜 IndexedDB 위에서 돌림.
"""
import json
import os
import re
import subprocess
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[2]
HERE = os.path.dirname(os.path.abspath(__file__))
X = "11111111-aaaa-4aaa-8aaa-000000000001"
Y = "22222222-bbbb-4bbb-8bbb-000000000002"
#: 아직 직접 읽는 B · D · E 페이지(572-2 · 572-3 창 몫) — 고치면 여기서 뺌.
PENDING = {
"B03_FileInput/B03_FileInput_UI_Page.ts",
"B03_FileInput/B03_FileInput_UI_Page_Flow.ts",
"B03_FileInput/B03_FileInput_UI_PlanImport.ts",
"B04_PreProcess/B04_PreProcess_UI_Page.ts",
"B07_DesignDetail/B07_DesignDetail_UI_Page.ts",
"B08_Quantity/B08_Quantity_UI_Page.ts",
"B09_Estimation/B09_Estimation_UI_Haul_Modal.ts",
"B09_Estimation/B09_Estimation_UI_Shell.ts",
"B09_Estimation/B09_Estimation_UI_Tabs_Base_Quote.ts",
"B09_Estimation/B09_Estimation_UI_Tabs_Bill_Link.ts",
"B09_Estimation/draft/B09_Draft_Print_Page.ts",
"B11_Status/B11_Status_UI_Loading.ts",
"D02_PlanBase/D02_PlanBase_UI_Page.ts",
"D03_PlanAnalysis/D03_PlanAnalysis_UI_Page.ts",
"D04_PlanConfirm/D04_PlanConfirm_UI_Page.ts",
"E02_StabGround/E02_StabGround_UI_Page.ts",
"E03_StabSection/E03_StabSection_UI_Page.ts",
"E04_Stab3D/E04_Stab3D_UI_Page.ts",
"E05_StabReport/E05_StabReport_UI_Page.ts",
"E06_StabRock/E06_StabRock_UI_Page.ts",
"E07_StabArea/E07_StabArea_UI_Page.ts",
}
@pytest.fixture(scope="module")
def out():
proc = subprocess.run(
["node", os.path.join(HERE, "helper_401_project_isolation.cjs")],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
def test_탭마다_지금_프로젝트(out):
assert out["newTabStartsWithLast"] == X
assert out["tabs"] == {"a": X, "b": Y, "fresh": Y, "last": Y}
def test_다른_프로젝트_화면은_새로_엶(out):
assert out["reload"] == {"first": False, "same": False, "other": True, "count": 1}
def test_떠남은_그_프로젝트_몫만_지움(out):
leave = out["leave"]
assert leave["keys"] == leave["expected"] # B · D · E · 옛 키 · 준비 표식 0 · 밖 칸 그대로
assert leave["entered"] == X # 탭 프로젝트 표식은 남김
assert leave["local"] == ["1", "1"] # 취향 · CAD 복구본
assert leave["idb"] == [f"{Y}|u1"] # 보관함 = X 줄만 지움
assert leave["otherTabKept"] == "1" # 다른 탭 세션은 안 건드림
def test_떠남_물음_한_번(out):
g = out["guard"]
assert g["armed"] and g["cleanLeave"] and not g["cleanUnload"] and g["asked0"] == 0
assert g["dirtyUnload"] and g["cancel"] is False and g["save"] is True
assert g["messages"] == ["둘째 글", "둘째 글"] # 고친 가드 하나 = 그 글
assert g["saveFail"] is False and g["discard"] is True
assert g["saves"] == [2, 1] and g["discards"] == 1 # 고친 가드만 저장
assert g["samePage"] and g["reArmed"] and g["samePageAsked"] == 0
def test_지금_프로젝트_직접_읽기는_한_곳():
hits = set()
tracked = subprocess.run(
["git", "ls-files", "*.ts"], cwd=ROOT, capture_output=True, text=True, check=True
).stdout.split() # storage · node_modules 는 훑지 않음
for rel in tracked:
text = (ROOT / rel).read_text(encoding="utf-8", errors="ignore")
if re.search(r"localStorage\.getItem\(\s*CURRENT_PROJECT_ID_KEY", text):
hits.add(rel)
assert hits - PENDING == {"A00_Common/b_project_switch.ts"} - PENDING
assert "A00_Common/b_project_switch.ts" in hits
def test_공용이_도우미를_씀():
router = (ROOT / "A00_Common/router.ts").read_text(encoding="utf-8")
assert "export const isProjectRoute" in router and "reloadIfOtherProject()" in router
group = (ROOT / "A00_Common/group_workflow.ts").read_text(encoding="utf-8")
assert "guardProjectLeave(root, { dirty, save, discard, message })" in group
leave = (ROOT / "A00_Common/design/design_leave.ts").read_text(encoding="utf-8")
assert "guardProjectLeave(root, {" in leave
state = (ROOT / "A00_Common/b_page_state.ts").read_text(encoding="utf-8")
for name in ("d02-points", "e02-ground", "e03-prob", "e04-settings", "e05-report"):
assert f'"{name}": {{ bucket: "draft", scope: "project"' in state
assert '"e06-rock"' in state and '"e07-settings"' in state
def test_떠남_취소_뒤_단계_단추_다시_맞춤():
# [취소] = 주소만 되돌림(hashchange 없음) → 「되돌림」 알림으로 [<] [>] 다시 맞춤
main = (ROOT / "A00_Common/main.ts").read_text(encoding="utf-8")
assert "window.dispatchEvent(new Event(ROUTE_RESTORED_EVENT))" in main
help_ts = (ROOT / "ui_template/ui_template_help.ts").read_text(encoding="utf-8")
assert "window.addEventListener(ROUTE_RESTORED_EVENT, onHash);" in help_ts