feat(M02): 도면으로 보내기 — 41-1 표 변환 답 · 41-2 놓기 손잡이 꼴에 맞춤(41-3)

- 답 {표, 시트, 범위, 값} · 연결표 줄 = {연결, 시트, 범위, 글자크기, 값(시트!A1: 글)} · 다름 = 값 견줌
- placeTable(표, 연결) · [업데이트] = updateTable 바꾼 표만 값 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVPp2o6Mh2FZJr72yW3ofZ
This commit is contained in:
2026-10-04 22:47:45 +09:00
co-authored by Claude Opus 5.5
parent ecc4ed372d
commit 4a264d961e
3 changed files with 74 additions and 52 deletions
+13 -9
View File
@@ -64,7 +64,8 @@ let now = [["1.5", "2"]];
const calls = [];
globalThis.fetch = async (url, init) => {
calls.push([url, JSON.parse(init.body)]);
return { ok: true, json: async () => table(now) };
const b = JSON.parse(init.body);
return { ok: true, json: async () => ({ 표: table(now), 시트: "s1", 범위: b.범위, 값: { "s1!B2": now[0][0], "s1!C2": now[0][1] } }) };
};
(async () => {
@@ -89,17 +90,18 @@ globalThis.fetch = async (url, init) => {
// 같은 열 도면 — 기록 T1 이 있으니 새 표는 T2
const placed = [];
const handle = { placeTable: (e) => placed.push(e), updateTable: (id, c) => placed.push(["u", id, c]) };
const old = { id: "T1", 시트: "산출", 범위: "A1:A1", 글자크기: 3, 값: [["옛"]] };
const handle = { placeTable: (e, id) => placed.push([e, id]), updateTable: async (id, c) => (placed.push(["u", id, c]), 1) };
const old = { 연결: "T1", 시트: "s1", 범위: "A1:A1", 글자크기: 3, 값: { "s1!A1": "옛" } };
const drawing = (ents, links) => ({ 양식: "구조물도면", 종류: "structure", 판: 1, 열: "item1", 도번: "SD-1", 도면: { entities: ents }, ...(links ? { 연결표: links } : {}) });
ad.onDrawing(handle, { ...area, kind: "structure" }, drawing([table([["옛"]], { 연결: "T1" })], [old]));
await new Promise((r) => setTimeout(r, 20));
const notice = notices.at(-1) ?? [];
const upd = notice.find((x) => x && x.on);
if (upd) upd.on.click();
if (upd) await upd.on.click();
// 저장 — T1 은 지움 · T2 만 남음 · 값 = 표 칸 글
const saved = ad.withLinks(drawing([{ type: "Line" }, table([["9", "8"]], { 연결: "T2" })], [old]));
// 저장 — T1(업데이트로 값 바뀜) · T2 · 지운 T3 기록은 빠짐
const t3 = { ...old, 연결: "T3" };
const saved = ad.withLinks(drawing([{ type: "Line" }, table([["옛"]], { 연결: "T1" }), table([["9", "8"]], { 연결: "T2" })], [old, t3]));
const plain = ad.withLinks(drawing([table([["x"]])]));
// 다른 열 도면이면 안 놓음
const before = placed.length;
@@ -136,8 +138,8 @@ def test_보냄은_표_변환_길_뒤_같은_열_도면을_엶(got):
def test_놓을_표는_겹치지_않는_연결_id(got):
first = got["placed"][0]
assert first["shapeData"]["style"]["연결"] == "T2"
entity, link = got["placed"][0]
assert link == "T2" and entity["shapeData"]["style"]["연결"] == "T2"
def test_다시_열면_다름_알림과_업데이트(got):
@@ -147,8 +149,10 @@ def test_다시_열면_다름_알림과_업데이트(got):
def test_저장_연결표는_남은_표만(got):
now = {"s1!B2": "1.5", "s1!C2": "2"}
assert got["saved"] == [
{"id": "T2", "시트": "산출", "범위": "B2:C2", "글자크기": 2.5, "값": [["9", "8"]]}
{"연결": "T1", "시트": "s1", "범위": "A1:A1", "글자크기": 3, "값": now}, # [업데이트] 값
{"연결": "T2", "시트": "s1", "범위": "B2:C2", "글자크기": 2.5, "값": now},
]
assert got["plain"] is False