from __future__ import annotations import unittest from pathlib import Path from database import ReviewDatabase from tests.frontend_test_helpers import registered_frontend_runtime_scripts APP_ROOT = Path(__file__).resolve().parents[1] FRONTEND_ROOT = APP_ROOT / "frontend" class CleanupContractTests(unittest.TestCase): def test_retired_files_stay_absent(self) -> None: self.assertFalse((APP_ROOT / "demo_data.py").exists()) self.assertFalse((FRONTEND_ROOT / "heaven-loading.js").exists()) def test_only_active_heaven_loading_asset_is_loaded(self) -> None: scripts = registered_frontend_runtime_scripts() self.assertTrue(any(path.startswith("/pages/heaven/loading-v2.js") for path in scripts)) self.assertFalse(any(path.startswith("/heaven-loading.js") for path in scripts)) def test_audited_definition_only_functions_stay_absent(self) -> None: runtime = "\n".join( path.read_text(encoding="utf-8") for path in FRONTEND_ROOT.rglob("*.js") if "vendor" not in path.parts ) for symbol in ( "commonReviewColumns", "outcomeClass", "screenerResultMatchesSelection", "selectRegime", "showHeartRitualCurtain", ): with self.subTest(symbol=symbol): self.assertNotIn(symbol, runtime) def test_wencai_history_compatibility_is_retained(self) -> None: for method in ( "list_wencai_saved_queries", "save_wencai_query", "delete_wencai_saved_query", ): with self.subTest(method=method): self.assertTrue(hasattr(ReviewDatabase, method)) if __name__ == "__main__": unittest.main()