"""345-5 덧 3 — 노선 편집 평면 상태 · 범례 글판과 도움말 글판 접기. `_RouteEdit_Chrome` 의 배선 · 접힘 기억 · 한 줄 요약 글 · CSS 자리를 글로 봄 · 요약 글 정규식은 node 로 돌림. ./venv/Scripts/python.exe -m pytest resources/tester/test_345_5c_info_hint_collapse.py -q """ from __future__ import annotations import json import re import shutil import subprocess from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[2] B05 = ROOT / "B05_Profile" CHROME = (B05 / "B05_Profile_UI_RouteEdit_Chrome.ts").read_text(encoding="utf-8") CSS = (B05 / "B05_Profile_UI_Style_RouteEdit.css").read_text(encoding="utf-8").replace("\r\n", "\n") def _rule(selector: str) -> str: at = CSS.rindex("\n" + selector + " {") return CSS[at : CSS.index("}", at)] def test_도움말_기본_접힘_펼침_기억() -> None: assert "let hintOpen = false;" in CHROME # 기본 접힘 · 모듈 값 = 페이지 동안 기억 assert 'data-act="hint-toggle" aria-expanded="false"' in CHROME and ">?" in CHROME assert "hintOpen = open;" in CHROME and 'hint.classList.toggle("is-open", open);' in CHROME assert "setHint(hintOpen);" in CHROME assert 'hintToggle.addEventListener("click", () => setHint(!hintOpen));' in CHROME # 접힘 = 몸통 없음 · 펼침 = 2열 · 단추만 클릭 받음 assert "display: none;" in _rule(".b05-routeedit__hint-body") assert "display: grid;" in _rule(".b05-routeedit__hint.is-open > .b05-routeedit__hint-body") assert "pointer-events: auto;" in _rule(".b05-routeedit__hint-toggle") assert "pointer-events: none;" in _rule(".b05-routeedit__hint") def test_상태_범례_접기_한_줄_기억() -> None: assert "let infoCollapsed = false;" in CHROME assert 'data-act="info-toggle"' in CHROME and 'aria-expanded="true"' in CHROME assert "infoCollapsed = collapsed;" in CHROME and "setInfo(infoCollapsed);" in CHROME assert 'infoToggle.textContent = collapsed ? "▸" : "▾";' in CHROME assert 'infoToggle.addEventListener("click", () => setInfo(!infoCollapsed));' in CHROME # 상태 글이 바뀔 때마다 요약 글을 다시 씀 assert "new MutationObserver(syncSummary).observe(status," in CHROME collapsed = ".b05-routeedit__info.is-collapsed > .b05-routeedit__" assert "display: none;" in _rule(f"{collapsed}status,\n{collapsed}legend") assert "display: block;" in _rule(f"{collapsed}summary") assert "display: none;" in _rule(".b05-routeedit__summary") assert "pointer-events: auto;" in _rule(".b05-routeedit__info-toggle") def test_상태_글판_작게_반투명_자리() -> None: info = _rule(".b05-routeedit__info") # 왼쪽 아래 제자리 — 뜬 판이 덮으면 가려진 채(349-0) · 폭 줄임 assert "bottom: var(--spacing-12);" in info assert "max-width: min(460px, 46%);" in info and "grid-template-columns:" in info # 상태 글 두 줄에서 자름 · 범례는 옆 칸 두 줄 assert "-webkit-line-clamp: 2;" in _rule(".b05-routeedit__status") assert "flex-direction: column;" in _rule(".b05-routeedit__legend") glass = _rule(".b05-routeedit__hint-body,\n.b05-routeedit__info") assert "color-mix(in srgb, var(--color-surface-raised) 72%, transparent)" in glass assert not re.search(r"#[0-9a-fA-F]{3,6}\b", glass) # 바탕 · 글 색은 토큰 @pytest.mark.skipif(shutil.which("node") is None, reason="node 없음") def test_요약_글은_계획노선_길이() -> None: pattern = re.search(r"const length = (/.+?/)\.exec", CHROME).group(1) samples = [ "예상노선 1201.4m · 계획노선 1153.2m · 노드 12개 · 고친 계획노선 · LAS 등고선", "노선을 읽는 중…", ] script = ( f"const re = {pattern};" f"const out = {json.dumps(samples, ensure_ascii=False)}.map((t) => {{" "const m = re.exec(t)?.[1]; return m ? `계획노선 ${m} m` : t; });" "console.log(JSON.stringify(out));" ) run = subprocess.run( # noqa: S603 S607 — 고정 node 실행 ["node", "-e", script], capture_output=True, check=True, encoding="utf-8" ) assert json.loads(run.stdout) == ["계획노선 1153.2 m", "노선을 읽는 중…"]