"""779-3 지킴 — 공용 격자 「칠」 옵션(요구 621-5): 안 주면 data-tone 없음 · 주면 보이는 칸만 · 색은 --color-* 만. 화면 수치 판정은 tmp 의 playwright 일회 검증 · 여기서는 길이 빠지지 않았는지만 지킴.""" import re from pathlib import Path SS = Path(__file__).parents[2] / "A00_Common/spreadsheet" def read(name: str) -> str: return (SS / name).read_text(encoding="utf-8") def test_fill_option_flows_option_to_ctx_to_cell(): assert "칠?:" in read("spreadsheet.ts") and "fill: opts.칠" in read("spreadsheet.ts") assert "fill?:" in read("spreadsheet_view_types.ts") def test_tone_set_only_in_visible_cell_loop_and_cleared_when_absent(): cells = read("spreadsheet_grid_cells.ts") assert cells.count("ctx.fill?.(") == 1 # 칸 그리는 반복(보이는 칸) 안 한 곳뿐 assert "cellEl.dataset.tone = tone" in cells assert "delete cellEl.dataset.tone" in cells # 재사용 div — 안 주면 data-tone 없음 def test_repaint_handle_only_rerenders_grid(): assert re.search(r"repaint:\s*\(\)\s*=>\s*grid\.render\(\)", read("spreadsheet.ts")) def test_css_tones_use_color_tokens_only_and_readonly_hides_add(): css = read("spreadsheet_grid.css") tone = css[css.index('[data-tone~="success"]') :] for name in ("success", "warning", "info", "danger"): assert f"var(--color-{name}) 18%" in tone assert "--draw-" not in tone assert "var(--color-text-muted)" in tone and "var(--color-accent)" in tone assert ".ss--readonly .ss-tabs__add" in css