from pathlib import Path REPO = Path(__file__).resolve().parents[1] def _extract_function(src: str, name: str) -> str: anchor = f"function {name}(" start = src.find(anchor) assert start != -1, f"{name}() must exist" body_start = src.find("{", start) assert body_start != -1, f"{name}() must have a body" depth = 1 idx = body_start + 1 while depth and idx < len(src): if src[idx] == "{": depth += 1 elif src[idx] == "}": depth -= 1 idx += 1 assert depth == 0, f"{name}() body must balance braces" return src[start:idx] def test_shutdown_description_uses_split_i18n_spans_in_index_html(): html = (REPO / "static" / "index.html").read_text(encoding="utf-8") start = html.find('
" not in line
def test_apply_locale_to_dom_stays_on_text_content():
src = (REPO / "static" / "i18n.js").read_text(encoding="utf-8")
apply_locale_body = _extract_function(src, "applyLocaleToDOM")
assert "el.textContent = val;" in apply_locale_body
assert "innerHTML = val" not in apply_locale_body
assert "data-i18n-html" not in src