"""T#30 — guard the new dashboard pages against emoji creep. Design pillar (`dashboard/DESIGN.md`): the unified Echo dashboard uses Lucide icons exclusively, no emojis in the chrome. This test asserts that no emoji codepoints sneak into the static HTML files we ship. """ from __future__ import annotations import re from pathlib import Path import pytest # Symbols + emoticons + transport + miscellaneous + dingbats. Covers the # common emoji blocks; not exhaustive but matches what the spec asked for. EMOJI_RE = re.compile( r'[\U0001F300-\U0001F9FF\U0001FA00-\U0001FAFF☀-➿]' ) DASHBOARD_DIR = Path(__file__).resolve().parent.parent / "dashboard" # Pages that the unified-dashboard initiative declares emoji-free. # index.html is excluded for now: it's the legacy unified panel page that # predates DESIGN.md and still contains historical emoji (👤👷🤖🔴…). It # will be migrated separately; that cleanup gets its own follow-up. _UNIFIED_PAGES = ["workspace.html", "login.html"] def _emoji_files(): """Only run the test for pages that exist on disk. workspace.html may not be in place during partial rollouts; skip silently so the suite doesn't hard-fail during the unified-dashboard migration. """ return [name for name in _UNIFIED_PAGES if (DASHBOARD_DIR / name).is_file()] @pytest.mark.parametrize("html_file", _emoji_files() or ["__skip__"]) def test_no_emoji_in_dashboard_html(html_file): if html_file == "__skip__": pytest.skip("no unified dashboard pages are present yet") content = (DASHBOARD_DIR / html_file).read_text(encoding="utf-8") found = EMOJI_RE.findall(content) assert not found, f"Emoji found in {html_file}: {found}"