fix: restore KaTeX assets and deployment checks
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user