Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
86 lines
2.8 KiB
Python
86 lines
2.8 KiB
Python
"""PLAN 266-1 — B06 [상세] 처음 가로 범위 = 좌측 「횡단 보기 설정」 반폭(개별 표시 반폭이면 그것).
|
|
|
|
짝: `B06_Section/B06_Section_UI_Section_View.ts`(`detailChart` 처음 배율) ·
|
|
`B06_Section_UI_Cross_Detail.ts`(`attachDetailZoom` homeScale) · `A00_Common/b_svg_zoom_pan.ts`.
|
|
실제 TS 를 `helper_266_detail_home.cjs` 가 Node 로 돌린다.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
HERE = os.path.dirname(__file__)
|
|
ROOT = os.path.join(HERE, "..", "..")
|
|
B06 = os.path.join(ROOT, "B06_Section")
|
|
|
|
pytestmark = pytest.mark.skipif(
|
|
not os.path.isdir(os.path.join(ROOT, "config", "node_modules")),
|
|
reason="프론트엔드 의존성 미설치",
|
|
)
|
|
|
|
|
|
def _read(name: str) -> str:
|
|
with open(os.path.join(B06, name), encoding="utf-8") as f:
|
|
return f.read().replace(chr(13), "")
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def out() -> dict:
|
|
proc = subprocess.run( # noqa: S603 — 고정 실행 파일
|
|
["node", os.path.join(HERE, "helper_266_detail_home.cjs")],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def test_처음_가로_반폭_15(out):
|
|
# 칸 맞춤이 가로를 넓혀도 처음 배율로 되좁힘 = −15 ~ +15
|
|
case = out["global15"]
|
|
assert case["widened"] is True and case["homeScale"] > 1
|
|
assert case["first"] == [-15, 15]
|
|
|
|
|
|
def test_개별_반폭_측점(out):
|
|
assert out["station10"]["first"] == [-10, 10]
|
|
|
|
|
|
def test_안_넓힌_칸_그대로(out):
|
|
case = out["tall15"]
|
|
assert case["widened"] is False and case["homeScale"] == 1
|
|
assert case["first"] == [-15, 15]
|
|
|
|
|
|
@pytest.mark.parametrize("name", ["global15", "station10", "tall15"])
|
|
def test_처음으로_같은_범위_줌_이동_그대로(out, name):
|
|
case = out[name]
|
|
assert case["reset"] == case["first"] # [⤢]
|
|
assert case["dblclick"] == case["first"] # 더블클릭
|
|
assert case["wheelScale"] == pytest.approx(1.15) # 휠 줌
|
|
assert case["panned"] is True # 가운데 단추 끌기
|
|
assert case["minScale"] == 1 # 줄이면 칸 맞춤 전체까지
|
|
|
|
|
|
def test_배선():
|
|
view = _read("B06_Section_UI_Section_View.ts")
|
|
assert (
|
|
"const homeScale = base && fitted ? base.pixelsPerMeter / fitted.pixelsPerMeter : 1;"
|
|
in view
|
|
)
|
|
assert "return { svg, axes, homeScale };" in view
|
|
# 반폭 = 개별 표시 반폭 › 좌측 「횡단 보기 설정」(카드와 같은 길)
|
|
assert (
|
|
"effectiveCardHalfWidth(section, stationWidth?.widthFor(section) ?? currentCrossHalfWidth)"
|
|
in view
|
|
)
|
|
src = " ".join(_read("B06_Section_UI_Cross_Detail.ts").split())
|
|
assert "drawn.homeScale" in src and "homeScale, home, onChange" in src # 295-2 첫 보기
|
|
assert "homeScale: drawn.homeScale" in src
|