- 총괄 = 가.~바. 소계 lv1 굵게 · 제비율 · 입력 줄 lv2 - 원가계산서 = 구분 줄 lv1 · 비목 소계 lv2 · 세목 lv3 - 182 is-lvN 글자 크기 재사용 · 들여쓰기 = 명칭 칸(is-indent) · 앞 칸(is-flat) 그대로 - 새 시험 test_185_1_b09_total_level Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015sDZSjFvoiDjdGpgj3muc3
81 lines
3.4 KiB
Python
81 lines
3.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""185-1 B09 총괄설계내역서 · 공사원가계산서 줄 레벨 — 줄 `level` · 줄 class(182 is-lvN) · 칸 class · CSS.
|
|
|
|
레벨 = 화면이 정함(줄 짜임이 `B09_Estimation_UI_Tabs_Total.ts` 에 있음 · 셈 짝은 값만 냄 → 거울 없음).
|
|
총괄 = 가.~바. 소계 1(굵게) · 그 밖 2 · 원가계산서 = 구분만 1 · 비목 소계 2 · 세목 3.
|
|
들여쓰기 = 명칭 칸(is-indent) · 앞 칸(is-flat)은 그대로.
|
|
"""
|
|
|
|
import json
|
|
import re
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
B09 = ROOT / "B09_Estimation"
|
|
IMPORTS = re.compile(r"^import[^;]*;\n", re.MULTILINE)
|
|
|
|
SUMS = {"material": 194234417, "labor": 346800554, "expense": 169324165, "supply_net": 69474220}
|
|
|
|
BODY = f"""
|
|
const user = {{ estimate: {{}} }};
|
|
const ctx = {{ sheets: {{ total: computeTotal({json.dumps(SUMS)}, user.estimate) }}, payload: {{}}, user, setUser: () => {{}} }};
|
|
const pack = (t) => t.rows.map((r, i) => [r.key, r.level, t.rowClass(i), t.cellClass(i, "name"), t.cellClass(i, t.columns[0].key), t.cellClass(i, "amount")]);
|
|
console.log(JSON.stringify({{ total: pack(buildTotal(ctx)), cost: pack(buildCost(ctx)) }}));
|
|
"""
|
|
|
|
|
|
def _run() -> dict:
|
|
names = ("Calc_Base", "Calc_Total", "UI_Tabs", "UI_Tabs_Total")
|
|
script = "".join(
|
|
IMPORTS.sub("", (B09 / f"B09_Estimation_{n}.ts").read_text(encoding="utf-8")) for n in names
|
|
)
|
|
result = subprocess.run(
|
|
["node", "--experimental-strip-types", "--no-warnings",
|
|
"--input-type=module-typescript"],
|
|
input=script + BODY, 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_총괄_레벨():
|
|
rows = {k: (lv, cls) for k, lv, cls, *_ in _run()["total"]}
|
|
top = ["direct", "net_cost", "da", "supply_price", "contract", "grand"]
|
|
assert all(rows[k] == (1, "is-lv1 is-title") for k in top)
|
|
for k in ["in_price", "in_env", "indirect_labor", "machine", "retirement", "overhead", "vat",
|
|
"supply"]: # fmt: skip
|
|
assert rows[k] == (2, "is-lv2"), k
|
|
assert {lv for lv, _ in rows.values()} == {1, 2}
|
|
|
|
|
|
def test_원가계산서_레벨():
|
|
rows = {k: (lv, cls) for k, lv, cls, *_ in _run()["cost"]}
|
|
for k in ["overhead", "profit", "supply_price", "vat", "contract", "supply", "grand"]:
|
|
assert rows[k] == (1, "is-lv1 is-title"), k
|
|
for k in ["material", "labor", "expense_sum"]:
|
|
assert rows[k] == (2, "is-lv2"), k
|
|
for k in ["direct_material", "scrap", "direct_labor", "indirect_labor", "expense", "safety"]:
|
|
assert rows[k] == (3, "is-lv3"), k
|
|
|
|
|
|
def test_칸_class_명칭만_들여씀():
|
|
out = _run()
|
|
for tab in ("total", "cost"):
|
|
for _k, _lv, _cls, name, first, amount in out[tab]:
|
|
assert (name, first, amount) == ("is-indent", "is-flat", None)
|
|
|
|
|
|
def test_CSS_레벨_규칙():
|
|
css = (B09 / "B09_Estimation_UI_Page.css").read_text(encoding="utf-8")
|
|
assert re.search(
|
|
r'tr\[class\*="is-lv"\] td\.is-flat:first-child \{\s*padding-left: var\(--spacing-8\);', css
|
|
)
|
|
for lv, em in ((2, 1), (3, 2)):
|
|
assert re.search(
|
|
rf"tr\.is-lv{lv} td\.is-indent \{{\s*padding-left: calc\(var\(--spacing-8\) \+ {em}em\);",
|
|
css,
|
|
)
|
|
# 글자 크기 = 182 규칙 재사용(줄 높이 28px → 16px 까지)
|
|
assert re.search(r"tr\.is-lv1 td \{\s*font-size: var\(--text-body\);", css)
|