from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def read(path): return (ROOT / path).read_text() def test_release_version(): assert 'version = "0.0.6"' in read("Cargo.toml") assert "# RustBox 0.0.6" in read("README.md") def test_realtime_contract(): ws = read("src/realtime/ws.rs") js = read("src/web/js/80-settings-realtime.js") assert '"type": "heartbeat"' in ws assert "Heartbeat timeout" in js assert "2 ** attempt" in js assert "resyncRealtimeState" in js assert "realtimeSeenEvents" in js assert "realtimePollTimer" in js assert "realtimeRefreshEvents" in js def test_upload_progress_is_not_toast_driven(): compose = read("src/web/js/50-compose.js") block = compose[compose.index("async function uploadComposeFiles"):compose.index("function previewMarkdown")] assert "progressToast(" not in block assert "setComposeUploadProgress" in block assert "AbortController" in block def test_fullscreen_reader_contract(): html = read("src/web/index.html") reader = read("src/web/js/40-messages-reader.js") menu = read("src/web/js/60-mail-actions-search.js") css = read("src/web/css/30-mail.css") assert 'id="reader-fullscreen"' in html assert "Open full screen" in menu assert "message-fullscreen-action" in reader assert "reader-fullscreen" in reader assert "history.pushState" in reader assert "reader-pane.reader-fullscreen" in css assert ".reader-pane.reader-fullscreen .message-body" in css assert "max-width: none" in css def test_mobile_reader_contract(): css = read("src/web/css/30-mail.css") responsive = read("src/web/css/60-responsive.css") bindings = read("src/web/js/95-bindings-boot.js") assert ".toolbar-menu-popover button" in css assert ".attachment-item .attachment-button" in css assert "min-height: 34px" in responsive assert 'bottom: "8px"' not in bindings assert 'rect.bottom + 5' in bindings def test_message_links_can_open_new_tabs_from_sandbox(): reader = read("src/web/js/40-messages-reader.js") assert 'iframe.setAttribute("sandbox", "allow-popups allow-popups-to-escape-sandbox")' in reader def test_extended_color_presets_contract(): html = read("src/web/index.html") css = read("src/web/css/00-tokens.css") backend = read("src/db/display_preferences.rs") presets = ["emerald", "lime", "sky", "navy", "plum", "magenta", "copper", "sand"] for preset in presets: assert f'