99 lines
4.1 KiB
Python
99 lines
4.1 KiB
Python
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.1.0"' in read("Cargo.toml")
|
|
assert "# RustBox 0.1.0" 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 allow-downloads")' 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'<option value="{preset}">' in html
|
|
assert f'html[data-color-preset="{preset}"]' in css
|
|
assert f'"{preset}"' in backend
|
|
|
|
|
|
def test_all_predefined_interface_styles_are_visible_and_wired():
|
|
import re
|
|
html = read("src/web/index.html")
|
|
js = read("src/web/js/20-preferences-auth.js")
|
|
css = read("src/web/css/55-roundcube-skins.css") + read("src/web/css/56-interface-styles.css")
|
|
backend = read("src/db/display_preferences.rs")
|
|
config = read("src/config.rs")
|
|
select = re.search(r'<select id="pref-interface-skin">(.*?)</select>', html, re.S).group(1)
|
|
visible = set(re.findall(r'<option value="([^"]+)">', select))
|
|
expected = {
|
|
"default", "rustbox", "roundcube-classic", "roundcube-larry", "roundcube-elastic",
|
|
"clean", "gmail", "proton", "zoho", "outlook", "minimal", "graphite",
|
|
"high-contrast", "fastmail", "apple-mail", "yahoo", "hey", "nord",
|
|
"github", "gitlab", "discord", "slack", "reddit", "notion",
|
|
}
|
|
assert visible == expected
|
|
for skin in expected - {"default", "rustbox"}:
|
|
assert f'data-interface-skin="{skin}"' in css
|
|
assert re.search(rf'(?:\"{re.escape(skin)}\"|\b{re.escape(skin)})\s*:', js)
|
|
assert f'"{skin}"' in backend
|
|
for skin in expected - {"default"}:
|
|
assert f'"{skin}"' in config
|
|
|
|
|
|
def test_new_website_inspired_styles_have_light_and_dark_palettes():
|
|
css = read("src/web/css/56-interface-styles.css")
|
|
for skin in ["github", "gitlab", "discord", "slack", "reddit", "notion"]:
|
|
assert f'html[data-interface-skin="{skin}"][data-theme="light"]' in css
|
|
assert f'html[data-interface-skin="{skin}"][data-theme="dark"]' in css
|