Files
Aislo/resources/tester/test_sheet_drawing_select.py
T
eomsangdonandClaude Opus 5.5 6541b65834 fix(M02): 구조물 조합 표 「일위대가」 줄 = 그 열 일위대가번(SU) — 옛 조합 키(UA) 칸 안 읽음 · 번호 글 줄(도면 · 면적산출과 같음)
- 표 부품: 일위대가 줄도 번호 글 줄(손으로 못 침 · laborLabel) · 조회 후 선택이 열 칸을 안 고침
- 누르면 다른 줄과 같은 길(일위대가 복사해 가져오기) · 열의 옛 「일위대가」 값은 파일에 그대로

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NPJGtfXo6GMbcpiboQC4uK
2026-10-04 22:08:06 +09:00

89 lines
3.4 KiB
Python

"""표 도면 줄 · 칸 고르기 신호 — `ui_template_sheet_ops.ts` 를 Node 로 바로 돌려 봄.
마스터 줄 = 일위대가 · 도면 `s:drawing` · 면적산출 `s:area`(식 · 들어갈 것 줄 없음) ·
master 만 · 단위 줄 바로 아래 차례(키보드) · project 에는 없음.
`selectionOf` = 격자가 `onSelect` 로 넘기는 모양({row, col, colId} · 모르는 열은 col -1 · colId null).
"""
from __future__ import annotations
import json
import re
import shutil
import subprocess
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[2]
OPS = ROOT / "ui_template" / "sheet" / "ui_template_sheet_ops.ts"
pytestmark = pytest.mark.skipif(shutil.which("node") is None, reason="node 가 없음")
SCRIPT = """
const { navRows, selectionOf, isBlankPick } = await import(process.argv[1]);
const doc = JSON.parse(process.argv[2]);
console.log(JSON.stringify({
master: navRows(doc, "master"),
project: navRows(doc, "project"),
pick: [selectionOf(doc, "s:drawing", "c2"), selectionOf(doc, "d:r1", "c1"), selectionOf(doc, "s:unit", "zz")],
blank: ["s:price", "s:drawing", "s:area", "s:unit", "d:r1"].map((k) => [isBlankPick(k, { id: "t", 머리: [], 꼴: "글" }), isBlankPick(k, { id: "n", 머리: [], 꼴: "수" })]),
}));
"""
DOC = {
"양식": "시험",
"종류": "표",
"판": 1,
"열": [{"id": "c1", "머리": ["가"]}, {"id": "c2", "머리": ["나"]}],
"줄": [{"id": "r1", "값": {}}],
"합계줄": [{"id": "t1", "이름": "계", "식": "SUM"}],
}
def _run() -> dict:
result = subprocess.run(
["node", "--experimental-strip-types", "--no-warnings", "--input-type=module", "-e",
SCRIPT, OPS.as_uri(), json.dumps(DOC, ensure_ascii=False)],
capture_output=True, text=True, encoding="utf-8", timeout=60,
) # fmt: skip
assert result.returncode == 0, result.stderr
return json.loads(result.stdout)
def test_drawing_row_under_price_master_only():
got = _run()
assert got["master"] == [
"s:unit", "s:price", "s:drawing", "s:area", "d:r1", "t:t1",
] # fmt: skip
assert got["project"] == ["s:unit", "d:r1", "t:t1"]
def test_selection_shape():
assert _run()["pick"] == [
{"row": "s:drawing", "col": 1, "colId": "c2"},
{"row": "d:r1", "col": 0, "colId": "c1"},
{"row": "s:unit", "col": -1, "colId": None},
]
def test_text_column_pick_rows_blank():
assert _run()["blank"] == [
[True, False], [True, False], [True, False], [False, False], [False, False],
] # fmt: skip
def test_labor_row_shows_su_number():
"""마스터 일위대가 줄 = 그 열 일위대가번(SU) — 열의 옛 `일위대가` 칸(UA 키)은 안 읽음."""
ops = OPS.read_text(encoding="utf-8")
assert "REF_ROWS: readonly string[] = [KEY_PRICE, KEY_DRAWING, KEY_AREA]" in ops
render = (OPS.parent / "ui_template_sheet_render.ts").read_text(encoding="utf-8")
assert re.search(r"key === KEY_PRICE\s*\?\s*state\.laborLabel", render)
assert "col.일위대가" not in render
sheet = (OPS.parent / "ui_template_sheet.ts").read_text(encoding="utf-8")
assert "col.일위대가" not in sheet # 읽기 · 쓰기 · 조회 후 선택 모두 안 건드림
main = (ROOT / "M02_MasterTemplete" / "M02_MasterTemplete_UI_Main.ts").read_text(
encoding="utf-8"
)
assert 'laborLabel: (colId: string) => struct.numbers()[colId]?.일위대가번 ?? ""' in main