fix: restore KaTeX assets and deployment checks
CI / test (pull_request) Canceled after 7s
PR合并自动部署 / release-check (pull_request) Successful in 1m40s
PR合并自动部署 / deploy (pull_request) Successful in 14s

This commit is contained in:
2026-08-09 03:47:17 +08:00
parent feb8845ec7
commit 3e47ba787d
68 changed files with 121 additions and 11 deletions
+38
View File
@@ -1,6 +1,9 @@
import re
from pathlib import Path
from django.conf import settings
from django.core.management import call_command
from django.test import override_settings
STATIC_ROOT = Path(settings.BASE_DIR) / "static"
@@ -71,6 +74,41 @@ def test_toolbox_and_games_资源入口与移动端触控样式存在():
assert "@media (max-width: 700px)" in styles
def test_latex_默认源码可渲染且_katex_静态资源完整():
template = (settings.BASE_DIR / "templates" / "index.html").read_text(encoding="utf-8")
app = (STATIC_ROOT / "js" / "app.js").read_text(encoding="utf-8")
katex_root = STATIC_ROOT / "vendor" / "katex"
katex_css = (katex_root / "katex.min.css").read_text(encoding="utf-8")
font_paths = set(re.findall(r"url\(fonts/([^)]+)\)", katex_css))
assert (
'<textarea id="latex-source" spellcheck="false">'
r"\int_{0}^{1} x^2\,dx = \frac{1}{3}</textarea>"
) in template
assert r"\\int_{0}^{1}" not in template
assert "function normalizeLatexSource(source)" in app
assert "globalThis.katex.render(normalized, target" in app
assert "throwOnError: true" in app
assert len(font_paths) == 60
assert all((katex_root / "fonts" / path).is_file() for path in font_paths)
assert (katex_root / "LICENSE.txt").is_file()
def test_production_manifest_可处理全部静态资源(tmp_path):
storage = "whitenoise.storage.CompressedManifestStaticFilesStorage"
with override_settings(
STATIC_ROOT=tmp_path,
STORAGES={
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
"staticfiles": {"BACKEND": storage},
},
):
call_command("collectstatic", interactive=False, clear=True, verbosity=0)
assert (tmp_path / "staticfiles.json").is_file()
assert (tmp_path / "vendor" / "katex" / "katex.min.css").is_file()
def test_realtime_match_联机码与_websocket_前端资源存在():
template = (settings.BASE_DIR / "templates" / "index.html").read_text(encoding="utf-8")
realtime = (STATIC_ROOT / "js" / "realtime.js").read_text(encoding="utf-8")