refactor: streamline frontend language and shared UI utilities
This commit is contained in:
@@ -23,6 +23,7 @@ class FrontendContractTests(unittest.TestCase):
|
||||
def setUpClass(cls) -> None:
|
||||
cls.html = (STATIC_DIR / "index.html").read_text(encoding="utf-8")
|
||||
cls.script = (STATIC_DIR / "app.js").read_text(encoding="utf-8")
|
||||
cls.ui_core = (STATIC_DIR / "ui-core.js").read_text(encoding="utf-8")
|
||||
collector = IdCollector()
|
||||
collector.feed(cls.html)
|
||||
cls.ids = collector.ids
|
||||
@@ -49,6 +50,28 @@ class FrontendContractTests(unittest.TestCase):
|
||||
self.assertIn('document.querySelector("#sectorPhaseManager").hidden = !isAdmin;', self.script)
|
||||
self.assertIn('const canManage = state.user?.role === "admin";', self.script)
|
||||
|
||||
def test_shared_ui_core_loads_before_application(self):
|
||||
self.assertLess(
|
||||
self.html.index('<script src="/ui-core.js"'),
|
||||
self.html.index('<script src="/app.js"'),
|
||||
)
|
||||
for function_name in (
|
||||
"number", "clamp", "escapeHtml", "formatNumber", "formatTimestamp",
|
||||
"displayCompactDate", "todayString", "localDateString", "parseLocalDate",
|
||||
):
|
||||
self.assertIn(f"function {function_name}(", self.ui_core)
|
||||
|
||||
def test_business_views_do_not_expose_engineering_source_labels(self):
|
||||
prohibited = (
|
||||
"Tushare 实时行情",
|
||||
"Tushare 日K",
|
||||
"SQLite 缓存",
|
||||
"演示日K",
|
||||
"rt_k 实时截面",
|
||||
)
|
||||
for label in prohibited:
|
||||
self.assertNotIn(label, self.script)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user