from __future__ import annotations import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[1] HTML_PATH = ROOT / "data" / "wiki" / "guanghan_topology_demo.html" class GuanghanTopologySourceTests(unittest.TestCase): @classmethod def setUpClass(cls) -> None: cls.html = HTML_PATH.read_text(encoding="utf-8") def test_topology_is_rendered_from_snapshot_layout(self) -> None: self.assertNotIn(' None: self.assertNotIn('', self.html) self.assertIn("decorations.radiator", self.html) self.assertIn("function createRadiator", self.html) def test_future_expansion_anchors_remain_source_comments(self) -> None: for direction in ("north", "east", "west"): self.assertIn( f"FUTURE_EXPANSION_ANCHOR:{direction}", self.html, ) self.assertNotIn("未来北部十字结构", self.html) self.assertNotIn("未来东部十字结构", self.html) self.assertNotIn("未来西部十字结构", self.html) def test_page_uses_same_origin_api(self) -> None: self.assertIn("const API_BASE = ''", self.html) self.assertNotIn("http://localhost:5000", self.html) def test_controls_use_api_navigation_and_safe_text(self) -> None: self.assertIn("/api/v1/bases/guanghan/missions", self.html) self.assertNotIn("return ['BL-01'", self.html) self.assertIn("popstate", self.html) self.assertIn("Asia/Shanghai", self.html) self.assertNotIn(".innerHTML =", self.html) self.assertIn("replaceChildren", self.html) if __name__ == "__main__": unittest.main()