Files
Aislo/resources/tester/test_est_print_batch.py
T
eomsangdonandClaude Opus 5.5 892285843d feat(est-test): 워드형 수량산출서 표 보존과 편집 도구
- 가져오기가 WPT 표를 버리던 결함 고침: 표 줄(칸·수량 표지·수식·세로병합) 보존, 문서 읽기 native-quantity-wpt.cjs 로 분리
- 표 셀 합·수량 지정·병합/분리·표 만들기·표 모양, 문단·그림·쪽 삽입/삭제·품명/규격 지정·공종명칭 입력·테두리선·산출근거 양식
- 수량 불러오기·수량목록보기·선택수량복사·내역서 수량붙여넣기(연결)
- ESTX 저장은 표 줄을 건너 문단만 맞춤, 표·서식 편집은 거부

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 18:35:50 +09:00

61 lines
2.6 KiB
Python

"""EST 테스트 앱 묶음 인쇄·간지(원본 TEstPrint.Print 0x10fef98 — Checked 서식 차례, 간지 = 가운데 제목)."""
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
FILES = [
"native-math.js",
"native-formula.js",
"native-machine.js",
"native-rows.js",
"native-text.js",
"native-quantity-wpt.cjs",
"native-quantity.cjs",
"native-wonga.js",
"native-engine.js",
"native-row-match.js",
"native-escalation.js",
"native-progress.js",
"native-business.js",
"native-review.js",
"native-resources.js",
"native-schedule.js",
"native-model.js",
"native-verify.js",
"native-docs.js",
"native-forms.js",
"native-print-batch.js",
]
def test_checked_forms_in_order_with_gangi():
runner = f"""
const fs = require('fs'), vm = require('vm');
const ctx = vm.createContext({{ structuredClone, console, Intl }});
for (const f of {json.dumps(FILES)})
vm.runInContext(fs.readFileSync('tools/est-test/' + f, 'utf8'), ctx, {{ filename: f }});
ctx.source = JSON.parse(fs.readFileSync('tools/est-test/sample.json', 'utf8'));
ctx.catalog = JSON.parse(fs.readFileSync('tools/est-test/print-catalog.json', 'utf8'));
process.stdout.write(JSON.stringify(vm.runInContext(`(() => {{
const p = EstNative.calculate(EstModel.validate(structuredClone(source)));
const list = EstPrintBatch.forms(catalog, p);
const pick = list.map((f) => ({{ ...f, checked: [9, 8, 1].includes(Number(f.Index)) }}));
const out = EstPrintBatch.document(pick, p, {{ view: 'EstMainDat' }}, true);
const order = [...out.html.matchAll(/<section class="(gangi[^"]*|form)">(?:<div>|<h2>)([^<]*)/g)].map((m) => m[1].split(' ')[0] + ':' + m[2]);
p.printBatch = {{ checked: [9], gangi: false }};
const saved = EstPrintBatch.forms(catalog, p).filter((f) => f.checked).map((f) => f.Index);
return {{ zero: list.some((f) => Number(f.Index) === 0), order, skipped: out.skipped, saved,
gangiOff: !EstPrintBatch.document(pick, p, {{}}, false).html.includes('class="gangi') }};
}})()`, ctx)));
"""
result = json.loads(subprocess.check_output(["node", "-e", runner], cwd=ROOT).decode("utf-8"))
assert result["zero"] is False
names = [x.split(":")[1] for x in result["order"]]
kinds = [x.split(":")[0] for x in result["order"]]
assert kinds[:2] == ["gangi", "form"] and names[0] == names[1]
assert len(result["order"]) + 2 * len(result["skipped"]) == 6
assert result["saved"] == [9]
assert result["gangiOff"] is True