"""373 B08 거리이정표 — 연결 없이 소재지 넣기 · 구간 길 선 저장 · 다시 이음 · 시점 미연결 · 녹색 점. 화면 코드는 소스 확인 + node 로 실제 TS(`findSegmentKm` · `reachesSite`)를 돌림. 서버 쪽 `path` 칸은 `test_244_9_b08_milestone_route_map.py`. """ from resources.tester.test_244_13_b08_milestone_place_leg import ( CALC, LAYOUT, STATE, STATE_STUBS, _node, _read, ) B08 = "B08_Quantity/B08_Quantity_" ROW = [{"item": "철근", "dest": "start", "note": ""}] DATA = { "site": {"mid_station_m": None, "mid_road": "비포장"}, "bases": [ {"id": "b1", "name": "병곡리", "address": "", "dir": None, "lon": 127.85, "lat": 35.66, "legs": [{"road": None, "km": None}], "to": "site", "linked": False}, ], "routes": [ {"id": "g", "name": "g", "address": "", "to": "b1", "dir": None, "lon": 127.9, "lat": 35.68, "linked": True, "legs": [{"road": "2차포장", "km": 23.8}], "rows": ROW}, ], } # fmt: skip FAIL_STUBS = STATE_STUBS.replace( 'if (url.includes("/directions")) return {', 'if (url.includes("/directions") && (globalThis as any).FAIL)' ' return { km: null, reason: "카카오 실패", path: [] };\n' ' if (url.includes("/directions")) return {', ) def test_373_안_이은_기준점에_이으면_시점_미연결_실패면_옛_거리_선_지움(): script = f"""const DATA = {__import__("json").dumps(DATA)}; await loadMilestone("p1"); const a = await findSegmentKm("p1", "g", false); const first = liveMilestone("p1"); const open = reachesSite(first, "g"); first.bases[0].linked = true; const closed = reachesSite(first, "g"); (globalThis as any).FAIL = true; const b = await findSegmentKm("p1", "g", false); const after = liveMilestone("p1").routes[0].legs; console.log(JSON.stringify({{ a, b, open, closed, first: first.routes[0].legs, after, line: segmentPath("p1", "g") }}));""" got = _node([CALC, LAYOUT, STATE], script, FAIL_STUBS) assert got["a"] == "g → 병곡리 10.5 km — 시점 미연결" and got["open"] is False assert got["closed"] is True assert got["first"][0]["path"] == [[35.68, 127.9], [35.66, 127.85]] # 구간 자료에 길 선 assert got["b"] == "g → 병곡리 — 카카오 실패" assert got["after"] == [{"road": "2차포장", "km": 23.8, "auto_km": None}] # 사용자 km 만 남음 assert got["line"] == [] def test_373_화면_소재지_지도_누름_저장된_선_녹색_점(): route = _read(B08 + "UI_Milestone_Route.ts") assert ( 'label: "소재지"' in route and "openPlaceModal(projectId, { add: false, id: routeId })" in route ) assert "onClick: (lon, lat) => void moveTo(routeId, lon, lat)," in route # 연결 없어도 누름 assert "center: () => startPoint(liveMilestone(projectId))," in route # 점 없으면 시점 쪽 assert "reachesSite(d, routeId)" in route and "시점 미연결" in route leg = _read(B08 + "UI_Milestone_LegModal.ts") assert "path: leg.path," in leg and "...(path ? { path } : {})" in leg # 모달이 선 안 지움 assert "{ ...l, auto_km: null, path: null }" in leg # 수기 = 선 지움 diagram = _read(B08 + "UI_Milestone_Diagram.ts") assert "route.legs = [{ road: null, km: null }];" in diagram # 다시 이음 = 옛 거리 · 선 지움 state = _read(B08 + "UI_Milestone_State.ts") assert "paths" not in state.replace("path:", "").replace("segmentPath", "") # 메모리 표 없음 assert "path?: Array<[number, number]> | null;" in _read(CALC) css = _read(B08 + "UI_Milestone.css") dot = css[css.index(".b08-milestone__connect {") :] assert "opacity: 0.85;" in dot[: dot.index("}")]