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

This commit is contained in:
2026-10-10 19:14:12 +09:00
18 changed files with 966 additions and 90 deletions
@@ -27,6 +27,8 @@ const DSel = loadTs("A00_Common/design/design_selection.ts", {
writeState: (key, value, pid) => store.set(`${key}:${pid}`, value),
},
});
globalThis.window = { addEventListener() {}, removeEventListener() {} };
const ESC = loadTs("A00_Common/design/design_pick_escape.ts", { "./design_selection": DSel });
const IRR = {
irregularStationId: (id) => `irregular:${id}`,
isPipeStation: (s) => s.origin === "pipe",
@@ -37,6 +39,7 @@ const SY = loadTs("B05_Profile/B05_Profile_UI_Selection.ts", {
});
const PP = loadTs("A00_Common/design/design_pick_profile.ts", {
"./design_selection": DSel,
"./design_pick_escape": ESC,
"../../B05_Profile/B05_Profile_UI_Selection": SY,
"../../B05_Profile/B05_Profile_UI_IrregularStations": IRR,
});
@@ -67,7 +70,7 @@ let visible = true;
const disposers = [];
const pick = PP.bindProfilePick(
PID,
target,
{ profile: target },
{ visible: () => visible, onDispose: (fn) => disposers.push(fn) },
{ irregular: () => irregular, pipes: () => pipes, sections: () => sections },
);
+319
View File
@@ -0,0 +1,319 @@
/* 233-2 3D · 횡단 카드 · [상세] 강조 = 고름 한 칸에서 파생 — 진짜 TS 를 Node 로 돌림.
* ① 3D: `bindProfilePick`(종단 보기 구독) + 진짜 마커(MK3) · 3D 부재 고름(SPK) · three.
* ② 횡단: `bindCrossPick` · `releaseCrossHighlights`(B06_Section_UI_Page_Pick_Sync) + 카드 · 형상 흉내.
* ③ [상세]: `attachDetailSelect` 다시 그림(창 크기 바뀜) 뒤 고른 선 조각 유지.
* 표준출력 JSON 한 벌 · 짝 = test_233_2_view_pick.py.
*/
const fs = require("fs");
const path = require("path");
const ROOT = path.join(__dirname, "..", "..");
const NM = path.join(ROOT, "config", "node_modules");
const ts = require(path.join(NM, "typescript"));
const THREE = require(path.join(NM, "three", "build", "three.cjs"));
function loadTs(file, stubs = {}) {
const js = ts.transpileModule(fs.readFileSync(path.join(ROOT, file), "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
const localRequire = (request) => {
if (request === "three") return THREE;
if (stubs[request]) return stubs[request];
throw new Error(`stub 없음: ${request}`);
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
return box.exports;
}
/* ── 가짜 DOM(라벨 캔버스 · [상세] 값 칸 · 조각) ── */
const node = (tag) => {
const self = {
tag,
hidden: false,
textContent: "",
attrs: {},
classes: new Set(),
parentElement: null,
setAttribute: (k, v) => {
self.attrs[k] = String(v);
if (k === "class")
String(v)
.split(" ")
.forEach((c) => self.classes.add(c));
},
getAttribute: (k) => self.attrs[k] ?? null,
addEventListener() {},
classList: {
toggle: (c, on) => (on ? self.classes.add(c) : self.classes.delete(c)),
contains: (c) => self.classes.has(c),
},
closest: (sel) => (self.classes.has(sel.slice(1)) ? self : null),
getContext: () => null,
};
return self;
};
globalThis.document = {
createElement: node,
createElementNS: (_ns, tag) => node(tag),
addEventListener() {},
removeEventListener() {},
};
globalThis.window = { addEventListener() {}, removeEventListener() {} };
const store = new Map();
const DSel = loadTs("A00_Common/design/design_selection.ts", {
"../b_page_state": {
readState: (key, pid) => store.get(`${key}:${pid}`) ?? null,
writeState: (key, value, pid) => store.set(`${key}:${pid}`, value),
},
});
const ESC = loadTs("A00_Common/design/design_pick_escape.ts", { "./design_selection": DSel });
const IRR = {
irregularStationId: (id) => `irregular:${id}`,
isPipeStation: (s) => s.origin === "pipe",
};
const SY = loadTs("B05_Profile/B05_Profile_UI_Selection.ts", {
"../A00_Common/design/design_selection": DSel,
"./B05_Profile_UI_IrregularStations": IRR,
});
const PP = loadTs("A00_Common/design/design_pick_profile.ts", {
"./design_selection": DSel,
"./design_pick_escape": ESC,
"../../B05_Profile/B05_Profile_UI_Selection": SY,
"../../B05_Profile/B05_Profile_UI_IrregularStations": IRR,
});
const MK3 = loadTs("B05_Profile/B05_Profile_UI_Markers.ts", {
"@util/common_util_svg": { inferStationInterval: () => 20, stationLabel: (c) => `0+${c}` },
});
const SPK = loadTs("B05_Profile/B05_Profile_UI_Viewer_Structure_Pick.ts");
const SYNC = loadTs("B06_Section/B06_Section_UI_Page_Pick_Sync.ts", {
"../A00_Common/design/design_selection": DSel,
"../A00_Common/design/design_pick_escape": ESC,
});
const CROSS_PAD = Function(
`return ${/export const CROSS_PAD = (\{[^}]*\})/.exec(fs.readFileSync(path.join(ROOT, "B06_Section", "B06_Section_UI_Section_Common.ts"), "utf8"))[1]}`,
)();
// [상세] 조각 모듈은 helper_209_1 과 같은 꼴로 딸린 모듈까지 진짜로 읽음(카드 공용만 흉내)
const DEEP_STUBS = {
"@ui/ui_template_context_menu": { createMapContextMenu: () => ({}) },
"./B06_Section_UI_Section_Common": { CROSS_PAD },
};
const resolveTs = (base) => (fs.existsSync(`${base}.ts`) ? `${base}.ts` : base);
function loadDeep(full) {
const js = ts.transpileModule(fs.readFileSync(full, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
const localRequire = (request) => {
if (DEEP_STUBS[request]) return DEEP_STUBS[request];
if (request.endsWith(".css")) return {};
if (request.startsWith("@util/"))
return loadDeep(resolveTs(path.join(ROOT, "common_util", request.slice(6))));
return loadDeep(resolveTs(path.join(path.dirname(full), request)));
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
return box.exports;
}
const DTS = loadDeep(path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Detail_Select.ts"));
const out = {};
const PID = "p233b";
const sel = (chainageM, structureId = null, options = {}) =>
DSel.selectDesign(
PID,
chainageM === null ? DSel.NO_SELECTION : { chainageM, structureId },
options,
);
/* ── ① 3D ── */
const bounds = { x: [0, 200], y: [0, 200], z: [0, 10] };
const scene = new THREE.Scene();
const markers = MK3.createRouteMarkers(scene, () => bounds);
const STATIONS = [
...[100, 120].map((at) => ({ station_id: `s${at}`, chainage_m: at, center_x: at })),
{ station_id: "irregular:sign", chainage_m: 127.86, center_x: 127.86 },
].map((s) => ({ ...s, center_y: 100, center_z: 5, frame: { left_xy: [0, 1] }, kind: "regular" }));
markers.renderStationLines(STATIONS, 3);
let notified = 0;
markers.onStationSelectionChange(() => (notified += 1));
const corridor = new THREE.Group();
const member = new THREE.Mesh(new THREE.BoxGeometry(4, 2, 4), new THREE.MeshLambertMaterial());
member.userData = { chainageM: 160, kind: "pipe", key: "inlet" };
const wall = new THREE.Mesh(new THREE.BoxGeometry(4, 2, 4), new THREE.MeshLambertMaterial());
wall.userData = { chainageM: 120, kind: "wall", key: "own" };
corridor.add(member, wall);
const structurePick = SPK.bindStructurePick({
canvas: { addEventListener() {}, removeEventListener() {} },
camera: () => null,
group: () => corridor,
blocked: () => false,
});
const profile = { station: null, structure: null };
let b05Visible = true;
const disposers = [];
PP.bindProfilePick(
PID,
{
profile: {
setSelectedStation: (id) => Object.assign(profile, { station: id, structure: null }),
setSelectedStructure: (id) => Object.assign(profile, { station: null, structure: id }),
},
viewer: { markers, structurePick },
},
{ visible: () => b05Visible, onDispose: (fn) => disposers.push(fn) },
{
irregular: () => [{ id: "sign", chainage_m: 127.86, origin: "user" }],
pipes: () => [],
sections: () => STATIONS.filter((s) => s.station_id.startsWith("s")),
},
);
const bar = (id) => markers.group.children[1].children.find((o) => o.userData.stationId === id);
const pin = () => markers.group.children.find((g) => g.renderOrder === 9);
const lit = (mesh) => mesh.material.emissive.getHex() !== 0;
const view3d = () => ({
red: STATIONS.map((s) => s.station_id).filter(
(id) => bar(id).material.color.getHexString() === "ef4444",
),
pin: pin().visible,
member: lit(member),
wall: lit(wall),
profile: { ...profile },
});
sel(120, null, { from: "b06" }); // 횡단 카드 120 고름 → 종단 보기도 값을 받음
out.card120 = view3d();
sel(160, null, { partKey: "inlet", from: "b06" });
out.part160 = view3d();
sel(127.86, "sign", { from: "b05" }); // 목록 표지 — 그 자리 구조물 측점 띠
out.sign = view3d();
sel(null);
out.released3d = view3d();
out.notified = notified; // 칠하기만 — 마커 알림으로 사슬이 다시 돌지 않음
disposers.forEach((fn) => fn());
/* ── ② 횡단 카드 · 범위 · 형상 ── */
const calls = [];
const sections = [100, 120].map((at) => ({ station_id: `s${at}`, chainage_m: at }));
const revetLit = new Set([120]);
let cardSelected = "s120";
let crossVisible = true;
let releaseCross;
const deps = {
sections: () => sections,
controls: {
revetOffset: {
highlightFor: (s) => revetLit.has(s.chainage_m),
selectedFor: (s) => revetLit.has(s.chainage_m),
select: (at) => revetLit.delete(at),
},
ford: { selectedFor: () => false, select() {} },
box: { selectedFor: () => false, select() {} },
},
releaseForm: () => calls.push("releaseForm"),
view: {
focusStation: (id) => {
calls.push(`focus:${id}`);
if (id === null && cardSelected !== null) {
cardSelected = null;
releaseCross(); // 카드 리스너(null) → 풀기 한 길 다시 부름 — 되돌아온 부름은 건너뜀
}
},
refreshCards: (list) => calls.push(`refresh:${list.join(",")}`),
selectMark: (id) => calls.push(`mark:${id}`),
},
reapply: () => calls.push("reapply"),
};
const crossDisposers = [];
const crossPick = SYNC.bindCrossPick(
PID,
{ visible: () => crossVisible, onDispose: (fn) => crossDisposers.push(fn) },
deps,
);
releaseCross = () => {
crossPick.release();
sel(null, null, { from: "b06" });
};
sel(120, null, { from: "b06" });
out.ownPick = calls.splice(0);
sel(140, null, { from: "esc" });
out.otherPick = calls.splice(0);
releaseCross(); // 카드 다시 누름 · 목록 다시 누름 · 보기 오감
out.release = calls.splice(0);
out.revetAfter = [...revetLit];
revetLit.add(100);
cardSelected = "s100";
sel(null, null, { from: "esc" }); // 다른 곳 풀기(Esc)
out.otherRelease = calls.splice(0);
crossVisible = false;
sel(100, null, { from: "esc" });
out.hidden = calls.splice(0);
crossDisposers.forEach((fn) => fn());
/* ── ③ [상세] 선 조각 — 다시 그린 뒤 고름 유지 ── */
let axes = {
maxOffset: 10,
pixelsPerMeter: 10,
displayMax: 110,
elevationMid: 100,
exaggeration: 1,
};
const groundM = [
[
[-5, 100],
[0, 101],
],
[
[0, 101],
[5, 99],
],
];
const toPx = ([o, e]) =>
[
CROSS_PAD.left + (axes.maxOffset - o) * axes.pixelsPerMeter,
CROSS_PAD.top + (axes.displayMax - e) * axes.pixelsPerMeter,
].join(",");
const layerChildren = [];
const layer = {
querySelectorAll: () => [...layerChildren],
append: (hit) => layerChildren.push(hit),
};
const drawGround = () => {
layerChildren.length = 0;
for (const pts of groundM) {
const el = node("polyline");
el.tagName = "polyline";
el.setAttribute("class", "b06-chart__cross-profile");
el.setAttribute("points", pts.map(toPx).join(" "));
el.hasAttribute = () => false;
layerChildren.push(el);
}
};
let click = null;
const cad = {
addEventListener: (_type, fn) => (click = fn),
querySelector: (s) => (s === "g.b06-chart__plot-layer" ? layer : null),
};
const select = DTS.attachDetailSelect({
cad,
design: () => undefined,
axes: () => axes,
picked() {},
commit() {},
});
drawGround();
select.redraw();
const hit = layerChildren.find((el) => el.classes.has(DTS.PIECE_HIT_CLASS));
click({ target: hit, shiftKey: false, ctrlKey: false, metaKey: false, stopPropagation() {} });
out.detailPicked = select.source("length")?.pieces.length ?? 0;
axes = { ...axes, pixelsPerMeter: 23 }; // 창 크기 바뀜 → 다시 그림
drawGround();
select.redraw();
out.detailAfterRedraw = select.source("length")?.pieces.length ?? 0;
groundM.splice(0, 1, [
[-6, 100],
[0, 102],
]); // 그 조각 자리가 바뀌면 고름도 빠짐
drawGround();
select.redraw();
out.detailAfterChange = select.source("length")?.pieces.length ?? 0;
process.stdout.write(JSON.stringify(out));
+171
View File
@@ -0,0 +1,171 @@
/* 233-3 풀기 한 길(Esc) · 배수유역도 다시 얹음 — 진짜 `design_pick_escape` · `design_pick_profile` ·
* `B06_Section_UI_Page_Pick_Sync` · `design_selection` 을 Node 로 돌림. 창 키 · 폼 · 지도 · 카드는 흉내.
* 표준출력 JSON 한 벌 · 짝 = test_233_3_release.py.
*/
const fs = require("fs");
const path = require("path");
const ROOT = path.join(__dirname, "..", "..");
const ts = require(path.join(ROOT, "config", "node_modules", "typescript"));
function loadTs(file, stubs = {}) {
const js = ts.transpileModule(fs.readFileSync(path.join(ROOT, file), "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
const localRequire = (request) => {
if (stubs[request]) return stubs[request];
throw new Error(`stub 없음: ${request}`);
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
return box.exports;
}
/* 창 키 듣기 · 창(모달) 흉내 */
const keyListeners = new Set();
globalThis.window = {
addEventListener: (type, fn) => type === "keydown" && keyListeners.add(fn),
removeEventListener: (type, fn) => keyListeners.delete(fn),
};
let modalOpen = false;
globalThis.document = { querySelector: () => (modalOpen ? {} : null) };
const press = (key, { inInput = false, prevented = false } = {}) => {
const event = {
key,
defaultPrevented: prevented,
target: { closest: () => (inInput ? {} : null) },
};
for (const fn of [...keyListeners]) fn(event);
};
const store = new Map();
const DSel = loadTs("A00_Common/design/design_selection.ts", {
"../b_page_state": {
readState: (key, pid) => store.get(`${key}:${pid}`) ?? null,
writeState: (key, value, pid) => store.set(`${key}:${pid}`, value),
},
});
const ESC = loadTs("A00_Common/design/design_pick_escape.ts", { "./design_selection": DSel });
const IRR = {
irregularStationId: (id) => `irregular:${id}`,
isPipeStation: (s) => s.origin === "pipe",
};
const SY = loadTs("B05_Profile/B05_Profile_UI_Selection.ts", {
"../A00_Common/design/design_selection": DSel,
"./B05_Profile_UI_IrregularStations": IRR,
});
const PP = loadTs("A00_Common/design/design_pick_profile.ts", {
"./design_selection": DSel,
"./design_pick_escape": ESC,
"../../B05_Profile/B05_Profile_UI_Selection": SY,
"../../B05_Profile/B05_Profile_UI_IrregularStations": IRR,
});
const SYNC = loadTs("B06_Section/B06_Section_UI_Page_Pick_Sync.ts", {
"../A00_Common/design/design_selection": DSel,
"../A00_Common/design/design_pick_escape": ESC,
});
const PID = "p233c";
const sel = (chainageM, structureId = null, from = "b05") =>
DSel.selectDesign(PID, chainageM === null ? DSel.NO_SELECTION : { chainageM, structureId }, {
from,
});
/* ── 종단 보기(B05) — 종단도 · 배수유역도 · 좌측 폼 흉내 ── */
const map = { pipe: null, mark: null, notifies: 0 };
const profile = { station: null, structure: null };
const form = { open: "wall", resets: 0 };
let b05Visible = true;
const b05 = PP.bindProfilePick(
PID,
{
profile: {
setSelectedStation: (id) => Object.assign(profile, { station: id, structure: null }),
setSelectedStructure: (id) => Object.assign(profile, { station: null, structure: id }),
drainage: {
// 진짜 판 꼴 — 0.51 m 안 관을 고름 · notify 거짓이면 밖으로 안 알림
selectPipeAtChainage: (at, notify = true) => {
map.pipe = at === null ? null : Math.abs(at - 80.17) < 0.51 ? 80.17 : null;
if (notify) map.notifies += 1;
},
markStation: (at) => (map.mark = at),
},
},
form: {
hasSelection: () => form.open !== null,
selectById: () => {
form.open = null;
form.resets += 1;
},
},
},
{ visible: () => b05Visible, onDispose() {} },
{
irregular: () => [{ id: "p80", chainage_m: 80.17, origin: "pipe" }],
pipes: () => [{ chainage_m: 80.17 }],
sections: () => [80, 100, 120].map((at) => ({ station_id: `s${at}`, chainage_m: at })),
},
);
/* ── 횡단 보기(B06) — 카드 · 형상 · 폼 흉내 ── */
const cross = [];
let b06Visible = false;
SYNC.bindCrossPick(
PID,
{ visible: () => b06Visible, onDispose() {} },
{
sections: () => [],
controls: {
revetOffset: { highlightFor: () => false, selectedFor: () => false, select() {} },
ford: { selectedFor: () => false, select() {} },
box: { selectedFor: () => false, select() {} },
},
releaseForm: () => cross.push("releaseForm"),
view: {
focusStation: (id) => cross.push(`focus:${id}`),
refreshCards: () => undefined,
selectMark: (id) => cross.push(`mark:${id}`),
},
reapply: () => cross.push("reapply"),
},
);
const snap = () => ({
session: DSel.readSelection(PID),
profile: { ...profile },
map: { ...map },
form: { ...form },
});
const out = {};
sel(80.17);
out.pipePick = snap();
// 배수유역도 재계산이 관 · 유역 고름을 지움 → 같은 값으로 다시 얹음(알림 없이)
map.pipe = null;
map.mark = null;
b05.paint();
out.afterRecompute = snap();
press("Escape", { inInput: true });
out.escInInput = snap();
modalOpen = true;
press("Escape");
modalOpen = false;
out.escModal = snap();
press("Escape", { prevented: true });
out.escPrevented = snap();
press("Escape");
out.esc = snap();
out.crossWhileHidden = cross.splice(0);
// 목록 다시 누름 같은 B05 풀기(값 비움)는 폼을 그 길이 이미 닫음 — 구독은 폼을 또 닫지 않음
form.open = "sign";
sel(100, "sign");
sel(null);
out.listRelease = snap();
// 횡단 보기가 보일 때 Esc = 카드 · 폼 · 범위 · 형상 모두 풂
b05Visible = false;
b06Visible = true;
sel(120, null, "b06");
press("Escape");
out.crossEsc = cross.splice(0);
out.crossSession = DSel.readSelection(PID);
out.listeners = keyListeners.size;
process.stdout.write(JSON.stringify(out));
+2 -2
View File
@@ -80,13 +80,13 @@ def test_숨은_보기는_안_그리고_보이면_다시_얹음(out) -> None:
def test_풂과_구독_끊음(out) -> None:
assert out["released"] == line(None)
assert out["disposers"] == 1
assert out["disposers"] == 2 # 구독 + Esc 듣기(233-3)
assert out["paintsAfterDispose"] == 0
def test_종단_보기_배선() -> None:
view = _read("A00_Common", "design", "design_view_profile.ts")
assert "bindProfilePick(activeProjectId, profilePanel, host," in view
assert "bindProfilePick(" in view and "{ profile: profilePanel, viewer," in view
# 폼이 닫히는 길(저장 뒤 · 관 폼으로)은 종단을 끄지 않고 값대로 다시 얹음
assert "profilePanel.setSelectedStructure(structure?.structure_id ?? null)" not in view
assert view.count("profilePick.paint()") >= 3
+103
View File
@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
"""233-2 3D(띠 · 핀 · 부재) · 횡단 카드(고름 · --span · 형상 · 포장층) · [상세] 선 조각 = 고름 한 칸에서 파생.
까닭: 3D 는 화면끼리 손으로 부르는 사슬로만 칠해져 길마다 빠짐(구조물 고름 뒤 옛 띠 남음 · 횡단 카드
고름은 부재를 안 켬) · 횡단 카드를 풀어도 `--span` · 포장층이 남음(a4) · 풀기 길마다 끄는 범위가 다름 ·
[상세] 선 조각은 다시 그릴 때(창 크기 · 카드 다시 세움) 고름을 지워 바로 꺼짐.
고침: 종단 보기 구독이 3D 띠 · 핀 · 부재까지 값으로 칠함(마커 알림 없이) · 횡단 보기 구독(`bindCrossPick`)은
다른 곳이 바꾼 값을 넘김 적용 길로 다시 세우고 · 풀기는 한 길(`releaseCrossHighlights` — 카드 · 폼 관 ·
범위 테두리 · 포장층 · 형상) · [상세] 다시 그림은 같은 자리 조각 고름 유지.
진짜 TS 를 `helper_233_2_view_pick.cjs` 가 Node(three 포함)로 돌린다.
"""
from __future__ import annotations
import json
import os
import subprocess
import pytest
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.abspath(os.path.join(HERE, "..", ".."))
pytestmark = pytest.mark.skipif(
not os.path.isdir(os.path.join(ROOT, "config", "node_modules")),
reason="프론트엔드 의존성 미설치",
)
def _read(*parts: str) -> str:
with open(os.path.join(ROOT, *parts), encoding="utf-8") as handle:
return handle.read()
@pytest.fixture(scope="module")
def out() -> dict:
proc = subprocess.run( # noqa: S603 — 고정 실행 파일
["node", os.path.join(HERE, "helper_233_2_view_pick.cjs")],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
def test_3D_횡단_카드_고름은_띠_핀_그_측점_부재(out) -> None:
card = out["card120"]
assert (card["red"], card["pin"], card["wall"], card["member"]) == (["s120"], True, True, False)
assert card["profile"]["station"] == "s120"
def test_3D_부재키_고름은_그_부재만_띠는_없음(out) -> None:
part = out["part160"]
assert (part["red"], part["pin"], part["member"], part["wall"]) == ([], False, True, False)
def test_3D_구조물_고름은_그_자리_구조물_측점_띠(out) -> None:
assert out["sign"]["red"] == ["irregular:sign"]
assert out["sign"]["profile"]["structure"] == "sign"
def test_3D_풂과_알림_없음(out) -> None:
released = out["released3d"]
assert (released["red"], released["pin"], released["member"], released["wall"]) == (
[],
False,
False,
False,
)
assert out["notified"] == 0 # 칠하기만 — 마커 알림이 사슬을 다시 돌리지 않음
def test_횡단_제_누름은_되받지_않고_다른_곳_값은_다시_세움(out) -> None:
assert out["ownPick"] == []
assert out["otherPick"] == ["reapply"]
assert out["hidden"] == [] # 숨은 보기는 안 받음
def test_횡단_풀기_한_길은_범위_테두리_형상까지(out) -> None:
for key in ("release", "otherRelease"):
assert out[key] == ["releaseForm", "focus:null", "mark:null", out[key][-1]]
assert out["release"][-1] == "refresh:120"
assert out["revetAfter"] == []
def test_상세_다시_그려도_같은_자리_조각_고름_유지(out) -> None:
assert out["detailPicked"] == 1
assert out["detailAfterRedraw"] == 1
assert out["detailAfterChange"] == 0
def test_배선() -> None:
cross = _read("A00_Common", "design", "design_view_cross.ts")
assert "bindCrossPick(projectId, host," in cross
assert "crossPick.release()" in cross
# 카드 다시 누름 = 풀기 한 길
assert "releaseCross(); // 카드 다시 누름" in cross
assert len(cross.splitlines()) <= 685
profile = _read("A00_Common", "design", "design_view_profile.ts")
assert "{ profile: profilePanel, viewer," in profile
assert len(profile.splitlines()) <= 700
+108
View File
@@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
"""233-3 좌측 목록 · 폼 · 배수유역도 · 남은 바로 꺼짐 자리 · 풀기 = Esc 한 길(조사 AF (나) ⑤ · a3 · a5 · a6).
까닭: 배수유역도 재계산이 관 마커 · 유역 고름을 지움(지도만 꺼짐) · 지도 · 유역 고름은 고름 한 칸에 안 적혀
마름모가 안 옮겨짐 · 목록 관 줄은 폭 0.05 · 관이 조금 옮겨지면 줄 강조 빠짐 · 목록 관 고름은 화면마다 손으로
불러 길마다 빠짐 · 풀기가 화면마다 다름(어디까지 푸는지 제각각).
고침: 종단 보기 구독이 배수유역도(관 마커 · 유역 · 마름모)까지 값으로 칠함(알림 없이 · 재계산 뒤 다시 얹음) ·
지도 고름 · 목록 관 고름 · 목록 다시 누름도 고름 한 칸에 적고 칠하기는 구독 몫 · 목록 줄 폭 = `PIPE_MATCH_M` ·
옮겨진 관도 고름 따라감 · Esc = 고름 한 칸 비움 → 종단 · 3D · 지도 · 폼 · 횡단 카드 · 범위 · 형상 모두 풂
(입력 칸 · 창 · 먼저 받은 Esc 는 그쪽 몫).
진짜 TS 를 `helper_233_3_release.cjs` 가 Node 로 돌린다.
"""
from __future__ import annotations
import json
import os
import subprocess
import pytest
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.abspath(os.path.join(HERE, "..", ".."))
pytestmark = pytest.mark.skipif(
not os.path.isdir(os.path.join(ROOT, "config", "node_modules")),
reason="프론트엔드 의존성 미설치",
)
def _read(*parts: str) -> str:
with open(os.path.join(ROOT, *parts), encoding="utf-8") as handle:
return handle.read()
@pytest.fixture(scope="module")
def out() -> dict:
proc = subprocess.run( # noqa: S603 — 고정 실행 파일
["node", os.path.join(HERE, "helper_233_3_release.cjs")],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
def test_관_고름은_지도_관_마커_유역_마름모까지_알림_없이(out) -> None:
assert out["pipePick"]["map"] == {"pipe": 80.17, "mark": 80.17, "notifies": 0}
assert out["pipePick"]["profile"]["station"] == "irregular:p80"
def test_재계산이_지운_지도_고름을_같은_값으로_다시_얹음(out) -> None:
assert out["afterRecompute"]["map"] == {"pipe": 80.17, "mark": 80.17, "notifies": 0}
def test_입력칸_창_먼저_받은_Esc는_안_풂(out) -> None:
for key in ("escInInput", "escModal", "escPrevented"):
assert out[key]["session"] == {"chainageM": 80.17, "structureId": None}, key
assert out[key]["form"]["resets"] == 0, key
def test_Esc는_값_종단_지도_폼_모두_풂(out) -> None:
esc = out["esc"]
assert esc["session"] is None
assert esc["profile"] == {"station": None, "structure": None}
assert (esc["map"]["pipe"], esc["map"]["mark"]) == (None, None)
assert esc["form"] == {"open": None, "resets": 1}
assert out["crossWhileHidden"] == [] # 숨은 횡단 보기는 안 받음
def test_B05_목록_풀기는_그_길이_폼을_닫고_구독은_폼을_또_안_닫음(out) -> None:
release = out["listRelease"]
assert release["session"] is None
assert release["profile"] == {"station": None, "structure": None}
assert release["form"]["resets"] == 1 # Esc 때 한 번뿐
def test_횡단_보기_Esc는_카드_폼_범위_형상_모두(out) -> None:
assert out["crossEsc"] == ["releaseForm", "focus:null", "mark:null"]
assert out["crossSession"] is None
assert out["listeners"] == 2 # 보기마다 하나 — 보이는 보기만 받음
def test_배선() -> None:
view = _read("A00_Common", "design", "design_view_profile.ts")
assert "onBasinSelected: (chainageM) => pickFromMap(chainageM)" in view
assert "onPipeSelected: (chainageM) => pickFromMap(chainageM)" in view
assert "if (!selectionSyncing) rememberPick(chainageM, null);" in view
assert "onListRelease: () => rememberPick(null, null)" in view
assert "form: panel.structures" in view
assert len(view.splitlines()) <= 700
panel = _read("B05_Profile", "B05_Profile_UI_Panel.ts")
assert "onListRelease: callbacks.onListRelease" in panel
drainage = _read("B05_Profile", "B05_Profile_UI_Drainage_Panel.ts")
assert "if (notify) callbacks.onPipeSelected?.(pickedChainage);" in drainage
assert "selectBasin(basinIndexOfPipe(basins, picked ?? null), notify);" in drainage
listing = _read("B05_Profile", "B05_Profile_UI_Structures_List.ts")
assert "< PIPE_MATCH_M" in listing and "< 0.05" not in listing
structures = _read("B05_Profile", "B05_Profile_UI_Structures_Panel.ts")
assert "selectedPipeChainage = kept.chainage_m;" in structures
# 저장 · 새로 읽기 뒤 목록 주입이 관 폼을 닫지 않음(닫히며 종단 선까지 꺼졌음)
assert "if (!applyingLive && selectedPipeChainage === null)" in structures
assert len(structures.splitlines()) <= 700
cross = _read("A00_Common", "design", "design_view_cross.ts")
assert "releaseForm: () => structuresPanel.showAtChainage(null)" in cross
assert len(cross.splitlines()) <= 685