Files
Aislo/resources/tester/helper_472_5r_route_save.cjs
T
eomsangdonandClaude Opus 5.5 cfdcf0aed7 fix(472-5 남음): 암선 · 암 경사 · B05 상단측 메모리 맵 걷음 · 노선 저장 뒤 옛 노선 칸 · hold 비움
- 암 경계 · 암 절토 경사 저장소(`B06_Section_UI_Page_Persist`) = 세션 칸이 주인 — 읽을 때마다 측점 열쇠 칸(`readCells`) · 고칠 때 지금 칸을 읽어 그 측점만 바꿔 씀(`putCell`) · 메모리 맵 · load · 갈아끼움 다시 읽기(keyedStores · reloadKeyedStores) 걷음 · ↶ 뒤 다음 조작이 되돌림을 덮던 흠(N5) 고침
- 저장 재료 = `offsets()` · `ratios()`(새 Map) · ↶ ↷ 가 rockb · cutslope 칸을 바꾸면 조정창과 같은 onRestore 로 카드 · 면적 다시
- B05 상단측 메모리 맵(uphillOverrides · load/saveUphillOverrides) 걷음 — 읽는 곳 없이 저장 뒤 비우기만 하던 사본 · 값 주인 = 세션 칸 `uphill` · 상단측 차례 = 기본 조각 그대로
- 노선 바뀐 [저장] 성공 뒤(페이지 다시 세운 뒤) 옛 노선 번호의 노선 범위 초안(`clearRouteDrafts`) · `route-draft-hold` 비움 · 넘김 규칙 그대로 · 같은 번호면 노선 칸 안 지움 · 실패면 그대로
- 시험 test_472_5r_rock_owner 7(옛 코드 빨강 5) · 옛 단언 고침(176_3 · 271 · 443 상단측 조각 · 344_3 저장소 load)
- 위키 암선 · 암 경사 · ↶ ↷ 규칙 · 노선 저장 뒤 정리 줄

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

69 lines
2.6 KiB
JavaScript

/* 472-5 남음 헬퍼 — 노선 바뀐 [저장] 뒤 옛 노선 세션 칸 · 초안 전 hold 비움(`design_save.ts` 그대로 · 서버 창구 ·
* 세션 창구는 가짜). 짝 = `test_472_5r_rock_owner.py`. 표준출력 JSON. */
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
globalThis.window = { setTimeout, clearTimeout };
const anything = () =>
new Proxy({}, { get: (_target, key) => (key === "__esModule" ? false : () => undefined) });
function load(file, stubs) {
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] ?? anything());
return box.exports;
}
async function once(newRouteId, fail) {
const calls = [];
const KEYS = ["settings", "pipes", "structures", "plusStations", "alignment"];
const save = load(path.join(ROOT, "A00_Common", "design", "design_save.ts"), {
"../b_page_state": {
clearRouteDrafts: (p, r) => calls.push(`clearRouteDrafts:${p}:${r}`),
clearState: (name, p) => calls.push(`clearState:${name}:${p}`),
stateKey: () => null,
},
"./design_save_api": {
SAVE_PART_KEYS: [...KEYS, "cross"],
DesignSaveError: Error,
postDesignSave: async () => {
calls.push("post");
if (fail) throw new Error("서버 500");
return { waited: false, steps: { route: { route_id: newRouteId } } };
},
},
"../../B05_Profile/B05_Profile_UI_RouteEdit_Apply": {
pendingRouteSave: async () => ({ draft: 1 }),
routeCarryPart: () => ({ carry: {}, cross: { body: {} } }),
routeSaved: () => calls.push("routeSaved"),
routeSaveSummary: () => "",
rebuildAfterRouteSave: async () => calls.push("rebuild"),
},
});
const done = await save.saveDesign({
projectId: "p1",
routeId: () => 3,
crossPart: async () => null,
failed: () => calls.push("failed"),
});
// 저장 뒤 정리와 무관한 칸(종류 캐시)은 빼고 봄
return { done, calls: calls.filter((c) => !c.includes("structure-type-cache")) };
}
(async () => {
const out = {
moved: await once(9, false),
same: await once(3, false),
failed: await once(9, true),
};
process.stdout.write(JSON.stringify(out));
})().catch((error) => {
process.stderr.write(String(error.stack || error));
process.exit(1);
});