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>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/* 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 }));
|
||||
})();
|
||||
@@ -22,6 +22,7 @@ ROOT = os.path.dirname(os.path.dirname(HERE))
|
||||
# 새 창으로 가는 종단 패널의 화면 코드
|
||||
POPOUT_FILES = [
|
||||
"A00_Common/design/design_profile.ts",
|
||||
"A00_Common/design/design_profile_save.ts",
|
||||
"A00_Common/design/design_profile_viewport.ts",
|
||||
"B05_Profile/B05_Profile_UI_Profile_Wheel.ts",
|
||||
"B05_Profile/B05_Profile_UI_Profile_Heights.ts",
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
"""472 마무리 — 종단도 계획고 [저장] 조각을 `design_profile_save.ts` 로 떼어 냄(700줄 한계 · 동작 같음).
|
||||
|
||||
`helper_472_6_profile_save.cjs` 가 진짜 본문을 돌림 — 편집 없음 · 노선 초안 미리보기 · 노선 없음 = 조각 없음 ·
|
||||
조각 본문 = 노선 id + 편집 · 저장 뒤 버린 자리 알림 → 서버 선형 넘김 · [확정] 직전 저장 = 같은 창구 한 번.
|
||||
|
||||
./venv/Scripts/python.exe -m pytest resources/tester/test_472_6_profile_save.py -q
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
def test_계획고_저장_조각() -> None:
|
||||
proc = subprocess.run(
|
||||
["node", os.path.join(HERE, "helper_472_6_profile_save.cjs")],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=60,
|
||||
)
|
||||
assert proc.returncode == 0, proc.stderr
|
||||
r = json.loads(proc.stdout)
|
||||
edits = {"station_offsets": {"10": 0.5}, "curve_radii": {}}
|
||||
assert r["nulls"] == {"clean": None, "preview": None, "noRoute": None}
|
||||
assert r["body"] == {"route_id": 7, **edits}
|
||||
assert r["adopted"] == [{"base_pvi": [2]}, {"base_pvi": [1]}]
|
||||
assert r["calls"] == [["notice", [3]], ["put", "p", 7, edits], ["notice", []]]
|
||||
Reference in New Issue
Block a user