"""198-1 B08 구조물 집계표 — 미연결 = 측점 칸 왼쪽 램프 하나 · 「미지정」 열 지움. - 칸 class: 화면 소스의 `cellClass` 를 떼어 공용 표 `renderDataTableHtml` 로 그림(Node) — 미연결 줄 측점 칸만 램프 - 호버 글: 화면 소스의 호버 함수를 떼어 가짜 칸으로 부름 — 「구조물 조합 미연결 — 빈 칸 이름」 · 연결 줄은 없음 - CSS: 램프 = 경고 노랑 토큰(177-1) · 밝음 · 어두움 둘 다 - 줄 값 = 측점 + 서버 값뿐(「미지정」 · 「· 미연결」 글 없음 → 수량 · 합계 그대로) """ import json import re import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[2] TS = ROOT / "config" / "node_modules" / "typescript" UI = (ROOT / "B08_Quantity" / "B08_Quantity_UI_Summary.ts").read_text(encoding="utf-8") + ( ROOT / "B08_Quantity" / "B08_Quantity_Summary_Table.ts" ).read_text(encoding="utf-8") PRELUDE = f""" const fs = require("fs"); const ts = require({json.dumps(str(TS))}); const js = (code) => ts.transpileModule(code, {{ compilerOptions: {{ module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }}, }}).outputText; """ def _node(script: str): out = subprocess.run( ["node", "-e", script], capture_output=True, text=True, encoding="utf-8", timeout=60 ) assert out.returncode == 0, out.stderr return json.loads(out.stdout) def _lamp_class() -> str: m = re.search(r'const LAMP_CLASS = "([^"]+)";', UI) assert m return m.group(1) def test_미연결_줄_측점_칸만_램프(): cell = re.search(r"cellClass: (\(i, key\) =>.*?),\n\s*frozen", UI, re.S) assert cell table = json.dumps(str(ROOT / "ui_template" / "ui_template_data_table.ts")) got = _node( PRELUDE + f""" const box = {{ exports: {{}} }}; new Function("exports", "module", "require", js(fs.readFileSync({table}, "utf8")))( box.exports, box, (p) => (p.endsWith(".css") ? {{}} : require(p))); const LAMP_CLASS = {json.dumps(_lamp_class())}; const missing = ["", "BOX", ""]; const linked = [false, false, false]; const LINKED_CLASS = LAMP_CLASS + " is-linked"; const cellClass = {cell.group(1)}; const html = box.exports.renderDataTableHtml({{ columns: [{{ key: "station", label: "측점" }}, {{ key: "c1", label: "조합" }}], rows: [{{ station: "0+000" }}, {{ station: "0+020" }}, {{ station: "0+040", c1: 1 }}], frozen: 1, empty: "", cellClass }}); const rows = html.split("
")[1].split(""); console.log(JSON.stringify({{ count: html.split(LAMP_CLASS).length - 1, row1: rows[1], row0: rows[0], }})); """ ) assert got["count"] == 1 assert f'