- 일위대가 줄 아래 도면 줄 s:drawing — 칸 글은 SheetOptions.drawingLabel(colId) · 없거나 빈 글이면 「없음」 · 읽기만
- 줄 차례(navRows) · MASTER_ROWS · KEY_UNIT 를 ops 로 옮김(Node 시험 가능)
- 칸을 고르면 SheetOptions.onSelect({ row, col, colId }) — 누르기 · 방향키 · 머리 칸
- 시험 test_sheet_drawing_select.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Kyw9qnkJ94pC1A4PfpDtA
65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
"""표 도면 줄 · 칸 고르기 신호 — `ui_template_sheet_ops.ts` 를 Node 로 바로 돌려 봄.
|
|
|
|
도면 줄 `s:drawing` = master 만 · 일위대가 줄 바로 아래(키보드 차례) · project 에는 없음.
|
|
`selectionOf` = 격자가 `onSelect` 로 넘기는 모양({row, col, colId} · 모르는 열은 col -1 · colId null).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
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 } = 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")],
|
|
}));
|
|
"""
|
|
|
|
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:formula", "s:desc", "s:price", "s:drawing", "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},
|
|
]
|