import pathlib import re REPO = pathlib.Path(__file__).parent.parent INDEX = (REPO / "static" / "index.html").read_text(encoding="utf-8") PANELS = (REPO / "static" / "panels.js").read_text(encoding="utf-8") CSS = (REPO / "static" / "style.css").read_text(encoding="utf-8") I18N = (REPO / "static" / "i18n.js").read_text(encoding="utf-8") def _function_body(src: str, name: str) -> str: match = re.search(rf"function\s+{re.escape(name)}\s*\(", src) assert match, f"{name}() not found" brace = src.find("{", match.end()) assert brace != -1, f"{name}() has no body" depth = 1 i = brace + 1 in_string = None escaped = False in_line_comment = False in_block_comment = False while i < len(src) and depth: ch = src[i] nxt = src[i + 1] if i + 1 < len(src) else "" if in_line_comment: if ch == "\n": in_line_comment = False i += 1 continue if in_block_comment: if ch == "*" and nxt == "/": in_block_comment = False i += 2 continue i += 1 continue if in_string: if escaped: escaped = False elif ch == "\\": escaped = True elif ch == in_string: in_string = None i += 1 continue if ch == "/" and nxt == "/": in_line_comment = True i += 2 continue if ch == "/" and nxt == "*": in_block_comment = True i += 2 continue if ch in "'\"`": in_string = ch i += 1 continue if ch == "{": depth += 1 elif ch == "}": depth -= 1 i += 1 assert depth == 0, f"{name}() body did not close" return src[brace + 1:i - 1] def test_logs_tab_is_wired_between_insights_and_settings_in_rail_and_mobile_nav(): rail = INDEX[INDEX.index('data-panel="insights"'):INDEX.index('