fix: refresh public dashboard and BI telemetry

This commit is contained in:
Wyndham ARR
2026-08-03 16:08:14 +08:00
parent 2107f00e32
commit 5294edab89
20 changed files with 584 additions and 75 deletions

View File

@@ -371,8 +371,8 @@ class PortalApplicationTests(unittest.TestCase):
self.assertIn(".company-fixed-companies", styles)
self.assertIn(".company-source-action", styles)
self.assertIn(".company-source-current", styles)
self.assertIn(".company-job-source", styles)
self.assertIn(".company-history-source", styles)
self.assertNotIn(".company-job-source", styles)
self.assertNotIn(".company-history-source", styles)
self.assertIn(".company-review-file", styles)
self.assertIn("overflow-wrap: anywhere", styles)
self.assertIn(".company-review-row.is-pending", styles)
@@ -398,6 +398,13 @@ class PortalApplicationTests(unittest.TestCase):
self.assertIn("BOOKING_EXCEL_SOURCE_ALREADY_ACTIVATED", script)
self.assertIn("requestError.code", script)
self.assertIn("state.companyReportConfirmRequest", script)
self.assertIn("company.publish_failed_detail", script)
self.assertIn("company.publish_failed_summary_all", script)
i18n = (STATIC_ROOT / "i18n.js").read_text(encoding="utf-8")
self.assertIn("数据已处理,但正式 Excel 保存失败。请重启报表服务后再生成。", i18n)
self.assertNotIn("重复后跳过", i18n)
self.assertNotIn("重复后跳过", script)
self.assertNotIn("历史任务未记录来源", script)
self.assertNotIn("company-review-guidance", script)
self.assertNotIn("company-review-description", script)
self.assertNotIn("还有 ${formatInteger(pending)} 条待人工记录", script)
@@ -410,12 +417,12 @@ class PortalApplicationTests(unittest.TestCase):
'id="company-source-current-filename"',
'id="company-source-current-meta"',
'id="company-source-status"',
'id="company-report-job-source"',
'id="company-report-job-source-file"',
'id="company-report-job-source-meta"',
"来源 Excel",
):
self.assertIn(required, desktop_text)
self.assertNotIn('id="company-report-job-source"', desktop_text)
self.assertNotIn("本次任务使用的 Excel", desktop_text)
self.assertNotIn("任务使用的 Excel", desktop_text)
self.assertNotIn("历史任务未记录来源", desktop_text)
self.assertIn('String(summary.filename || "").trim()', script)
self.assertIn('$("#company-review-filename").textContent = filename || "未记录文件名"', script)
self.assertLess(

View File

@@ -79,6 +79,22 @@ class ChannelBiVisualStaticContractTests(unittest.TestCase):
self.assertIn(".chart-data-range", self.desktop_styles)
self.assertIn(".card-title .data-range", self.mobile_styles)
def test_bi_uses_five_second_updated_at_refresh_without_reloading_every_poll(self) -> None:
self.assertIn("const BI_POLL_INTERVAL = 5000", self.desktop_script)
self.assertIn("const BI_POLL_INTERVAL = 5000", self.mobile_script)
self.assertIn('api("/api/months")', self.desktop_script)
self.assertIn('api("/api/public/h5/months")', self.mobile_script)
self.assertIn("metadata.updated_at !== current.updated_at", self.desktop_script)
self.assertIn("metadata.updated_at !== lastData.updated_at", self.mobile_script)
self.assertIn("loadAnalytics(false, Boolean(current))", self.desktop_script)
self.assertIn("load(false, Boolean(lastData))", self.mobile_script)
self.assertIn("function checkBiFreshness", self.desktop_script)
self.assertIn("function checkBiFreshness", self.mobile_script)
self.assertIn("clearBiPoll()", self.desktop_script)
self.assertIn("clearBiPoll()", self.mobile_script)
self.assertIn("document.hidden", self.desktop_script)
self.assertIn("document.hidden", self.mobile_script)
if __name__ == "__main__":
unittest.main(verbosity=2)