from pathlib import Path import unittest ROOT = Path(__file__).resolve().parent class UiAssetsTests(unittest.TestCase): def test_static_ui_assets_define_dashboard_structure(self): index = (ROOT / "ui" / "index.html").read_text(encoding="utf-8") styles = (ROOT / "ui" / "styles.css").read_text(encoding="utf-8") app = (ROOT / "ui" / "app.js").read_text(encoding="utf-8") for required in ("SSO 快捷注册", "SSO 注册参数", "CPA 地址", "CPA 管理密钥", "代理地址(留空 = 直连)"): self.assertIn(required, index) for removed in ( "配置中心", "账号注册", "API 配置", "代理配置", "邮件助手 URL", "邮箱轮询", "使用 1 个月免费 promo", "PayPal", "接码 API URL", "长链", "API Token", "CORS Allow-Origin", ): self.assertNotIn(removed, index) self.assertNotIn("CPA 账号池维护", index) self.assertNotIn("ChatGPT Plus 全自动注册 + CPA 账号池维护", index) self.assertNotIn('id="go"', index) self.assertNotIn('id="poolStatus"', index) self.assertNotIn("pool_maintainer", app) self.assertNotIn("startFullRun", app) self.assertNotIn("'/api/start'", app) self.assertNotIn("const FIELDS", app) self.assertNotIn("function saveConfig", app) self.assertNotIn("function activateConfigTab", app) self.assertIn('id="logDock"', index) self.assertIn('id="copyLog"', index) self.assertIn("function showErrorPopover", app) self.assertIn("async function copyTextToClipboard", app) self.assertIn("navigator.clipboard.writeText", app) self.assertIn("document.execCommand('copy')", app) self.assertIn(".app-shell", styles) self.assertIn(".log-dock", styles) self.assertIn(".error-popover", styles) def test_account_library_uses_readable_card_list(self): index = (ROOT / "ui" / "index.html").read_text(encoding="utf-8") styles = (ROOT / "ui" / "styles.css").read_text(encoding="utf-8") app = (ROOT / "ui" / "app.js").read_text(encoding="utf-8") self.assertIn('id="accountList"', index) self.assertNotIn('id="dbTable"', index) self.assertIn("function renderAccountCard", app) self.assertIn(".account-list", styles) self.assertIn(".account-card", styles) def test_server_serves_static_ui_instead_of_inline_index(self): server_py = (ROOT / "server.py").read_text(encoding="utf-8") self.assertIn("UI_DIR", server_py) self.assertIn("_send_static_file", server_py) self.assertNotIn("INDEX_HTML = r", server_py) self.assertNotIn("INDEX_HTML.encode", server_py) if __name__ == "__main__": unittest.main()