from __future__ import annotations import unittest from pathlib import Path PROJECT_ROOT = Path(__file__).resolve().parents[1] STATIC_ROOT = PROJECT_ROOT / "arr_web" / "static" class ChannelBiVisualStaticContractTests(unittest.TestCase): @classmethod def setUpClass(cls) -> None: cls.desktop = (STATIC_ROOT / "index.html").read_text(encoding="utf-8") cls.mobile = (STATIC_ROOT / "h5.html").read_text(encoding="utf-8") cls.desktop_script = (STATIC_ROOT / "app.js").read_text(encoding="utf-8") cls.mobile_script = (STATIC_ROOT / "h5.js").read_text(encoding="utf-8") cls.i18n = (STATIC_ROOT / "i18n.js").read_text(encoding="utf-8") cls.desktop_styles = (STATIC_ROOT / "styles.css").read_text(encoding="utf-8") cls.mobile_styles = (STATIC_ROOT / "h5.css").read_text(encoding="utf-8") def test_bi_removes_old_labels_and_places_data_range_under_sales_title(self) -> None: for content in (self.desktop, self.mobile): self.assertNotIn("CHANNEL PERFORMANCE", content) self.assertNotIn("数据库月报快照", content) self.assertNotIn("TOTAL PRICE", content) self.assertNotIn("CHANNEL PERFORMANCE", self.i18n) self.assertNotIn("数据库月报快照", self.i18n) self.assertNotIn("TOTAL PRICE", self.i18n) self.assertNotIn('"bi.updated"', self.i18n) self.assertNotIn("bi-subtitle", self.desktop) self.assertNotIn("h5-updated", self.mobile) self.assertIn('
数据范围:—
', self.desktop) self.assertIn('数据范围:—
', self.mobile) self.assertIn('"bi.data_range"', self.i18n) def test_bi_surface_keeps_only_a_compact_month_control(self) -> None: desktop_start = self.desktop.index('id="panel-bi"') desktop_end = self.desktop.index('id="panel-usage"', desktop_start) desktop_bi = self.desktop[desktop_start:desktop_end] mobile_start = self.mobile.index('