"""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.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(/
(?:
|

)([^<]*)/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