Merge remote-tracking branch 'origin/sub_laptop_7' into main_laptop_1
This commit is contained in:
@@ -51,6 +51,10 @@ const drafts = loadTs("B06_Section/B06_Section_Section_Drafts.ts", {
|
||||
"../A00_Common/design/design_page_data": loadTs("A00_Common/design/design_page_data.ts", {
|
||||
"../../B04_PreProcess/B04_PreProcess_Api_Fetch": serverFetch,
|
||||
"../../B05_Profile/B05_Profile_Api_Structures": serverStructures,
|
||||
"../../B06_Section/B06_Section_Api_Fetch": {
|
||||
fetchSectionContext: async () => ({ route_id: 1 }),
|
||||
},
|
||||
"./design_page_route": loadTs("A00_Common/design/design_page_route.ts"), // 노선 id 한 칸(386-2b)
|
||||
}),
|
||||
"../B05_Profile/B05_Profile_Api_Pipes_Draft": { readPendingPipes: () => draftPipes },
|
||||
"../B05_Profile/B05_Profile_Api_PlusStations": { readPlusDraft: () => null },
|
||||
|
||||
@@ -7,7 +7,14 @@ const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "t
|
||||
const ROOT = path.join(__dirname, "..", "..");
|
||||
const calls = { structures: 0, pipes: 0, version: 0 };
|
||||
let failPipes = false;
|
||||
const routeJs = ts.transpileModule(
|
||||
fs.readFileSync(path.join(ROOT, "A00_Common", "design", "design_page_route.ts"), "utf8"),
|
||||
{ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 } },
|
||||
).outputText;
|
||||
const routeBox = { exports: {} };
|
||||
new Function("exports", "module", "require", routeJs)(routeBox.exports, routeBox, () => ({}));
|
||||
const STUBS = {
|
||||
"./design_page_route": routeBox.exports, // 노선 id 한 칸(386-2b · 진짜)
|
||||
"../../B04_PreProcess/B04_PreProcess_Api_Fetch": {
|
||||
fetchDetailPipePoints: async () => {
|
||||
calls.pipes += 1;
|
||||
@@ -15,6 +22,10 @@ const STUBS = {
|
||||
return { pipe_points: [{ chainage_m: 10, facility: "pipe" }], basins: [] };
|
||||
},
|
||||
},
|
||||
// 횡단 context(세션 캐시) — 노선 id 한 칸(386-2b)
|
||||
"../../B06_Section/B06_Section_Api_Fetch": {
|
||||
fetchSectionContext: async (projectId) => ({ route_id: projectId === "p-none" ? null : 304 }),
|
||||
},
|
||||
"../../B05_Profile/B05_Profile_Api_Structures": {
|
||||
fetchStructures: async () => {
|
||||
calls.structures += 1;
|
||||
@@ -85,6 +96,17 @@ const tick = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
data.trackPageBusy(P, Promise.resolve());
|
||||
await tick();
|
||||
out.busy = seen;
|
||||
// 노선 id 한 칸(386-2b) — context 가 채움 · 저장 정본 바뀜(비움)엔 그대로 · 페이지 떠남에 비움
|
||||
const route = { before: data.pageRouteId(P) };
|
||||
route.context = (await data.pageSectionContext(P)).route_id;
|
||||
route.after = data.pageRouteId(P);
|
||||
data.forgetPageData(P);
|
||||
route.keptOnSave = data.pageRouteId(P);
|
||||
data.forgetPageData(P, true);
|
||||
route.leaving = data.pageRouteId(P);
|
||||
await data.pageSectionContext("p-none");
|
||||
route.none = data.pageRouteId("p-none");
|
||||
out.route = route;
|
||||
process.stdout.write(JSON.stringify(out));
|
||||
})().catch((error) => {
|
||||
console.error(error);
|
||||
|
||||
@@ -137,6 +137,8 @@ const { createCrossPreview } = loadTs(
|
||||
path.join(ROOT, "B05_Profile", "B05_Profile_UI_RouteEdit_Cross.ts"),
|
||||
);
|
||||
const pick = loadTs(path.join(ROOT, "A00_Common", "design", "design_selection.ts"));
|
||||
// 페이지 노선 id 한 칸(386-2b) — 판이 읽는 적용값 = 이 노선 것만
|
||||
const pageRoute = loadTs(path.join(ROOT, "A00_Common", "design", "design_page_route.ts"));
|
||||
|
||||
const record = (key, chainage_m, left, right, leftCut, rightCut) => ({
|
||||
key,
|
||||
@@ -161,12 +163,16 @@ async function run() {
|
||||
out.before = cross.watched();
|
||||
await cross.open(100);
|
||||
out.empty = { watched: cross.watched() };
|
||||
pageRoute.setPageRouteId("p-1", 3);
|
||||
session.setItem("aislo:draft:cross-display:p-1:3", "15");
|
||||
await cross.refresh();
|
||||
out.applied15 = { watched: cross.watched() };
|
||||
session.setItem("aislo:draft:cross-display:p-1:12", "8.5");
|
||||
session.setItem("aislo:draft:cross-display:p-2:99", "40");
|
||||
await cross.refresh();
|
||||
out.otherRoute = { watched: cross.watched() }; // 다른 노선 · 다른 프로젝트 값은 안 봄
|
||||
pageRoute.setPageRouteId("p-1", 12);
|
||||
await cross.refresh();
|
||||
out.latestRoute = { watched: cross.watched() };
|
||||
session.setItem("aislo:draft:cross-display:p-1:12", "abc");
|
||||
await cross.refresh();
|
||||
|
||||
@@ -87,7 +87,7 @@ def test_비우는_자리():
|
||||
store = _read("B06_Section/B06_Section_Section_Store.ts")
|
||||
assert "forgetPageData(projectId)" in drafts # 저장 정본 바뀜(invalidate → forgetDraftStations)
|
||||
assert "forgetDraftStations(projectId)" in store
|
||||
assert "forgetPageData(projectId)" in page # 페이지를 떠남
|
||||
assert "forgetPageData(projectId, true)" in page # 페이지를 떠남(노선 id 칸도 · 386-2b)
|
||||
assert "onPageBusy(projectId" in page
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
"""PLAN 386-2b sub7 — 노선 id 한 칸(design_page_data).
|
||||
|
||||
못박는 것
|
||||
- 출처 하나 = `pageSectionContext`(횡단 context · 세션 캐시)가 채운 칸 — 두 보기는 context 를 이것으로만 받음.
|
||||
- 읽는 곳(옛 출처 다섯) = 종단 보기 [저장] 몫(PA) · 횡단 보기 · 종단도 render · 평면 횡단 판(RC) · 3D · 측점 그림 —
|
||||
`pageRouteId` 만 · 묶음(PP)은 종단도 `pipelineSource().routeId`(= 칸)를 받음.
|
||||
- 칸 = 저장 정본 바뀜(invalidate)엔 그대로 · 페이지 떠남에 비움 · context 노선 없음 = null.
|
||||
|
||||
짝: `helper_384_2_page_data.cjs`(진짜 TS · 서버 흉내) — `test_384_2_page_data.py` 와 같은 헬퍼.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
ROOT = HERE.parents[1]
|
||||
|
||||
READERS = {
|
||||
"B05_Profile/B05_Profile_UI_Page_Actions.ts": "pageRouteId(projectId)",
|
||||
"A00_Common/design/design_view_cross.ts": "currentRouteId = pageRouteId(projectId);",
|
||||
"A00_Common/design/design_profile.ts": "pageRouteId(projectId) ?? givenRouteId",
|
||||
"B05_Profile/B05_Profile_UI_RouteEdit_Cross.ts": "pageRouteId(projectId)",
|
||||
"A00_Common/design/design_view_profile.ts": "pageRouteId(activeProjectId)",
|
||||
"A00_Common/design/design_view_profile_3d.ts": "pageRouteId(projectId)",
|
||||
"A00_Common/design/design_view_profile_sections.ts": "pageRouteId(projectId)",
|
||||
}
|
||||
|
||||
|
||||
def _read(rel: str) -> str:
|
||||
return (ROOT / rel).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def r() -> dict:
|
||||
proc = subprocess.run( # noqa: S603 — 고정 실행 파일
|
||||
["node", str(HERE / "helper_384_2_page_data.cjs")],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=60,
|
||||
)
|
||||
assert proc.returncode == 0, proc.stderr
|
||||
return json.loads(proc.stdout)
|
||||
|
||||
|
||||
def test_칸_채움_비움(r):
|
||||
route = r["route"]
|
||||
assert route["before"] is None and route["context"] == 304 and route["after"] == 304
|
||||
assert route["keptOnSave"] == 304 # 저장 정본 바뀜(비움)엔 그대로
|
||||
assert route["leaving"] is None # 페이지 떠남
|
||||
assert route["none"] is None # context 노선 없음
|
||||
|
||||
|
||||
@pytest.mark.parametrize("rel", sorted(READERS))
|
||||
def test_읽는_곳은_칸만(rel):
|
||||
src = _read(rel)
|
||||
assert READERS[rel] in src
|
||||
assert "context.route_id" not in src
|
||||
used = [
|
||||
line
|
||||
for line in src.splitlines()
|
||||
if re.search(r"(latest(Response)?|ctx\.latest\(\))\??\.route\??\.id\b", line)
|
||||
and "!==" not in line # 노선이 바뀌었나 견줌(다시 세움) = 출처 아님
|
||||
]
|
||||
assert not used
|
||||
|
||||
|
||||
def test_출처는_자료_줄_하나():
|
||||
data = _read("A00_Common/design/design_page_data.ts")
|
||||
assert "setPageRouteId(projectId, context.route_id)" in data
|
||||
slot = _read("A00_Common/design/design_page_route.ts")
|
||||
assert not re.search(r"^import ", slot, re.M) # 끄는 모듈 없음
|
||||
found = subprocess.run( # noqa: S603, S607 — 고정 실행 파일
|
||||
["git", "grep", "-l", "setPageRouteId(", "--", "*.ts"],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
)
|
||||
users = set(found.stdout.split()) | {
|
||||
"A00_Common/design/design_page_route.ts"
|
||||
} # 새 파일(추적 전)
|
||||
assert sorted(users) == [
|
||||
"A00_Common/design/design_page_data.ts",
|
||||
"A00_Common/design/design_page_route.ts",
|
||||
]
|
||||
for rel in (
|
||||
"A00_Common/design/design_view_cross.ts",
|
||||
"A00_Common/design/design_view_profile.ts",
|
||||
):
|
||||
src = _read(rel)
|
||||
assert "fetchSectionContext(" not in src and "pageSectionContext(" in src
|
||||
cross = _read("B05_Profile/B05_Profile_UI_RouteEdit_Cross.ts")
|
||||
assert "routeStateKeys" not in cross # 노선 번호를 몰라 훑던 길 지움
|
||||
page = _read("A00_Common/design/design_page.ts")
|
||||
assert "forgetPageData(projectId, true)" in page
|
||||
@@ -39,7 +39,9 @@ def test_적용값이_있으면_그_값_양쪽(results):
|
||||
assert results["applied15"]["watched"] == {"chainageM": 100, "leftM": 15, "rightM": 15}
|
||||
|
||||
|
||||
def test_노선이_여럿이면_최신_노선_값_다른_프로젝트는_무시(results):
|
||||
def test_페이지_노선_값만_다른_노선_프로젝트는_무시(results):
|
||||
# 노선 = 페이지 노선 id 한 칸(386-2b · 옛 「가장 큰 노선 번호」 훑기 지움)
|
||||
assert results["otherRoute"]["watched"]["leftM"] == 15
|
||||
assert results["latestRoute"]["watched"]["leftM"] == 8.5
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user