Files
Pulse/scripts/tests/test_watchdog_help_docs.py
pulse-triage[bot] b3e6984460 Align watchdog, Mail Gateway, and PBS Help with stale-reading UI
Document the landed stale-reading and unread-capacity indicators across
three shipped in-app Help guides and bind each guide to its live TSX
component with Python regression tests:

- docs/AVAILABILITY.md (+ public mirror): explain External watchdog
  status badges from AlertDeadManDestinationSection.tsx (#5149, #5171),
  including Heartbeat healthy vs No recent heartbeat, Status read
  overdue (60s), Status unavailable, Delivery failing, Monitoring
  stalled, and Last interruption (clean restart vs unexpected stop).
- docs/MAIL_GATEWAY.md (+ public mirror): explain Readings stale in
  ProxmoxMailGatewayTable.tsx and ProxmoxMailGatewayDrawer.tsx (#5176),
  including Degraded filter movement, retained counts, drawer notice,
  and offline/alert severity precedence.
- docs/PBS.md (+ public mirror): explain PBS data stale and unread
  datastore capacity (Unavailable/Unknown) in
  ProxmoxBackupServersTable.tsx (#5162), including retained capacity,
  Last reading/Last forecast qualifiers, and suppressed fill forecasts.

Contract-Neutral: Documentation and Python doc-regression test alignment for already-landed frontend status presentations; no runtime, API, schema, or subsystem contract changes.
Change-source: pulse-maintainer
2026-11-26 19:23:43 +00:00

73 lines
2.5 KiB
Python

#!/usr/bin/env python3
"""Keep External watchdog Help aligned with AlertDeadManDestinationSection.tsx.
Static source/document checks only: no watchdog URL, network request, or live
alert operation is performed.
"""
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[2]
DOC = ROOT / "docs/AVAILABILITY.md"
MIRROR = ROOT / "frontend-modern/public/docs/AVAILABILITY.md"
COMPONENT = ROOT / "frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx"
def plain(text: str) -> str:
return " ".join(text.replace("**", "").replace("`", "").split())
class WatchdogHelpDocsTest(unittest.TestCase):
def setUp(self) -> None:
self.doc = DOC.read_text(encoding="utf-8")
self.guide = plain(self.doc)
self.component = COMPONENT.read_text(encoding="utf-8")
def test_shipped_guide_matches(self) -> None:
self.assertEqual(DOC.read_bytes(), MIRROR.read_bytes())
def test_watchdog_status_badges_match_runtime_presentation(self) -> None:
for label in (
"Heartbeat healthy",
"No recent heartbeat",
"Status read overdue",
"Status unavailable",
"Delivery failing",
"Monitoring stalled",
"Starting",
"Not configured",
"Configuration invalid",
"Configuration unavailable",
):
with self.subTest(label=label):
self.assertIn(f"'{label}'", self.component)
self.assertIn(label, self.guide)
def test_watchdog_polling_and_interruption_details_match_component(self) -> None:
self.assertIn("DEAD_MAN_STATUS_POLL_MS = 30_000", self.component)
self.assertIn("DEAD_MAN_STATUS_READ_OVERDUE_MS = 2 * DEAD_MAN_STATUS_POLL_MS", self.component)
self.assertIn("recommendedGraceSeconds", self.component)
self.assertIn("Last interruption", self.component)
self.assertIn("clean restart", self.component)
self.assertIn("unexpected stop", self.component)
for phrase in (
"Alerts → Notifications → External watchdog",
"3-minute grace period",
"A live status read does not mean a heartbeat was sent",
"two 30-second poll intervals (60 seconds)",
"Use Refresh to retry",
"last known snapshot",
"Last interruption",
"clean restart",
"unexpected stop",
):
with self.subTest(phrase=phrase):
self.assertIn(phrase, self.guide)
if __name__ == "__main__":
unittest.main()