"""Mobile-first quality tests — automated validation of mobile UX requirements. These tests verify the HTML, CSS, and HTMX attributes that make the dashboard work correctly on phones. No browser / Playwright required: we parse the static assets and server responses directly. Categories: M1xx Viewport & meta tags M2xx Touch target sizing M3xx iOS keyboard & zoom prevention M4xx HTMX robustness (double-submit, sync) M5xx Safe-area / notch support """ import re from pathlib import Path # ── helpers ─────────────────────────────────────────────────────────────────── def _css() -> str: """Read the main stylesheet.""" css_path = Path(__file__).parent.parent.parent / "static" / "style.css" return css_path.read_text() def _index_html(client) -> str: return client.get("/").text def _timmy_panel_html(client) -> str: """Fetch the Timmy chat panel (loaded dynamically from index via HTMX).""" return client.get("/agents/default/panel").text # ── M1xx — Viewport & meta tags ─────────────────────────────────────────────── def test_M101_viewport_meta_present(client): """viewport meta tag must exist for correct mobile scaling.""" html = _index_html(client) assert 'name="viewport"' in html def test_M102_viewport_includes_width_device_width(client): html = _index_html(client) assert "width=device-width" in html def test_M103_viewport_includes_initial_scale_1(client): html = _index_html(client) assert "initial-scale=1" in html def test_M104_viewport_includes_viewport_fit_cover(client): """viewport-fit=cover is required for iPhone notch / Dynamic Island support.""" html = _index_html(client) assert "viewport-fit=cover" in html def test_M105_apple_mobile_web_app_capable(client): """Enables full-screen / standalone mode when added to iPhone home screen.""" html = _index_html(client) assert "apple-mobile-web-app-capable" in html def test_M106_theme_color_meta_present(client): """theme-color sets the browser chrome colour on Android Chrome.""" html = _index_html(client) assert 'name="theme-color"' in html def test_M107_apple_status_bar_style_present(client): html = _index_html(client) assert "apple-mobile-web-app-status-bar-style" in html def test_M108_lang_attribute_on_html(client): """lang attribute aids screen readers and mobile TTS.""" html = _index_html(client) assert '