/* 카드 폭 넘김 다시 만들기 확인창(PLAN 446) 단위검증 헬퍼 — `createSampleWidener` 를 트랜스파일해 돌린다. * 취소 = 재생성 없음 · 오버레이 셈 그대로 · 확인 = 재생성 한 번 · 오버레이 올림 · 내림 짝. 결과는 JSON 한 벌. * 짝 = `test_446_widen_carry.py`. */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const ROOT = path.join(__dirname, "..", ".."); const calls = { regenerate: [], overlay: 0, asked: [] }; let answer = false; const STUBS = { "@ui/ui_template_locale": { currentLanguageIndex: 0, ui_locales: new Proxy({}, { get: (_t, key) => [`${String(key)} {width}/{sampled}`] }), }, "@ui/ui_template_elements": { showLoadingOverlay: () => calls.overlay++, hideLoadingOverlay: () => calls.overlay--, showToast: () => {}, showConfirmDialog: async (message) => { calls.asked.push(message); return answer; }, }, "./B06_Section_Api_Fetch": { regenerateSections: async (_p, _r, width) => calls.regenerate.push(width), }, "./B06_Section_Section_Store": { loadSectionDetail: async () => ({ cross_sections: [] }) }, }; const file = path.join(ROOT, "B06_Section", "B06_Section_UI_Page_Common.ts"); const js = ts.transpileModule(fs.readFileSync(file, "utf8"), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, }).outputText; const box = { exports: {} }; new Function("exports", "module", "require", js)(box.exports, box, (r) => STUBS[r]); (async () => { const widen = box.exports.createSampleWidener({ target: () => ({ projectId: "p", routeId: 1 }), sampledHalfWidth: () => 20, applyDetail: () => {}, }); const out = {}; out.within = await widen(15); // 표본 안 = 묻지 않음 out.withinAsked = calls.asked.length; out.cancel = await widen(21); out.cancelCalls = calls.regenerate.length; out.cancelOverlay = calls.overlay; answer = true; out.ok = await widen(21); out.okCalls = [...calls.regenerate]; out.okOverlay = calls.overlay; out.asked = calls.asked; process.stdout.write(JSON.stringify(out)); })();