"""229-1 B09 설계내역서 레벨 단추 = 보조 탭 줄 오른쪽 — 단추 넷 · 다른 탭엔 없음 · 표 위 도구 줄 없음. - 단추 = 보조 탭 줄 도구 자리(`setTools`) · 안내 글 = 표 아래 · 못 하는 동작 = 흐림(200-2 그대로) - 쉘 배선 = 소스 글 대조(test_200_2 · test_202_1 과 같은 꼴) """ import re import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[2] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from resources.tester.helper_b09_group_cards import TABS, run # noqa: E402 B09 = "B09_Estimation/B09_Estimation_UI_" FILES = [TABS, f"{B09}TabBar.ts", f"{B09}Tabs_Bill_Level.ts"] # 가짜 DOM 에 줄 찾기(closest · querySelector(All))만 더함 · 끌기 = 빈 함수 PRELUDE = r""" document.addEventListener = () => {}; const attachDrag = () => {}; E.prototype.closest = function () { for (let e = this; e; e = e.parent) if (e.tagName === "TR") return e; return null; }; E.prototype.querySelectorAll = function () { return this.all("TR").filter((t) => t.cls.has("is-focus")); }; E.prototype.querySelector = function (s) { const i = s.match(/data-i="(-?\d+)"/)?.[1]; return this.children.find((c) => c.dataset.i === i) ?? null; }; """ def test_설계내역서_보조_줄에_단추_넷_다른_탭엔_없음(): out = run( FILES, """ const bars = createTabBars(() => {}); const items = ["들여쓰기 →", "내어쓰기 ←", "위로 ↑", "아래로 ↓"].map((t) => [t, () => {}]); const table = { rows: [{ key: "r1" }], menu: (i) => (i === 0 ? items.slice(1, 3) : []) }; const root = document.createElement("div"); const tr = document.createElement("tr"); tr.dataset.i = "0"; root.append(tr); const toolsOf = () => bars.sub.children[bars.sub.children.length - 1]; const snap = (lv) => ({ labels: toolsOf().children.map((b) => b.textContent), levels: toolsOf().children.map((b) => b.dataset.b09Level ?? null), guideIn: lv ? lv.guide.textContent.length > 0 : null, }); const show = (tab) => { bars.draw(tab); bars.setTools([]); if (tab !== "bill") return null; const lv = levelBar(root, table); bars.setTools(lv.tools); return lv; }; const bill = show("bill"); const a = snap(bill); const disabledBefore = bill.tools.map((b) => b.disabled); tr.click(); const disabledAfter = bill.tools.map((b) => b.disabled); show("dg"); const b = snap(null); show("bill"); const c = snap(null); console.log(JSON.stringify({ a, disabledBefore, disabledAfter, b: b.labels, c: c.labels, guideTag: bill.guide.tagName, guideCls: bill.guide.className, subBlank: bars.sub.classList.contains("b09-estimation__tabs--blank"), })); """, PRELUDE, ) names = ["→ 들여쓰기", "← 내어쓰기", "↑ 위로", "↓ 아래로"] assert out["a"]["labels"] == names # 설계내역서 = 단추 넷(보조 줄 오른쪽 도구 자리) assert out["a"]["levels"] == ["들여쓰기 →", "내어쓰기 ←", "위로 ↑", "아래로 ↓"] assert out["a"]["guideIn"] is True # 안내 글 = 단추 줄이 아니라 따로(표 아래로) assert out["guideTag"] == "P" and "ui-general-block__empty" in out["guideCls"] assert not out["subBlank"] # 257-1 설계내역 = 아래 탭 둘(총괄 · 설계내역서) · 빈 보조 줄 아님 assert out["disabledBefore"] == [True] * 4 # 고른 줄 없음 = 흐림 assert out["disabledAfter"] == [True, False, False, True] # 줄 누름 = 메뉴 항목대로 assert out["b"] == [] # 다른 탭(일위대가표) = 단추 없음 assert out["c"] == names # 설계내역서로 돌아오면 다시 있음 def test_표_위_도구_줄_없음_쉘_배선(): shell = (ROOT / "B09_Estimation" / "B09_Estimation_UI_Shell.ts").read_text("utf-8") assert "if (level) bars.setTools(level.tools);" in shell assert ( "panel.replaceChildren(table.root, ...(foot ? [foot] : []))" in shell ) # 203 레벨 안내 + 탭 안내 = 한 영역 assert "...(level ? [level] : [])" not in shell # 표 위 자리 없음 css = (ROOT / "B09_Estimation" / "B09_Estimation_UI_Page.css").read_text("utf-8") lvl = (ROOT / "B09_Estimation" / "B09_Estimation_UI_Tabs_Bill_Level.ts").read_text("utf-8") assert "b09-estimation__level" not in css and "b09-estimation__level" not in lvl # 키 · 단추 = 우클릭 메뉴 같은 항목 · 키 안 바뀜(Tab · Shift+Tab · Alt+↑↓ · 방향키) assert re.search(r"ACTS\[e\.shiftKey \? 1 : 0\]\[1\]", lvl)