Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4uKaV4ZBhsJN4GHG7yRj4
66 lines
2.8 KiB
Python
66 lines
2.8 KiB
Python
"""공용 오른쪽 접는 패널(`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]
|
|
|
|
|
|
def test_따라붙기_끔_옵션():
|
|
"""85-5 — `follow: false` = followView 안 부름 · 칸 높이 채움(is-fill) · M02 상세 둘만 씀 · M01 그대로."""
|
|
src = PART.read_text(encoding="utf-8")
|
|
assert (
|
|
'if (opts.follow === false) root.classList.add("is-fill");\n else followView(root);' in src
|
|
)
|
|
css = PART.with_suffix(".css").read_text(encoding="utf-8")
|
|
assert ".ui-side-panels.is-fill {" in css and "overscroll-behavior: contain" in css
|
|
m02 = ROOT / "M02_MasterTemplete"
|
|
for name in ("M02_MasterTemplete_AreaPanel.ts", "M02_MasterTemplete_Labor_Detail.ts"):
|
|
assert "follow: false," in (m02 / name).read_text(encoding="utf-8"), name
|
|
m01 = (ROOT / "M01_MasterData/M01_MasterData_UI_LogicLab_Side.ts").read_text(encoding="utf-8")
|
|
assert "follow" not in m01
|
|
style = (m02 / "M02_MasterTemplete_UI_Style.css").read_text(encoding="utf-8")
|
|
assert ".m02-main:has(> .m02-main__host > .ui-side-panels-row)" in style
|
|
source = (ROOT / "M01_MasterData/M01_MasterData_UI_LogicLab_Source.ts").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
assert 'scrollIntoView({ block: "center" })' not in source and "box.scrollTop +=" in source
|