refactor(387-4): 횡단 다시 셈 창구 하나 · 면적 얹기 한 곳 — 화면은 묶음에 부탁
- 다시 셈(refreshCrossDesigns) 부르는 곳 = 묶음 cross 단계 하나(design_shared savedCross) - 종단 미리 셈 · B06 설계 맞춤 · 3D 업데이트 = pipelineCross · reconcilePagePipeline(▲ 한 번 = cross 한 번) - 입력 칸 밖 세션 고침(노견 · 소단 · 단면 유형 · 조정창)은 forceCross 로 같은 입력이어도 한 번 더 - 카드 그리기 · 횡단 보기 면적 쓰기 지움 · 다시 셈 창구가 면적을 늘 얹음(바뀐 측점만 알림) - 저장 안 한 조정창 값을 상세 가게가 읽을 때 얹음(새 Section_Adjusts · B05 만 열어도 같은 면적) - 새 test_384_4_cross_window · 옛 약속 시험 넷 새 약속으로 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
/* 387-4 헬퍼 — 저장 안 한 조정창 값(세션)을 상세 가게가 얹는지(`B06_Section_Section_Adjusts`) · 얹은 뒤 구조물
|
||||
* 면적(`structureAreaRows`)이 그 값으로 바뀌는지 · 다른 노선 칸은 안 얹는지. 짝 = `test_384_4_cross_window.py`.
|
||||
*/
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
||||
const CATALOG = require("./helper_322_catalog_module.cjs"); // 구조물 표(322-1)
|
||||
|
||||
const ROOT = path.join(__dirname, "..", "..");
|
||||
const cache = new Map();
|
||||
const STUBS = { "@ui/ui_template_toast": { showToast: () => undefined } };
|
||||
|
||||
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,
|
||||
esModuleInterop: true,
|
||||
},
|
||||
}).outputText;
|
||||
const box = { exports: {} };
|
||||
cache.set(full, box.exports);
|
||||
const localRequire = (request) => {
|
||||
if (CATALOG.isCatalogRequest(request)) return CATALOG;
|
||||
if (STUBS[request]) return STUBS[request];
|
||||
const alias = { "@util/": "common_util", "@ui/": "ui_template", "@config/": "config" };
|
||||
for (const [prefix, dir] of Object.entries(alias))
|
||||
if (request.startsWith(prefix))
|
||||
return loadTs(resolve(path.join(ROOT, dir, request.slice(prefix.length))));
|
||||
return loadTs(resolve(path.join(path.dirname(full), request)));
|
||||
};
|
||||
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
||||
cache.set(full, box.exports);
|
||||
return box.exports;
|
||||
}
|
||||
const resolve = (base) =>
|
||||
[base, `${base}.ts`, path.join(base, "index.ts")].find(
|
||||
(p) => fs.existsSync(p) && fs.statSync(p).isFile(),
|
||||
) ?? `${base}.ts`;
|
||||
|
||||
function memoryStorage() {
|
||||
const map = new Map();
|
||||
return {
|
||||
getItem: (k) => (map.has(k) ? map.get(k) : null),
|
||||
setItem: (k, v) => map.set(k, String(v)),
|
||||
removeItem: (k) => map.delete(k),
|
||||
key: (i) => [...map.keys()][i] ?? null,
|
||||
get length() {
|
||||
return map.size;
|
||||
},
|
||||
};
|
||||
}
|
||||
globalThis.window = { sessionStorage: memoryStorage(), localStorage: memoryStorage() };
|
||||
|
||||
const B06 = (f) => path.join(ROOT, "B06_Section", `${f}.ts`);
|
||||
const { structureAreaRows } = loadTs(B06("B06_Section_Structure_Layouts"));
|
||||
const { withDraftAdjusts } = loadTs(B06("B06_Section_Section_Adjusts"));
|
||||
const { writeState } = loadTs(path.join(ROOT, "A00_Common", "b_page_state.ts"));
|
||||
|
||||
const sections = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, "fixtures", "b06_186_1_pipe_292.json"), "utf8"),
|
||||
).cross_sections;
|
||||
const detail = { cross_sections: sections };
|
||||
const section = sections.find((s) => s.culvert);
|
||||
const at = section.chainage_m.toFixed(2);
|
||||
const area = () => {
|
||||
const row = structureAreaRows(sections).find((r) => r.chainage_m === section.chainage_m);
|
||||
return row ? [row.cut_area_m2, row.fill_area_m2] : null;
|
||||
};
|
||||
const out = { before: area() };
|
||||
// 다른 노선 칸 — 안 얹음
|
||||
writeState("revetx", { [`${at}:outlet`]: { x: 3, d: null, h: null, m: null } }, "p", 8);
|
||||
withDraftAdjusts(detail, "p", 7);
|
||||
out.otherRoute = section.design.revet_adjust?.outlet ?? null;
|
||||
// 이 노선 — 유출 벽 4축 · 유입 형식 · 다단 수
|
||||
writeState("revetx", { [`${at}:outlet`]: { x: 1.5, d: 0, h: null, m: null } }, "p", 7);
|
||||
writeState("inletstruct", { [at]: "L" }, "p", 7);
|
||||
writeState("extrawall", { [at]: 2 }, "p", 7);
|
||||
withDraftAdjusts(detail, "p", 7);
|
||||
out.laid = {
|
||||
revet: section.design.revet_adjust.outlet,
|
||||
inlet: section.design.inlet_structure,
|
||||
extra: section.design.extra_wall_counts,
|
||||
};
|
||||
out.after = area();
|
||||
withDraftAdjusts(detail, "p", 7);
|
||||
out.again = area();
|
||||
process.stdout.write(JSON.stringify(out));
|
||||
@@ -1,8 +1,8 @@
|
||||
"""PLAN 317-1 — B05 [3D 업데이트]가 낡은 횡단을 먼저 다시 셈(요구 213).
|
||||
|
||||
- 낡음 지문(`staleKey`) — 낡은 측점이 있으면 지문 · 모두 맞으면 ""
|
||||
- 그릴 때 잰 지문이 새것일 때만 다시 셈 예약(같은 낡음 되풀이 · 서버 폴백 반복 막음)
|
||||
- 그래프가 그릴 때 지문을 패널에 넘김 · 단추는 예상형상을 짓기 전에 낡은 설계부터 다시 셈
|
||||
- 그릴 때 잰 낡음은 다시 셈을 직접 안 부름 — 계산 묶음 cross 한 곳이 셈(387-4 · ▲ 한 번 = cross 한 번)
|
||||
- 그래프가 그릴 때 지문을 패널에 넘김 · 단추는 예상형상을 짓기 전에 묶음 차례(다시 셈)를 기다림
|
||||
|
||||
실제 TS 를 `helper_317_stale_preview.cjs` 가 Node 로 돌린다(다시 셈 창구는 흉내).
|
||||
"""
|
||||
@@ -47,9 +47,9 @@ def test_stale_key_marks_only_stale_sections(result: dict) -> None:
|
||||
assert result["key_fresh"] == ""
|
||||
|
||||
|
||||
def test_same_stale_key_schedules_once(result: dict) -> None:
|
||||
# a → 부름 · a(같음) → 안 부름 · "" → 안 부름(되돌림) · a(다시 낡음) → 부름 · b → 부름
|
||||
assert result["calls"] == [1, 1, 1, 2, 3]
|
||||
def test_stale_key_never_refreshes_directly(result: dict) -> None:
|
||||
# 낡음이 와도 미리 셈은 다시 셈 창구를 안 부름 — 묶음 cross 한 곳(387-4)
|
||||
assert result["calls"] == [0, 0, 0, 0, 0]
|
||||
|
||||
|
||||
def test_draw_and_button_wiring() -> None:
|
||||
@@ -65,5 +65,5 @@ def test_draw_and_button_wiring() -> None:
|
||||
assert "pendingRecalc: pending," in render
|
||||
corridor = _read("B05_Profile", "B05_Profile_UI_Corridor.ts")
|
||||
body = corridor.split("export async function refreshCorridor", 1)[1].split("\n}\n", 1)[0]
|
||||
assert "await refreshStaleDesigns({ projectId, routeId, detail })" in body
|
||||
assert body.index("refreshStaleDesigns") < body.index("ensureCorridor")
|
||||
assert "await reconcilePagePipeline(projectId)" in body
|
||||
assert body.index("reconcilePagePipeline") < body.index("ensureCorridor")
|
||||
|
||||
@@ -99,11 +99,12 @@ def test_국부_연산_바뀐_측점만(out):
|
||||
|
||||
|
||||
def test_남은_낡음은_곡선을_그리고_경고(out):
|
||||
assert out["settleFirst"] is True # 다시 셈 기다림
|
||||
assert out["settleSameKey"] is True # 다시 셈이 못 고침
|
||||
assert out["settleAfter"] is False # 기다림 끝 — 곡선 그림
|
||||
# 387-4 — 미리 셈은 다시 셈을 안 함(묶음 cross 한 곳) · 기다릴 묶음 차례가 없으면 곧바로 곡선 + 경고
|
||||
assert out["settleFirst"] is False
|
||||
assert out["settleSameKey"] is True
|
||||
assert out["settleAfter"] is False
|
||||
assert out["settleWarns"] == 1
|
||||
assert out["settleRedraws"] >= 1 # 바뀐 것 없어도 다시 그림
|
||||
assert out["settleRedraws"] == 0
|
||||
assert out["settleClear"] is False
|
||||
|
||||
|
||||
@@ -116,7 +117,7 @@ def test_흙_배분_실패_열쇠_다시_보냄_받은_열쇠는_안_물음(out)
|
||||
|
||||
|
||||
def test_전체_측점_반영은_한_번_선택_안_박음(out):
|
||||
assert out["applyAllCalls"] == [out["total"]]
|
||||
assert out["applyAllCalls"] == [] # 387-4 — 화면이 직접 안 셈 · 묶음 cross 가 셈
|
||||
assert out["applyAllChoiceKeys"] == 0
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"""387-4(384 단계 4) 횡단 다시 셈 창구 하나 · 면적 얹기 한 곳.
|
||||
|
||||
· 다시 셈(`refreshCrossDesigns`) 부르는 곳 = 계산 묶음 cross 단계 하나(design_shared savedCross) — 종단 미리
|
||||
셈 · B06 설계 맞춤 · 3D 업데이트는 묶음에 부탁(`pipelineCross` · `reconcilePagePipeline`) · ▲ 한 번 = cross 한 번
|
||||
· 화면(횡단 보기 · 카드 그리기)은 구조물 면적을 안 고침 — 다시 셈 창구 · 상세 가게만 얹음(카드 안 그려도 면적 같음)
|
||||
· 저장 안 한 조정창 값(세션)은 상세 가게가 읽을 때 얹음 — B05 만 연 페이지도 같은 면적 · 다른 노선 칸은 안 얹음
|
||||
|
||||
./venv/Scripts/python.exe -m pytest resources/tester/test_384_4_cross_window.py -q
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
HELPER = Path(__file__).parent / "helper_384_4_adjusts.cjs"
|
||||
|
||||
|
||||
def _code(relative: str) -> str:
|
||||
text = (ROOT / relative).read_text(encoding="utf-8")
|
||||
text = re.sub(r"/\*.*?\*/", "", text, flags=re.S)
|
||||
return re.sub(r"(?m)^\s*//.*$|\s//\s.*$", "", text)
|
||||
|
||||
|
||||
def _screen_and_page_ts() -> list[Path]:
|
||||
files = list((ROOT / "A00_Common" / "design").rglob("*.ts"))
|
||||
files += (ROOT / "B05_Profile").rglob("B05_Profile_*.ts")
|
||||
files += (ROOT / "B06_Section").rglob("B06_Section_*.ts")
|
||||
return files
|
||||
|
||||
|
||||
def test_다시_셈_부르는_곳_하나() -> None:
|
||||
callers = [
|
||||
str(p.relative_to(ROOT))
|
||||
for p in _screen_and_page_ts()
|
||||
for _ in re.findall(r"(?<!function )refreshCrossDesigns\(", _code(str(p.relative_to(ROOT))))
|
||||
]
|
||||
assert callers == [str(Path("A00_Common/design/design_shared.ts"))]
|
||||
|
||||
|
||||
def test_화면은_면적_안_고침() -> None:
|
||||
hits = [
|
||||
str(p.relative_to(ROOT))
|
||||
for p in _screen_and_page_ts()
|
||||
if ("_UI_" in p.name or p.name.startswith("design_view"))
|
||||
and re.search(r"applyStructureArea\w*\(", _code(str(p.relative_to(ROOT))))
|
||||
]
|
||||
assert hits == []
|
||||
|
||||
|
||||
def test_화면은_묶음에_부탁() -> None:
|
||||
sync = _code("B06_Section/B06_Section_UI_Page_Design_Sync.ts")
|
||||
assert "pipelineCross(projectId)" in sync and "await reconcilePagePipeline(projectId)" in sync
|
||||
preview = _code("B05_Profile/B05_Profile_UI_Profile_Preview.ts")
|
||||
assert "pipelineCross(ctx.projectId)" in preview
|
||||
corridor = _code("B05_Profile/B05_Profile_UI_Corridor.ts")
|
||||
assert "await reconcilePagePipeline(projectId)" in corridor
|
||||
# 입력 칸 밖 세션 고침(노견 · 소단 · 조정창)은 「한 번 더」 표시로 같은 입력이어도 cross 다시
|
||||
cross = _code("A00_Common/design/design_pipeline_cross.ts")
|
||||
assert "export const forceCross" in cross and "|${forced}`" in cross
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def adjusts() -> dict:
|
||||
done = subprocess.run( # noqa: S603 — 고정 실행 파일
|
||||
["node", str(HELPER)], cwd=str(ROOT), capture_output=True, text=True, encoding="utf-8"
|
||||
)
|
||||
assert done.returncode == 0, done.stderr
|
||||
return json.loads(done.stdout)
|
||||
|
||||
|
||||
def test_세션_조정값을_상세_가게가_얹음(adjusts: dict) -> None:
|
||||
assert adjusts["otherRoute"]["x"] != 3 # 다른 노선 칸은 안 얹음
|
||||
assert adjusts["laid"] == {
|
||||
"revet": {"x": 1.5, "d": None, "h": None, "m": None}, # d 0 = 기본 자리(조정창 읽기와 같음)
|
||||
"inlet": "L",
|
||||
"extra": {"outlet": 2, "basin": 0},
|
||||
}
|
||||
# 얹은 값으로 구조물 면적이 바뀜 · 두 번 얹어도 같음
|
||||
assert adjusts["after"] != adjusts["before"]
|
||||
assert adjusts["again"] == adjusts["after"]
|
||||
@@ -99,7 +99,8 @@ def test_source_shared_rule_and_b05_entry_recompute():
|
||||
assert "scheduleCrossPreview();" in B05_PANEL
|
||||
# B06: 같은 규칙 하나만 쓴다 — 옛 암 2단계 필드 누락 조건도 공용 유틸로 옮겼다
|
||||
# (2026-09-03 일원화: 조건이 갈리면 같은 데이터가 두 화면에서 다른 값이 된다).
|
||||
# 판정은 종단도가 쥔 화면 선 기준(342-1 · 공용 규칙 hasStaleDesigns 를 그 선으로 부름)
|
||||
assert "staleAgainstScreen(sectionDetail, currentRouteId)" in B06_PAGE
|
||||
# 다시 셈은 계산 묶음 cross 한 곳(387-4) — B06 은 판정 · 다시 셈 없이 묶음에 부탁
|
||||
assert "pipelineCross(projectId)" in B06_PAGE
|
||||
assert "staleAgainstScreen" not in B06_PAGE
|
||||
assert "two_stage_slope === undefined" in COMMON
|
||||
assert "two_stage_slope === undefined" not in B06_PAGE
|
||||
|
||||
@@ -47,8 +47,11 @@ def test_cross_refresh_is_single_entry():
|
||||
assert "export async function refreshCrossDesigns" in REFRESH
|
||||
assert "readStandardCrossSession(projectId)" in REFRESH
|
||||
assert "readRockBoundarySession(projectId, routeId)" in REFRESH
|
||||
# 부르는 곳 = 계산 묶음 cross 단계 하나(design_shared savedCross · 387-4) — 화면은 묶음에 부탁
|
||||
shared = _read("A00_Common/design/design_shared.ts")
|
||||
assert shared.count("refreshCrossDesigns(") == 1
|
||||
for source in (B05_PREVIEW, B06_PAGE):
|
||||
assert "refreshCrossDesigns(" in source
|
||||
assert "refreshCrossDesigns(" not in source
|
||||
assert "previewCrossDesigns(" not in source
|
||||
|
||||
|
||||
@@ -75,3 +78,6 @@ def test_cross_refresh_lays_structure_areas_once():
|
||||
body = body[: body.index("\n}\n")]
|
||||
assert "applyStructureAreaRows(" in body and "structureAreaRows(" in body
|
||||
assert "applyStructureAreaRows(" not in B05_PREVIEW
|
||||
# 화면(횡단 보기 · 카드 그리기)은 면적을 안 고침 — 카드 안 그려도 면적 같음(387-4)
|
||||
assert "applyStructureAreaRows(" not in B06_PAGE
|
||||
assert "applyStructureAreas" not in _read("B06_Section/B06_Section_UI_Cross_View.ts")
|
||||
|
||||
Reference in New Issue
Block a user