"""공용 오른쪽 접는 패널(`ui_template_side_panels.ts`) 시험 — 폭 자르기 · 줄 수. 접기 · 펴기 · 기억은 화면 시나리오(`ui_checks/47-3_로직상세_오른쪽패널.js`)로 봄. """ from __future__ import annotations import json import re import shutil import subprocess from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[2] PART = ROOT / "ui_template" / "ui_template_side_panels.ts" def test_700줄을_넘지_않음(): for path in (PART, PART.with_suffix(".css")): assert len(path.read_text(encoding="utf-8").splitlines()) <= 700, path.name @pytest.mark.skipif(shutil.which("node") is None, reason="node 가 없음") def test_폭_자르기(): """`clampSideWidth` — 가장 작게 min · 가장 크게 화면 85% · 화면이 좁아도 min.""" found = re.search( r"^export function clampSideWidth[\s\S]*?^}", PART.read_text(encoding="utf-8"), re.M ) assert found, "clampSideWidth 를 못 찾음" script = ( found.group(0).replace("export ", "") + "\nconsole.log(JSON.stringify(JSON.parse(process.argv[1])" + ".map(([p, m, v]) => clampSideWidth(p, m, v))));" ) cases = [[100, 280, 1600], [500.4, 280, 1600], [5000, 280, 1600], [500, 280, 200]] result = subprocess.run( ["node", "--experimental-strip-types", "--no-warnings", "--input-type=module-typescript", "-e", script, json.dumps(cases)], capture_output=True, text=True, encoding="utf-8", timeout=60, ) # fmt: skip assert result.returncode == 0, result.stderr assert json.loads(result.stdout) == [280, 500, 1360, 280]