abuse: теги accs + продажа подписок, строже порог; panels: реальные free-имена и 130/175 с бесплатными
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""Local UI dependencies are served without exposing project data."""
|
||||
import http.client
|
||||
import pathlib
|
||||
import re
|
||||
import threading
|
||||
from http.server import ThreadingHTTPServer
|
||||
|
||||
@@ -75,3 +77,47 @@ def test_index_still_served(static_server):
|
||||
status, headers, body = static_server("/")
|
||||
assert status == 200 and body == b"<html>panel</html>"
|
||||
assert headers["Content-Type"].startswith("text/html")
|
||||
|
||||
|
||||
WEB_ROOT = pathlib.Path(__file__).resolve().parents[1] / "web"
|
||||
|
||||
|
||||
def test_panel_html_is_self_contained_black():
|
||||
html = (WEB_ROOT / "index.html").read_text(encoding="utf-8")
|
||||
# Black theme is declared three ways so first paint cannot flash white.
|
||||
assert 'data-bs-theme="dark"' in html
|
||||
assert "color-scheme: dark" in html
|
||||
assert "--omni-background: #09090b" in html
|
||||
# No remote dependencies: every src/href must stay inside /assets/ or be a data URL.
|
||||
for attr in re.findall(r'(?:src|href)="([^"]+)"', html):
|
||||
assert not attr.startswith(("http://", "https://", "//")), attr
|
||||
assert "/assets/vendor/tabler/tabler.min.css" in html
|
||||
assert "/assets/vendor/tabler/tabler.min.js" in html
|
||||
|
||||
|
||||
def test_panel_self_hosts_inter_for_latin_and_cyrillic():
|
||||
html = (WEB_ROOT / "index.html").read_text(encoding="utf-8")
|
||||
assert html.count('font-family: "Inter Variable"') == 4
|
||||
assert 'format("woff2-variations")' not in html # rejected by Firefox/Safari
|
||||
assert html.count('format("woff2")') == 4
|
||||
assert html.count("font-display: swap") == 4
|
||||
assert "--tblr-font-sans-serif: \"Inter Variable\"" in html
|
||||
files = WEB_ROOT / "vendor" / "inter" / "files"
|
||||
for subset in ("latin", "latin-ext", "cyrillic", "cyrillic-ext"):
|
||||
face = files / f"inter-{subset}-wght-normal.woff2"
|
||||
assert face.is_file() and face.stat().st_size > 2000, face
|
||||
assert f"/assets/vendor/inter/files/{face.name}" in html
|
||||
licence = (WEB_ROOT / "vendor" / "inter" / "LICENSE").read_text(encoding="utf-8")
|
||||
assert "SIL OPEN FONT LICENSE" in licence.upper()
|
||||
|
||||
|
||||
def test_panel_typography_does_not_clip_cyrillic():
|
||||
html = (WEB_ROOT / "index.html").read_text(encoding="utf-8")
|
||||
badge = re.search(r"\.badge \{[^}]*\}", html)
|
||||
assert badge and "line-height: 1.4" in badge.group(0)
|
||||
assert "letter-spacing: -.01em" not in html # negative tracking on Cyrillic titles
|
||||
for selector in (".brand-caption", ".feed-title", ".feed-preview"):
|
||||
rule = re.search(r"(?m)^" + re.escape(selector) + r" \{[^}]*\}", html)
|
||||
assert rule, selector
|
||||
line_height = re.search(r"line-height: ([\d.]+)", rule.group(0))
|
||||
assert line_height and float(line_height.group(1)) >= 1.4, rule.group(0)
|
||||
|
||||
Reference in New Issue
Block a user