"""The shipped Remotion runtime assets and the player page.""" from __future__ import annotations import json from pathlib import Path from deeptutor.agents.video_lesson.runtime import ASSETS_DIR, KIT_FILES, prepare_workdir, write_page def test_shipped_runtime_assets_exist() -> None: for name in ( *KIT_FILES, "build.mjs", "render-platform.ts", "package.json", "package-lock.json", ): assert (ASSETS_DIR / name).is_file(), name deps = json.loads((ASSETS_DIR / "package.json").read_text(encoding="utf-8"))["dependencies"] # Pinned exactly: a lesson that compiled once must compile the same way later. assert all(v[0].isdigit() for v in deps.values()) def test_prepare_workdir_copies_the_kit(tmp_path: Path) -> None: lesson = prepare_workdir(tmp_path / "source", "export const x = 1;") assert lesson.read_text(encoding="utf-8") == "export const x = 1;" for name in KIT_FILES: assert (tmp_path / "source" / name).is_file() def test_write_page_inlines_the_bundle_safely(tmp_path: Path) -> None: bundle = tmp_path / "player.js" bundle.write_text('console.log("x");', encoding="utf-8") page = write_page(bundle, tmp_path / "out" / "lesson.html", title="a < b", language="zh") html = page.read_text(encoding="utf-8") assert html.count("") == 1 assert "<\/script>x" in html assert "