8OI-532 regression — ``assets/index.html`` must render without reaching
9out to ``fonts.googleapis.com`` or ``fonts.gstatic.com``. Web fonts are
10self-hosted under ``assets/fonts/`` and referenced via inline
11``@font-face`` declarations.
15- No ``fonts.googleapis.com`` / ``fonts.gstatic.com`` hosts appear.
16- Every ``@font-face`` ``src: url(...)`` points at a relative path
17 rooted in ``fonts/``, and the target ``.woff2`` file exists on disk.
24 L3 — assertion details
29- Tests read ``assets/index.html`` from the repository root; no temp
31- All assertions are read-only checks against existing project assets.
34from __future__
import annotations
37from pathlib
import Path
40REPO_ROOT = Path(__file__).resolve().parents[3]
41INDEX_HTML = REPO_ROOT /
"assets" /
"index.html"
42FONTS_DIR = REPO_ROOT /
"assets" /
"fonts"
46 return INDEX_HTML.read_text(encoding=
"utf-8")
51 assert "fonts.googleapis.com" not in text, (
52 "assets/index.html must not reference fonts.googleapis.com "
53 "(OI-532: fonts are self-hosted under assets/fonts/)"
55 assert "fonts.gstatic.com" not in text, (
56 "assets/index.html must not reference fonts.gstatic.com "
57 "(OI-532: fonts are self-hosted under assets/fonts/)"
63 srcs = re.findall(
r"src:\s*url\(['\"]?([^'\")]+)['\"]?\)", text)
64 assert srcs,
"expected at least one @font-face src: url(...) declaration"
66 assert src.startswith(
"fonts/"), (
67 f
"@font-face src {src!r} must be rooted in fonts/ (relative)"
69 assert src.endswith(
".woff2"), (
70 f
"@font-face src {src!r} must be a .woff2 file"
72 target = FONTS_DIR / Path(src).name
73 assert target.is_file(), f
"missing vendored font file: {target}"
test_no_external_font_hosts_in_index_html()
test_every_font_face_src_points_at_local_woff2()