Files
Aislo/resources/tester/helper_design_profile_single.cjs
T
eomsangdonandClaude Opus 5.5 acd30ba32c refactor(B05·B06): 종단도 한 벌 마무리 — 배수유역도 판(createDrainageSide)을 두 보기에 끼움 · 켬끔 단추 · 흙덮기 강제 값 한 칸 · 계획고 초안 키를 등록부(alignment-draft)로
- 두 보기 같은 오른쪽 판 · 같은 켬끔 값(drainage-visible) · 단추는 도구줄 오른쪽(Profile_SideTool)
- B06 배수유역도 노선 평면선 = 최신 노선 캐시(없으면 한 번 읽기)
- 최소 흙덮기 강제 여부를 두 보기가 한 칸(profile-enforce-min-cover)에서 봄 — B06 막기 동작
- 계획고 초안 b05-profile-alignment-draft:{노선} → aislo:draft:alignment-draft:{프로젝트}:{노선}(옛 값 옮겨 받음) · 되돌리기 사진 · [초기화] 쓸기 포함
- 세로 창 고정을 _Profile_Drag 로(design_profile 684줄) · 시험 test_design_profile_single 6건

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BU9gbNE3aWFUvE61pS2WGt
2026-09-29 20:47:40 +09:00

80 lines
3.1 KiB
JavaScript

/* 종단도 한 벌(계획서 24-2c) 단위검증 헬퍼 — 계획고 초안이 등록부 칸(`alignment-draft`)으로
* 옮겨졌는지 · 옛 키 값을 옮겨 받는지 · 되돌리기 사진이 새 칸을 찍는지를 Node 로 돌린다.
* `A00_Common/design/design_store.ts` · `B05_Profile_UI_Profile_History.ts` 를 그 자리에서
* 트랜스파일한다.
*/
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
function memoryStorage() {
const map = new Map();
return {
getItem: (key) => (map.has(key) ? map.get(key) : null),
setItem: (key, value) => map.set(key, String(value)),
removeItem: (key) => map.delete(key),
key: (index) => [...map.keys()][index] ?? null,
get length() {
return map.size;
},
keys: () => [...map.keys()],
};
}
const session = memoryStorage();
const local = memoryStorage();
globalThis.window = { sessionStorage: session, localStorage: local };
globalThis.sessionStorage = session;
const cache = new Map();
function loadTs(file) {
const full = path.resolve(file);
if (cache.has(full)) return cache.get(full);
const js = ts.transpileModule(fs.readFileSync(full, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
cache.set(full, box.exports);
const localRequire = (request) => {
if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`));
return require(request);
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
cache.set(full, box.exports);
return box.exports;
}
const { useDesignStore } = loadTs(path.join(ROOT, "A00_Common", "design", "design_store.ts"));
const history = loadTs(path.join(ROOT, "B05_Profile", "B05_Profile_UI_Profile_History.ts"));
const out = {};
// ① 옛 키에 남은 초안 — 처음 읽을 때 새 칸으로 옮겨 받고 옛 키는 지운다.
local.setItem("frd_current_project_id", "p-1");
session.setItem(
"b05-profile-alignment-draft:7",
JSON.stringify({ station_offsets: { "20.000": 0.3 }, curve_radii: {} }),
);
out.adopted = useDesignStore(null, 7).get("alignmentDraft");
out.keysAfterAdopt = session.keys();
// ② 쓰기는 새 칸으로 — 프로젝트를 준 가게와 안 준 가게가 같은 칸.
useDesignStore("p-1", 7).set("alignmentDraft", {
station_offsets: { "40.000": 0.1 },
curve_radii: {},
});
out.sameSlot = useDesignStore(null, 7).get("alignmentDraft");
// ③ 되돌리기가 새 칸을 사진 찍는다 — 편집 한 걸음을 쌓고 되돌리면 앞 값이 돌아온다.
const undoStack = history.createProfileHistory(() => undefined);
useDesignStore("p-1", 7).set("alignmentDraft", {
station_offsets: { "40.000": 0.2 },
curve_radii: {},
});
undoStack.record();
out.beforeUndo = useDesignStore("p-1", 7).get("alignmentDraft");
out.undone = undoStack.undo();
out.afterUndo = useDesignStore("p-1", 7).get("alignmentDraft");
process.stdout.write(JSON.stringify(out));