Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmC34fsxxbweEG3RUjs3Mn
66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""224-1a(PLAN 325-1) 배수유역 판 창구 — 새 창으로 떼어도 지도 크기 관찰이 그 창을 따름.
|
|
|
|
- 판 지도 크기 관찰(`observeViewportSize`)은 판이 놓인 창의 ResizeObserver 를 씀.
|
|
- `rehome()` = 옛 창 관찰자 끊고 지금 놓인 창 것으로 · 직전 크기를 이어받아 배율(화면 m 당 px) 유지.
|
|
- 판 창구(`DrainagePanel.rehome`)로 내보내고 패널 본체는 700줄 안.
|
|
|
|
`helper_224_1a_drainage_rehome.cjs` 가 진짜 TS 를 가짜 창 둘 위에서 돌림.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
B05 = Path(HERE).parents[1] / "B05_Profile"
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def r():
|
|
proc = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_224_1a_drainage_rehome.cjs")],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def test_처음은_놓인_창_관찰자(r):
|
|
assert r["firstOwner"] is True
|
|
assert r["firstApplied"] == 0 # 처음 크기는 기억만
|
|
|
|
|
|
def test_rehome_은_새_창_관찰자로(r):
|
|
assert r["mainLive"] is False
|
|
assert r["popupLive"] == 1
|
|
|
|
|
|
def test_새_창에서_커져도_배율_유지(r):
|
|
"""400 → 800 px · 배율 2 → 1 = 화면 m 당 px 그대로."""
|
|
grow = r["afterGrow"]
|
|
assert grow["applied"] == 1
|
|
assert grow["scale"] == pytest.approx(1)
|
|
assert r["mainIgnored"] == 1 # 끊긴 메인 관찰자는 안 울림
|
|
|
|
|
|
def test_제자리와_정리(r):
|
|
assert r["backPopupLive"] is False
|
|
assert r["backMainLive"] == 1
|
|
assert r["afterDispose"] is False
|
|
assert r["redraws"] == 2
|
|
|
|
|
|
def test_판_창구와_700줄():
|
|
panel = (B05 / "B05_Profile_UI_Drainage_Panel.ts").read_text(encoding="utf-8")
|
|
assert "rehome: () => resizeObserver.rehome()," in panel
|
|
assert len(panel.splitlines()) <= 700
|
|
types = (B05 / "B05_Profile_UI_Drainage_Panel_Types.ts").read_text(encoding="utf-8")
|
|
assert "rehome: () => void;" in types
|