"""557-2 부품 · 테마 작은 흠 지킴 시험 — 위험 채움 흰 글 대비 · 계산 줄 · 칸 램프 · 넓은 중간 창 · 값 목록 규칙 꼴 · 구역 머리 · 입력 칸 2열(D01 · E01 이 B02 클래스를 안 빌림).""" import re from test_552_3_card import ROOT, _text, check_part, kit_line def _lum(h: str) -> float: c = [int(h[i : i + 2], 16) / 255 for i in (1, 3, 5)] c = [v / 12.92 if v <= 0.03928 else ((v + 0.055) / 1.055) ** 2.4 for v in c] return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2] def _ratio(a: str, b: str) -> float: x, y = sorted((_lum(a), _lum(b)), reverse=True) return (x + 0.05) / (y + 0.05) def _tokens(block: str) -> dict[str, str]: return dict(re.findall(r"--(color-[a-z-]+):\s*(#[0-9a-fA-F]{6})\b", block)) def test_위험_채움_흰_글_대비(): theme = _text("ui_template_theme.css") light = _tokens(theme[theme.index(":root {") :].split("\n}\n", 1)[0]) dark = _tokens(theme[theme.index(':root[data-theme="dark"]') :].split("\n}\n", 1)[0]) # 채운 바탕 위 글 = canvas(밝음 흰 · 어두움 짙은 바탕) assert _ratio(light["color-danger-fill"], light["color-canvas"]) >= 4.5 assert _ratio(dark["color-danger-fill"], dark["color-canvas"]) >= 4.5 assert _ratio(light["color-danger"], light["color-canvas"]) >= 4.5 # 위험 단추 · 글 assert _ratio(dark["color-danger"], dark["color-canvas"]) >= 4.5 assert light["color-danger"] == "#c0392b" # 위험 글 색 그대로 def test_계산_줄(): check_part( "calc-row", "ui_template_calc_row.ts", ["ui_template_calc_row.css"], ["createCalcRow", "createCalcFormulaRow", "createCalcFormula"], [ "ui-calc-row", "ui-calc-row--formula", "ui-calc-row__label", "ui-calc-row__out", "ui-calc-row__in", ], ) sheet = (ROOT / "B08_Quantity" / "B08_Quantity_UI_Hydro_Sheet.ts").read_text(encoding="utf-8") css = (ROOT / "B08_Quantity" / "B08_Quantity_UI_Hydro.css").read_text(encoding="utf-8") for old in ( "b08-hydro__row", "b08-hydro__label", "b08-hydro__formula", "b08-hydro__out", "b08-hydro__in", ): assert old not in sheet and old not in css, old def test_칸_램프(): css = _text("ui_template_data_table.css") assert "td.ui-data-table__lamp::before" in css and "var(--color-warning)" in css assert re.search(r"td\.ui-data-table__lamp\.is-linked::before\s*\{[^}]*content: \"✓\"", css) assert "td.ui-data-table__lamp--only" in css assert "칸 램프" in kit_line("table") and "kitLampTable()" in kit_line("table") for page, old in ( ("B08_Quantity/B08_Quantity_UI_Page.css", "b08-summary__lamp"), ("B08_Quantity/B08_Quantity_UI_Milestone.css", "b08-milestone__lamp"), ("B09_Estimation/B09_Estimation_UI_Page.css", "b09-bill__lamp"), ): assert old not in (ROOT / page).read_text(encoding="utf-8"), page def test_넓은_중간_창(): css = _text("ui_template_modal.css") assert re.search( r'\.ui-modal\.ui-modal--wide\[data-width="1100px"\]\s*\{[^}]*min\(1100px, 94vw\)', css ) assert '"1100px"' in _text("ui_template_modal.ts") and "1100" in kit_line("modal") haul = (ROOT / "B09_Estimation" / "B09_Estimation_UI_Haul_Modal.ts").read_text(encoding="utf-8") assert 'width: "1100px"' in haul and "--modal-max:min(680px" not in haul def test_값_목록_규칙_꼴(): assert "ui-kv--rule" in _text("ui_template_kv.css") and "rule: true" in kit_line("kv") app = (ROOT / "A00_Common" / "app_settings.ts").read_text(encoding="utf-8") assert "createKv(rows, { rule: true })" in app assert "app-settings__rules" not in (ROOT / "A00_Common" / "app_settings.css").read_text( encoding="utf-8" ) def test_구역_머리(): ts = _text("ui_template_collapsible.ts") assert "export function createCollapsibleHead" in ts and "kitSection()" in kit_line( "collapsible" ) link = (ROOT / "B08_Quantity" / "B08_Quantity_UI_Link.ts").read_text(encoding="utf-8") assert "createCollapsibleHead(" in link and "b08-sheets__title" not in link def test_입력_칸_2열_안_빌림(): css = _text("ui_template_general_layout.css") assert ( ".ui-form-grid" in css and ".ui-general-layout--narrow" in css and ".ui-general-block__actions--end" in css ) for page in ( "D01_PlanRegister/D01_PlanRegister_UI_Page.ts", "E01_StabRegister/E01_StabRegister_UI_Page.ts", ): src = (ROOT / page).read_text(encoding="utf-8") assert ( "b02-proj" not in src and "B02_ProjRegister_UI_Style" not in src and "createFormGrid(" in src ), page for scene in ("D01", "E01"): assert "b02-proj" not in ( ROOT / "A05_EduDetail" / "guide" / scene / "_scenes.json" ).read_text(encoding="utf-8")