Files
Aislo/resources/tester/test_180_3_b07_guide_toggle.py
T

77 lines
3.4 KiB
Python

"""180-3 B07 횡단 장 안내선 보이기 / 숨기기 단추.
- 끄는 것 = 점선 작도 영역 + 붉은 넘침 틀(화면 전용) · 인쇄 칸선 · 도면 개체는 그대로
- 단추 = 배치 칸 줄 · ghost sm · 글 「안내선 숨기기」 ↔ 「안내선 보이기」 · 상태는 모듈 값(저장 안 함)
- 숨김이면 넘침 토스트도 안 띄움 · 메시지 한 줄(`aislo:b08:guide-visible`) · cad_host `setGuideVisible`
"""
import json
import os
import re
import subprocess
from pathlib import Path
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = Path(HERE).parents[1]
B07 = ROOT / "B07_DesignDetail"
def _read(path: Path) -> str:
return path.read_text(encoding="utf-8")
def test_단추_글_누름_상태_이어짐():
proc = subprocess.run(
["node", os.path.join(HERE, "helper_180_3_b07_guide_toggle.cjs")],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
out = json.loads(proc.stdout)
assert out["first"] == {
"text": "안내선 숨기기",
"cls": "ui-btn ui-btn--ghost ui-btn--sm",
"pressed": "false",
"shown": True,
}
assert out["hidden"]["text"] == "안내선 보이기" and out["hidden"]["pressed"] == "true"
assert out["hidden"]["shown"] is False
assert out["again"]["text"] == "안내선 숨기기" and out["again"]["shown"] is True
assert out["last"]["shown"] is False
assert out["sent"] == [False, True, False] # CAD 에 알린 값
# 화면을 다시 세워 새 단추를 만들어도 숨김 유지
assert out["rebuilt"] == {"text": "안내선 보이기", "pressed": "true"}
def test_메시지_짝_호스트_CAD():
host = _read(ROOT / "ui_template" / "cad_host" / "cad_host.ts")
bridge = _read(B07 / "openwebcad" / "src" / "integration" / "aislo-drawing-bridge.ts")
guide = _read(B07 / "openwebcad" / "src" / "integration" / "guide-area.ts")
name = "aislo:b08:guide-visible"
assert f'"{name}"' in host and f"'{name}'" in bridge # 짝 메시지 이름 같음
assert "setGuideVisible: (visible) => postAfterLoad(" in host
assert "setGuideVisible: (visible: boolean) => void;" in host
assert "return setGuideVisible(guideMessage.visible);" in bridge
assert "if (!guide || !guideVisible) return;" in guide # 그리기 거름
assert "!guideVisible) return;" in guide # 끌기 집기도 거름
# 싣기(setGuide)가 보임 값을 건드리지 않음
body = guide[
guide.index("export function setGuide(") : guide.index("export function setGuideArea")
]
assert "guideVisible" not in body
def test_페이지_잇기_토스트_거름_장만():
page = _read(B07 / "B07_DesignDetail_UI_Page.ts")
assert "if (guideShown() && guide?.marks?.length) {" in page # 숨김 = 넘침 토스트 없음
assert "cad.setGuideVisible(visible)" in page
assert "if (!guideShown()) cad.setGuideVisible(false);" in page # 다시 세운 화면에 이어 줌
assert "controls.append(guideToggle);" in page # 배치 칸 줄 끝
assert "guideToggle.disabled = !isCrossSheet(drawing);" in page # 장만
# 단추는 인쇄 칸선(도각 층) · 도면 개체를 건드리지 않음 — 파이썬 쪽 변경 없음
assert not re.search(
r"guide.?visible", _read(B07 / "B07_DesignDetail_Engine_Cad_Sheet.py"), re.I
)