- test_design_view_parity.py 10건 — 두 보기 공용 칸 DOM · 단추 넷 차례 · 보기 전환 글자 · 페이지 파일이 좌측 칸 · 단추를 직접 만들면 빨강 - 아래 단추 글자가 두 줄로 꺾이지 않게 design_dock.css Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EauA2ATmqNRbeV48s9CcBr
139 lines
5.2 KiB
Python
139 lines
5.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""B05 · B06 한 페이지 두 보기 — **좌측 패널 같음 지킴**(계획서 24-2f).
|
|
|
|
① 두 보기의 좌측 패널을 같은 견본으로 세워 공용 칸(구조물 배치)의 DOM · 아래 고정 영역이 같은지 본다
|
|
(Node 헬퍼 `helper_design_view_parity.cjs` 가 등록부를 트랜스파일해 가짜 DOM 위에서 돌린다).
|
|
② 페이지 파일(`B05_Profile_UI_Page.ts` · `B06_Section_UI_Page.ts`)이 좌측 칸 · 아래 단추 · 저장 단추를
|
|
직접 만들면 빨강 — 칸과 단추는 등록부(`A00_Common/design/`)만 만든다.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import re
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
ROOT = Path(HERE).parents[1]
|
|
PAGE_FILES = (
|
|
ROOT / "B05_Profile" / "B05_Profile_UI_Page.ts",
|
|
ROOT / "B06_Section" / "B06_Section_UI_Page.ts",
|
|
)
|
|
# 페이지 파일에 나오면 안 되는 것 — 좌측 칸 · 아래 단추 · 저장 단추를 직접 만든다는 표시.
|
|
FORBIDDEN_IN_PAGES = (
|
|
"createButton(",
|
|
"attachCollapsible(",
|
|
"buildGroup(",
|
|
"createSectionFrame(",
|
|
"registerPanelSection(",
|
|
"createDesignDock(",
|
|
"ui-sidebar-actions",
|
|
"b05-route__dock",
|
|
"b05-route__actions",
|
|
"b06-profile__actions",
|
|
"b06-profile__form",
|
|
"b05-route__panel",
|
|
"b06-profile__group",
|
|
"saveButton",
|
|
"confirmButton",
|
|
"actionDock",
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def results():
|
|
proc = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_design_view_parity.cjs")],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def test_공용_칸_구조물_배치는_두_보기가_같은_DOM(results):
|
|
profile, cross = results["views"]["profile"], results["views"]["cross"]
|
|
assert profile["structuresHtml"] == cross["structuresHtml"]
|
|
assert profile["structuresFirst"] and cross["structuresFirst"] # 맨 위 칸
|
|
|
|
|
|
def test_구조물_목록은_두_보기_모두_아래_고정_영역_맨_위(results):
|
|
profile, cross = results["views"]["profile"], results["views"]["cross"]
|
|
assert profile["dockFirstChild"] == cross["dockFirstChild"]
|
|
assert profile["dockClass"] == cross["dockClass"]
|
|
assert profile["dockIsLast"] and cross["dockIsLast"]
|
|
|
|
|
|
def test_아래_단추는_네_개_두_보기_같은_차례(results):
|
|
profile, cross = results["views"]["profile"], results["views"]["cross"]
|
|
assert (
|
|
profile["dockActions"]
|
|
== cross["dockActions"]
|
|
== [
|
|
"reset",
|
|
"save",
|
|
"confirm",
|
|
"switchView",
|
|
]
|
|
)
|
|
assert profile["dockLabels"][:3] == cross["dockLabels"][:3] == ["초기화", "저장", "확정"]
|
|
|
|
|
|
def test_보기_전환_단추는_가려는_쪽_이름(results):
|
|
assert results["views"]["profile"]["dockLabels"][3] == "횡단 보기"
|
|
assert results["views"]["cross"]["dockLabels"][3] == "종단 보기"
|
|
assert results["switchLabelAfter"] == "종단 보기" # setView("cross") 뒤
|
|
|
|
|
|
def test_꺼진_단추는_안_눌리고_켜진_단추는_동작을_부름(results):
|
|
assert results["views"]["profile"]["dockDisabled"] == [False, False, True, False]
|
|
assert results["views"]["cross"]["dockDisabled"] == [False, False, False, False]
|
|
assert results["calls"] == [
|
|
"profile:reset",
|
|
"profile:save",
|
|
"profile:switch",
|
|
"cross:reset",
|
|
"cross:save",
|
|
"cross:confirm",
|
|
"cross:switch",
|
|
]
|
|
|
|
|
|
def test_칸_차례는_보기마다_등록부_순서(results):
|
|
assert results["views"]["profile"]["sectionIds"] == [
|
|
"structures",
|
|
"page-settings",
|
|
"planned-route",
|
|
"route-calc",
|
|
"selected-point",
|
|
]
|
|
|
|
|
|
def test_횡단_보기_칸_정의와_차례():
|
|
"""B06 칸 정의는 화면 부품(입력 칸 · 표준 패널)을 물어 Node 에서 못 읽는다 — 소스로 본다."""
|
|
source = (ROOT / "B06_Section" / "B06_Section_UI_Page_Panel.ts").read_text(encoding="utf-8")
|
|
found = re.findall(
|
|
r'id: "([\w-]+)",\s*title:[^\n]*\n\s*views: \["cross"\],\s*order: (\d+)', source
|
|
)
|
|
ordered = [name for name, _ in sorted(found, key=lambda item: int(item[1]))]
|
|
assert ordered == ["cross-view", "standard-cross"]
|
|
shared = (ROOT / "A00_Common" / "design" / "design_sections.ts").read_text(encoding="utf-8")
|
|
assert 'views: ["profile", "cross"]' in shared # 구조물 배치는 한 정의로 두 보기
|
|
|
|
|
|
@pytest.mark.parametrize("page", PAGE_FILES, ids=lambda path: path.name)
|
|
def test_페이지_파일이_좌측_칸_단추_저장을_직접_만들지_않는다(page):
|
|
text = page.read_text(encoding="utf-8")
|
|
found = [marker for marker in FORBIDDEN_IN_PAGES if marker in text]
|
|
assert not found, f"{page.name} 이(가) 좌측 칸 · 단추를 직접 만든다: {found}"
|
|
|
|
|
|
def test_두_보기_패널은_같은_등록부로_세운다():
|
|
b05 = (ROOT / "B05_Profile" / "B05_Profile_UI_Panel.ts").read_text(encoding="utf-8")
|
|
b06 = (ROOT / "B06_Section" / "B06_Section_UI_Page.ts").read_text(encoding="utf-8")
|
|
assert "createDesignPanel(" in b05 and '"profile"' in b05
|
|
assert "createDesignPanel(" in b06 and '"cross"' in b06
|