- 마스터 첫 쪽 도면 줄 아래 산출근거 줄 s:basis — 칸 글 basisLabel(colId) · 없으면 「없음」 · 손으로 못 침 - onPick 을 주면 일위대가 · 도면 · 산출근거 칸은 두 번 누르기 · Enter · F2 로 조회 후 선택(글을 돌려주면 일위대가 칸에 넣음) - 「<둘째 층 이름> 더하기」 단추 — 같은 종류 묶음 끝에 [종류, 새 분류, 새 열] 열(층 셋 이상일 때) - 머리 층 줄 머리 칸 두 번 누르기 = 층 이름 고치기(master) - 시험 test_sheet_group_layer.py · 줄 차례 시험에 산출근거 줄 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Kyw9qnkJ94pC1A4PfpDtA
91 lines
2.7 KiB
Python
91 lines
2.7 KiB
Python
"""표 둘째 층 묶음 더하기 · 층 이름 고치기 — `ui_template_sheet_ops.ts` 를 Node 로 바로 돌려 봄.
|
|
|
|
`addGroup` = 고른 열과 같은 맨 위 묶음(종류) 끝에 `[종류, 새 분류, …, 새 열]` · 다른 종류 열은 안 건드림.
|
|
`setLayerName` = 층 이름(줄 머리 글) · 모자란 층은 빈 글로 채움.
|
|
"""
|
|
|
|
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 { addGroup, setLayerName } = await import(process.argv[1]);
|
|
const base = JSON.parse(process.argv[2]);
|
|
const out = {};
|
|
let doc = structuredClone(base);
|
|
out.id = addGroup(doc, "a1", 3, "새 분류", "새 열");
|
|
out.after_a1 = doc.열.map((c) => [c.id, c.머리]);
|
|
doc = structuredClone(base);
|
|
addGroup(doc, "b1", 4, "G", "L");
|
|
out.deep = doc.열.at(-1).머리;
|
|
doc = structuredClone(base);
|
|
addGroup(doc, null, 3, "G", "L");
|
|
out.none = doc.열.at(-1).머리;
|
|
doc = structuredClone(base);
|
|
setLayerName(doc, 1, " 분류1 ");
|
|
out.layers = doc.층;
|
|
doc = structuredClone(base);
|
|
delete doc.층;
|
|
setLayerName(doc, 2, "분류2");
|
|
out.padded = doc.층;
|
|
console.log(JSON.stringify(out));
|
|
"""
|
|
|
|
DOC = {
|
|
"양식": "시험",
|
|
"종류": "표",
|
|
"판": 1,
|
|
"층": ["종류", "공법", "규격"],
|
|
"열": [
|
|
{"id": "a1", "머리": ["가", "x", "1"], "단위": "m"},
|
|
{"id": "a2", "머리": ["가", "x", "2"]},
|
|
{"id": "a3", "머리": ["가", "y", None]},
|
|
{"id": "b1", "머리": ["나", None, None]},
|
|
],
|
|
"줄": [],
|
|
}
|
|
|
|
|
|
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_group_goes_to_end_of_same_top():
|
|
got = _run()
|
|
assert got["id"] == "c1"
|
|
assert got["after_a1"] == [
|
|
["a1", ["가", "x", "1"]],
|
|
["a2", ["가", "x", "2"]],
|
|
["a3", ["가", "y", None]],
|
|
["c1", ["가", "새 분류", "새 열"]],
|
|
["b1", ["나", None, None]],
|
|
]
|
|
|
|
|
|
def test_group_depth_and_no_selection():
|
|
got = _run()
|
|
assert got["deep"] == ["나", "G", None, "L"]
|
|
assert got["none"] == ["G", "G", "L"]
|
|
|
|
|
|
def test_layer_name():
|
|
got = _run()
|
|
assert got["layers"] == ["종류", "분류1", "규격"]
|
|
assert got["padded"] == ["", "", "분류2"]
|