Files
Aislo/resources/tester/helper_472_6_profile_save.cjs
T
eomsangdonandClaude Opus 5.5 8d577ef330 refactor(472 마무리): 종단도 계획고 [저장] 조각을 design_profile_save 로 떼어 냄 — design_profile 708 → 683 줄 · 동작 같음
- design_profile_save.ts 새 파일 — 한 본문 [저장] 조각 · [확정] 직전 저장 · 저장 뒤 서버 선형 넘김
- 높이 캐스케이드 설명을 B05_Profile_UI_Profile_Heights 머리로 옮김
- 팝아웃 시험 목록에 새 파일 · 저장 조각 시험(test_472_6_profile_save) 추가

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 15:33:08 +09:00

57 lines
2.3 KiB
JavaScript

/* 472 마무리 — 종단도 계획고 [저장] 조각(`design_profile_save.ts`) 진짜 본문 · 서버 창구 · 알림만 가짜.
* 결과 = 표준출력 JSON. 짝 = `test_472_6_profile_save.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 = [];
const STUBS = {
B05_Profile_Api_Fetch: {
saveProfileAlignment: async (projectId, routeId, edits) => {
calls.push(["put", projectId, routeId, edits]);
return { profile_alignment: { base_pvi: [1] }, dropped_edit_chainages: [] };
},
},
design_save: {
noticeDroppedEdits: (saved) => calls.push(["notice", saved.dropped_edit_chainages]),
},
};
const file = path.join(ROOT, "A00_Common", "design", "design_profile_save.ts");
const js = ts.transpileModule(fs.readFileSync(file, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
const req = (request) => STUBS[Object.keys(STUBS).find((name) => request.endsWith(name))] ?? {};
new Function("exports", "module", "require", js)(box.exports, box, req);
(async () => {
const state = { routeId: 7, dirty: true, previewing: false };
const adopted = [];
const edits = { station_offsets: { 10: 0.5 }, curve_radii: {} };
const save = box.exports.createProfileSave({
projectId: "p",
routeId: () => state.routeId,
edits: () => edits,
dirty: () => state.dirty,
previewing: () => state.previewing,
adopt: (next) => adopted.push(next ?? null),
});
const nulls = {};
for (const [name, patch] of [
["clean", { dirty: false }],
["preview", { previewing: true }],
["noRoute", { routeId: null }],
]) {
Object.assign(state, { routeId: 7, dirty: true, previewing: false }, patch);
nulls[name] = save.savePart();
}
Object.assign(state, { routeId: 7, dirty: true, previewing: false });
const part = save.savePart();
await part.after({ profile_alignment: { base_pvi: [2] }, dropped_edit_chainages: [3] });
await save.save();
state.dirty = false;
await save.save(); // 편집 없음 = 안 보냄
console.log(JSON.stringify({ nulls, body: part.body, adopted, calls }));
})();