- 헬퍼 동작 그대로(풀이 함수 본문은 옮겨 담음) · 제품 코드 안 고침 - 확인: 이 묶음 헬퍼를 쓰는 시험 428 개 전 417 통과 → 후 417 통과 (시험별 junit 대조 · 어긋남 0) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
66 lines
2.5 KiB
JavaScript
66 lines
2.5 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 { makeLoader } = require("./helper_ts_stub_loader.cjs");
|
|
|
|
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 { loadTs } = makeLoader({
|
|
root: ROOT,
|
|
});
|
|
|
|
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 = {};
|
|
// ① 옛 키(프로젝트 없음)에 남은 초안 — 안 받음(387-1 · 다른 프로젝트 초안일 수 있음).
|
|
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));
|