- 시설 폼 칸에 옵션 키 표식(data-option-keys) · 끈 키의 칸은 가림 · 칸이 다 가려진 줄은 줄째 - 키가 여럿인 칸(본체 규격 · 유입구 구조)은 키가 다 꺼졌을 때만 가림 · 독립 기슭막이는 유입 · 유출 채널 키로 넓힘 - 숨긴 칸은 칸 값(제안값 채우기 포함)이 아니라 폼이 받은 옛 값을 저장에 그대로 실음 · 이 폼에는 필수 검사가 없음 - 가리기 코드는 새 파일(_Facility_Hidden)로 분리해 Facility.ts 700줄 아래 유지 - 시험 3개 추가 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TULoa94ZFL26KU6ZqVpjkF
175 lines
7.2 KiB
Python
175 lines
7.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""B05/B06 좌측 패널 「집계 항목」 회귀검증 — PLAN 21-4 (2026-09-29).
|
|
|
|
폼 옵션 보이기(`visible`) · [수정] 옵션 보존(안 그린 칸 · 상세 칸) · 집계 항목 줄(이름 ·
|
|
고르기 · 해제) · 관 계열 merge · 목록 줄 색(`.is-assigned`) + 툴팁을 본다.
|
|
화면 그릇은 Node 헬퍼가 흉내낸다(`helper_b05_structures_form_summary.cjs` —
|
|
TS 를 그 자리에서 트랜스파일).
|
|
실제 화면 조작은 ORCA(자체 확인)로 따로 본다.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
A_KEY = "SS000007"
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def out():
|
|
proc = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_b05_structures_form_summary.cjs")],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def test_visible_false_만_숨김(out):
|
|
assert out["visible"] == [True, True, False]
|
|
|
|
|
|
def test_visible_false_옵션은_폼에_안_그림_정의는_그대로(out):
|
|
assert out["drawB05"] == {
|
|
"keys": ["height_m"],
|
|
"hidden": False,
|
|
} # 길이 숨김 · 상세는 B05 에 없음
|
|
assert out["drawB06"]["keys"] == ["height_m", "stone_kind"] # B06 은 상세까지 · 숨김은 여기도
|
|
assert out["definitionKept"] == ["height_m", "length_m", "stone_kind", "back_len_cm"]
|
|
|
|
|
|
def test_수정은_안_그린_칸을_보존(out):
|
|
# 폼이 그린 H · stone_kind 는 갈아 끼우고, 안 그린 상세 칸 · 숨긴 칸은 옛 값 그대로
|
|
assert out["mergeSame"] == {"back_length_m": 0.6, "memo_only": "x", "H": 3}
|
|
|
|
|
|
def test_그린_칸을_비우면_지워짐(out):
|
|
assert out["mergeCleared"] == {"back_length_m": 0.6, "memo_only": "x"}
|
|
|
|
|
|
def test_종류를_바꾸면_통째로_새_값(out):
|
|
assert out["mergeTypeChange"] == {"H": 1}
|
|
assert out["mergeNoPrev"] == {"H": 9}
|
|
assert out["mergePrevNoOptions"] == {"H": 9}
|
|
|
|
|
|
def test_참조_모양_검사(out):
|
|
assert out["isItem"] == [True, False, False, False]
|
|
assert out["readItem"] == [A_KEY, None]
|
|
assert out["same"] == [True, False, True, False] # 이름만 바뀌면 같음
|
|
|
|
|
|
def test_키는_앞에_안_내세움_툴팁에만(out):
|
|
assert out["label"] == ["미지정", "돌기슭막이 메쌓기 1.2m"]
|
|
assert A_KEY not in out["label"][1]
|
|
assert A_KEY in out["tip"][1] and "개인용" in out["tip"][1]
|
|
assert out["rowSet"]["nameShowsKey"] is False
|
|
|
|
|
|
def test_집계_항목_줄(out):
|
|
empty = out["rowEmpty"]
|
|
assert (empty["name"], empty["assigned"], empty["clearDisabled"], empty["get"]) == (
|
|
"미지정",
|
|
False,
|
|
True,
|
|
None,
|
|
)
|
|
assert (empty["label"], empty["pick"], empty["clear"]) == ("집계 항목", "고르기", "해제")
|
|
row = out["rowSet"]
|
|
assert row["assigned"] is True and row["clearDisabled"] is False
|
|
assert row["name"] == "돌기슭막이 메쌓기 1.2m" and A_KEY in row["title"]
|
|
assert out["clicks"] == ["pick", "clear"]
|
|
assert out["rowCleared"] == {"name": "미지정", "clearDisabled": True}
|
|
|
|
|
|
def test_관_계열_merge_가_집계_항목을_잇고_지움(out):
|
|
assert out["pipeKeep"]["key"] == A_KEY # 다음 값에 칸이 없으면 옛 지정을 이음
|
|
assert out["pipeClear"] is None # 폼이 null 을 보내면 해제
|
|
assert out["pipeSet"] == "SS000004" # 다른 항목으로 바꿈
|
|
|
|
|
|
def test_목록_줄_색과_툴팁(out):
|
|
rows = out["list"] # 측점 순: 구조물(지정) · 구조물(미지정) · 관(지정) · 관(미지정)
|
|
assert [r["assigned"] for r in rows] == [True, False, True, False]
|
|
assert A_KEY in rows[0]["title"] and "SS000004" in rows[2]["title"]
|
|
assert rows[1]["title"] == "" and rows[3]["title"] == "" # 미지정은 지금 그대로
|
|
|
|
|
|
def test_저장_기록에_집계_항목이_실리고_해제하면_칸이_빠짐(out):
|
|
# 새 구조물(미지정) — 칸을 아예 안 실음(서버가 모르는 칸을 거절하는 동안에도 저장이 안 깨짐)
|
|
assert out["commitNew"] == {"hasKey": False, "options": {"H": 3}}
|
|
# 지정돼 있던 것을 해제 — 옛 지정이 살아오지 않음 · 안 그린 칸은 보존
|
|
assert out["commitCleared"]["hasKey"] is False
|
|
assert out["commitCleared"]["options"] == {"hidden_cost_key": "keep", "detail_only": 9, "H": 3}
|
|
# 지정 유지 · 바꿈
|
|
assert out["commitKept"] == {
|
|
"key": A_KEY,
|
|
"options": {"hidden_cost_key": "keep", "detail_only": 9, "H": 3},
|
|
}
|
|
assert out["commitSwapped"] == "SS000004"
|
|
|
|
|
|
def test_집계_항목만_바뀌면_폼_검증과_무관하게_기록에_반영(out):
|
|
# 흠 2 — 필수 옵션이 비면 종전 commit 은 조용히 멈춤
|
|
assert out["formBlocks"] is True
|
|
# 집계 항목 전용 반영은 그 검증을 안 거침 · 옵션은 그대로
|
|
assert out["summaryOnlyAssign"] == {
|
|
"done": True,
|
|
"key": "SS000004",
|
|
"options": {"H": 2, "hidden_cost_key": "keep", "detail_only": 9},
|
|
}
|
|
assert out["summaryOnlyClear"] == {"done": True, "hasKey": False}
|
|
assert out["summaryOnlyNew"] is False
|
|
|
|
|
|
def test_배수유역_화면은_들어올_때_세션_초안_관을_먼저_씀():
|
|
# 흠 3 — B05→B06→B05 를 오가도 저장 전 지정 · 옵션이 옛값으로 안 돌아감
|
|
source = open(
|
|
os.path.join(HERE, "..", "..", "B05_Profile", "B05_Profile_UI_Drainage_Panel.ts"),
|
|
encoding="utf-8",
|
|
).read()
|
|
body = source.split("const loadSaved", 1)[1].split("/**", 1)[0]
|
|
assert "readPendingPipes(" in body and "computeDetailBasins(" in body
|
|
assert body.index("readPendingPipes(") < body.index("fetchDetailPipePoints(")
|
|
|
|
|
|
def test_시설_폼_끈_옵션_가리기(out):
|
|
# 칸 표식 — 키 하나 · 여럿 · 없음
|
|
assert out["labelTag"] == ["pipe_kind", "inlet_type inlet_structure", None]
|
|
none = dict(kind=False, dia=False, rowA=False, inlet=False, free=False, rowB=False)
|
|
assert out["hideOne"] == {**none, "kind": True}
|
|
# 줄의 칸이 다 가려지면 줄째 · 표식 없는 칸은 그대로
|
|
assert out["hideRow"] == {**none, "kind": True, "dia": True, "rowA": True}
|
|
assert out["hideInletPartial"] == none
|
|
assert out["hideInlet"] == {**none, "inlet": True}
|
|
assert out["showAll"] == none # [모두 보임] 뒤 되돌아옴
|
|
|
|
|
|
def test_숨긴_칸은_옛_값_그대로_저장에_실림(out):
|
|
# 칸에서 읽은 값(VR관 · 제안)이 아니라 폼이 받은 옛 값 — 안 숨긴 칸은 칸 값
|
|
assert out["restored"] == {"pipe_kind": "흄관", "pipe_diameter_mm": 800, "other": 2}
|
|
# 옛 값이 없던 숨긴 칸은 값이 안 실림(칸의 제안값이 몰래 확정되지 않음)
|
|
assert out["restoredEmpty"] == {"pipe_diameter_mm": 800}
|
|
|
|
|
|
def test_끈_키를_폼_칸_키로_넓힘(out):
|
|
# 독립 기슭막이는 유입 · 유출 채널 키로 · 유입구 구조는 inlet_structure 까지
|
|
assert out["revetKeys"] == sorted(
|
|
[
|
|
"form",
|
|
"height_m",
|
|
"side",
|
|
"inlet_revet_form",
|
|
"outlet_revet_form",
|
|
"inlet_revet_height_m",
|
|
"outlet_revet_height_m",
|
|
]
|
|
)
|
|
assert out["pipeKeys"] == ["inlet_structure", "inlet_type"]
|
|
assert out["otherKeys"] == ["form"]
|