Merge remote-tracking branch 'origin/main_laptop_1' into sub_laptop_2

This commit is contained in:
2026-10-20 11:23:26 +09:00
4 changed files with 65 additions and 1 deletions
@@ -158,3 +158,12 @@ export function plusStationsPart(projectId: string): SavePart {
},
};
}
/** 저장분을 다시 받음 — 추천 [적용] 뒤(서버가 추가 측점을 지움) 옛 저장분 · 따라감 기억이 남지 않게(493-5). */
export async function reloadSavedPlusStations(projectId: string): Promise<void> {
[saved, savedRows, loaded, beforeRoute, followedOnly, warnedOutside].forEach((map) =>
map.delete(projectId),
);
await loadSavedPlusStations(projectId);
notify(projectId);
}
@@ -30,6 +30,7 @@ import {
import { balloonOffsetsPayload } from "@util/common_util_mass_haul_balance_view";
import type { SavePart } from "../A00_Common/design/design_save_api";
import { clearRouteLatestCache } from "./B05_Profile_Api_Fetch";
import { reloadSavedPlusStations } from "./B05_Profile_Api_PlusStations";
import {
replanRoute,
type RouteReplanResponse,
@@ -216,6 +217,7 @@ export async function saveRecommendedRoute(
as_initial: true,
});
clearDrafts(projectId);
await reloadSavedPlusStations(projectId); // 페이지를 다시 세워도 남는 옛 저장분(493-5)
sources.get(projectId)?.saved();
const reset = routeResetNotice(saved.route_reset, saved.pipes?.crossing ?? 0);
showToast(`추천 노선을 저장했습니다 — 새 초기값입니다.${reset ? ` ${reset}` : ""}`, "success");
@@ -39,13 +39,45 @@ async function applyText(server) {
return ui.applyResetText("p");
}
/** 493-5 — 추가 측점 저장분 기억: 저장 [127 · 163] → 서버가 [적용]으로 지움 → 다시 세운 페이지가 읽는 값. */
async function plusAfterApply(reload) {
let server = [127, 163];
const drafts = new Map();
global.window = { setTimeout: () => 0, clearTimeout: () => undefined };
global.fetch = async () => ({
ok: true,
json: async () => ({ chainages: server, stations: server.map((c) => ({ chainage_m: c })) }),
});
const plus = loadTs("B05_Profile/B05_Profile_Api_PlusStations.ts", {
"../config/config_frontend": { API_BASE_URL: "", API_TIMEOUT_MS: 1000 },
"../A00_Common/design/design_store": {
draftProjectId: () => "p",
useDesignStore: () => ({
get: (k) => drafts.get(k) ?? null,
set: (k, v) => drafts.set(k, v),
}),
},
"./B05_Profile_UI_Profile_History": { onPageHistory: () => undefined },
});
await plus.loadSavedPlusStations("p");
plus.followPlusDraft("p", { plusStations: [127, 163] }); // 노선 끌기 따라감 기억
const before = plus.plusStationsOf("p");
server = []; // 추천 [적용] — 서버가 지움 · 세션 초안 비움(clearDrafts)
drafts.clear();
if (reload) await plus.reloadSavedPlusStations("p");
await plus.loadSavedPlusStations("p"); // 다시 세운 페이지
return { before, after: plus.plusStationsOf("p"), body: plus.plusStationsPart("p").body };
}
async function main() {
const input = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
const plusApply = { fixed: await plusAfterApply(true), stale: await plusAfterApply(false) };
const texts = {};
for (const [name, server] of Object.entries(input.servers)) texts[name] = await applyText(server);
process.stdout.write(
JSON.stringify({
texts,
plusApply,
notice: reset.routeResetNotice(input.reset, 2),
noticeNone: [
reset.routeResetNotice(undefined),
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
"""283 · 493-2 B05 [저장] = 보이는 화면 그대로 · 초기화 기준 = 노선 추천 [적용](요구 289 · 290).
"""283 · 493-2 · 493-5 B05 [저장] = 보이는 화면 그대로 · 초기화 기준 = 노선 추천 [적용](요구 289 · 290).
- 손 고침 [저장] — 띠 · 확인 창 · 저장 뒤 초기화 알림 · 세션 초안 통째 비움 없음(492-2 걷음 · 소스 확인).
- 추천 [적용] 확인 창 — 지워질 수 = 서버 저장분(구조물 · 관 · 추가 측점) = 적용 뒤 알림 수
(서버 `route_reset.dropped` = 저장 파일 길이) · 세션 초안은 안 셈 · 관 저장 파일 없음 = 0.
- [적용] 뒤 추가 측점 저장분 다시 받음 — 지운 측점이 목록 · [저장]에 남지 않음(493-5).
"""
from __future__ import annotations
@@ -118,3 +119,23 @@ def test_적용뒤_알림_dropped(ts):
"노선이 바뀌어 초기화했습니다 — 지움: 구조물 1 · 관 3 · 추가 측점 1 · 새 교차 관 2"
)
assert ts["noticeNone"] == [None, None]
# ── 493-5 [적용] 뒤 화면 초안 = 새 초기값 ────────────────────────────────────
def test_적용뒤_추가측점_저장분_다시받음(ts):
fixed, stale = ts["plusApply"]["fixed"], ts["plusApply"]["stale"]
assert fixed["before"] == [127, 163]
assert fixed["after"] == [] and fixed["body"] is None # [저장]이 지운 측점을 다시 안 보냄
assert stale["after"] == [127, 163] # 대조 — 다시 안 받으면 옛 저장분이 남음(고치기 전)
def test_적용_배선_추가측점_다시받기():
src = _read("B05_Profile", "B05_Profile_UI_RouteEdit_Apply.ts")
body = src[src.index("export async function saveRecommendedRoute(") :]
assert (
body.index("clearDrafts(projectId)")
< body.index("await reloadSavedPlusStations(projectId)")
< body.index("await rebuildAfterRouteSave(projectId)")
)