Files
Aislo/resources/tester/test_709_pager_fit.py
T
eomsangdonandClaude Sonnet 5.5 a7c48aae9a fix(829-1): 모바일 찾기 칸 되풀이 다시 그리기 — 늦은 옛 응답 덮어쓰기 막음 · 한글 조합 중 검색 보류 · 키보드로 높이만 바뀐 뒤 줄 수 다시 재기 거름
- 원인 셋: ① 목록 불러오기 응답 순서 가드 없음(Rows · Machine · Tables · 복사 고르기 · 고를 재료 판) → 느린 회선에서 앞 글자 응답이 뒤 글자 목록을 덮음 ② 글자 칸 조합마다 input 이 검색을 걸음 ③ 키보드가 뜨고 닫을 때마다 watchFit 이 줄 수를 다시 재 목록을 다시 받아 그림 · 첫 그림 어림(6)과 잰 값(5) 어긋남으로 한 글자에 두 번 받음
- 공용 고침: ui_template_pager(holdForKeyboard · 직전 잰 줄 수 어림) · device_context(찾기 칸 조합 보류) · M01 Rows · Machine · Tables · Page · Pick · LogicLab_Copy
- 시험: test_709_pager_fit 에 holdForKeyboard 1 건 더함

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 22:06:27 +09:00

88 lines
3.2 KiB
Python

"""709 쪽 단추 부품 지킴 시험 — 쪽 수 · 화면 높이 → 줄 수 · 쪽 크기 바뀔 때 첫 줄 유지(순수 함수).
`ui_template/ui_template_pager.ts` 의 「순수 셈」 구간만 떼어 node 로 돌림(화면 · 서버 없음).
부품 모음 견본 · 옛 이름 `buildPager` 가 새 부품을 부르는지도 글로 잡음.
"""
import json
import re
import shutil
import subprocess
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[2]
PAGER = ROOT / "ui_template" / "ui_template_pager.ts"
pytestmark = pytest.mark.skipif(shutil.which("node") is None, reason="node 가 없음")
def _pure() -> str:
text = PAGER.read_text(encoding="utf-8")
start = text.index("export const ROW_H")
end = text.index("/* ── 아래부터 화면 재기")
return text[start:end]
def _run(body: str) -> object:
script = _pure() + "\n" + body
out = subprocess.run(
["node", "--experimental-strip-types", "--no-warnings",
"--input-type=module-typescript", "-e", script],
capture_output=True, text=True, encoding="utf-8", timeout=60,
) # fmt: skip
assert out.returncode == 0, out.stderr
return json.loads(out.stdout)
def test_쪽_수():
got = _run(
"console.log(JSON.stringify([pageCount(0,30), pageCount(30,30), pageCount(31,30), pageCount(1469,30)]));"
)
assert got == [1, 1, 2, 49]
def test_화면_높이_줄_수():
# 머리 40 + 줄 40 · 표 칸 위 200 · 쪽 단추 자리 64 → 1080: (816-40)/40=19 · 768: (504-40)/40=11
got = _run(
"console.log(JSON.stringify(["
"fitRows(1080-200-PAGER_ROOM), fitRows(768-200-PAGER_ROOM), "
"fitRows(100), fitRows(100000), fitRows(Number.NaN), fitRows(520, 36, 40)]));"
)
assert got == [19, 11, 5, 200, 5, 13]
def test_높이가_클수록_줄이_많음():
got = _run(
"const a=[]; for (let h=300; h<=1400; h+=50) a.push(fitRows(h)); "
"console.log(JSON.stringify(a.every((v,i)=>i===0||v>=a[i-1])));"
)
assert got is True
def test_쪽_크기_바뀌어도_첫_줄_유지():
# 30줄 쪽의 3쪽(첫 줄 61번째) → 20줄 쪽이면 4쪽(61~80) · 50줄 쪽이면 2쪽(51~100)
got = _run(
"console.log(JSON.stringify([pageKeepFirst(3,30,20), pageKeepFirst(3,30,50), pageKeepFirst(1,30,12)]));"
)
assert got == [4, 2, 1]
def test_옛_이름은_새_부품():
cells = (ROOT / "M01_MasterData" / "M01_MasterData_UI_Cells.ts").read_text(encoding="utf-8")
assert re.search(r"export const buildPager = createPager;", cells)
assert "createButton" not in cells
parts = (ROOT / "ui_template" / "ui_template_ui_kit_parts.ts").read_text(encoding="utf-8")
assert 'file: "ui_template_pager.ts"' in parts and 'file: "ui_template_divider.ts"' in parts
def test_829_키보드_높이만_바뀐_다시_재기_거름():
# 글자 넣는 중 · 터치 · 폭 그대로 = 거름(true) · 폭이 바뀌었거나 터치 아님 · 글자 안 넣는 중이면 다시 잼(false)
got = _run(
"console.log(JSON.stringify(["
"holdForKeyboard(true,true,true), holdForKeyboard(true,true,false), "
"holdForKeyboard(true,false,true), holdForKeyboard(false,true,true)]));"
)
assert got == [True, False, False, False]