Files
Pulse/scripts/tests/test_relay_and_map_docs.py
pulse-triage[bot] bd26eb6549 Align Pro runtime switching, License/Relay API, and Map inspector docs
- Align docs/PULSE_PRO.md (and its frontend-modern/public/docs/ mirror)
  with the shipped in-app Switch this install to Pulse Pro and Switch
  this container to Pulse Pro cards (GET /api/updates/pro-runtime,
  POST /api/updates/pro-runtime/apply), typed refusal reasons, and
  GET /api/license/runtime-capabilities (capabilities vs
  blocked_capabilities on Community builds).
- Document GET /api/license/runtime-capabilities,
  GET /api/license/entitlements, and GET /api/license/commercial-posture
  in docs/API.md (and its mirror) to match
  internal/api/router_routes_licensing.go.
- Align docs/RELAY.md (and its mirror) API Reference with all six routes
  and admin/authenticated plus relay-entitlement gates in
  internal/api/router_routes_ai_relay.go.
- Align the held docs/MAP.md guide (and its mirror, remaining unlinked
  while Map is in Build stage) with #5415's zero-shift bottom inspector
  bar, priority-ordered anomalies, and preserved touch tap cards.
- Add source-bound documentation verification tests in
  scripts/tests/test_license_recovery_docs.py and
  scripts/tests/test_relay_and_map_docs.py.

Contract-Neutral: Documentation and documentation-only tests aligned to existing shipped runtime contracts with no behavioral or subsystem contract change.
Change-source: pulse-maintainer
2026-11-28 23:11:35 +00:00

61 lines
2.5 KiB
Python

#!/usr/bin/env python3
"""Verify Relay API reference and held Map inspector documentation against live source."""
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[2]
class RelayAndMapDocsTest(unittest.TestCase):
def test_shipped_mirrors_match_repo_docs(self) -> None:
for name in ("RELAY.md", "MAP.md"):
with self.subTest(doc=name):
self.assertEqual(
(ROOT / "docs" / name).read_bytes(),
(ROOT / "frontend-modern/public/docs" / name).read_bytes(),
)
def test_relay_api_reference_matches_router_routes(self) -> None:
relay_doc = (ROOT / "docs/RELAY.md").read_text(encoding="utf-8")
router = (ROOT / "internal/api/router_routes_ai_relay.go").read_text(encoding="utf-8")
routes = (
("GET", "/api/settings/relay"),
("PUT", "/api/settings/relay"),
("GET", "/api/settings/relay/status"),
("GET", "/api/onboarding/qr"),
("POST", "/api/onboarding/validate"),
("GET", "/api/onboarding/deep-link"),
)
for method, path in routes:
with self.subTest(route=f"{method} {path}"):
self.assertIn(f'"{method} {path}"', router)
self.assertIn(f"| `{method}` | `{path}` |", relay_doc)
self.assertIn("`relay` licence entitlement", relay_doc)
self.assertIn("`/api/settings/relay*` routes require administrator access", relay_doc)
def test_map_doc_describes_bottom_inspector_bar_and_stays_unlinked_while_in_build(self) -> None:
map_doc = (ROOT / "docs/MAP.md").read_text(encoding="utf-8")
surface = (
ROOT / "frontend-modern/src/features/infrastructureMap/InfrastructureMapSurface.tsx"
).read_text(encoding="utf-8")
docs_readme = (ROOT / "docs/README.md").read_text(encoding="utf-8")
self.assertIn("data-testid=\"infrastructure-map-inspector\"", surface)
self.assertIn("data-map-inspector-anomaly=", surface)
self.assertIn("bottom inspector bar", map_doc)
self.assertIn("touch card", map_doc)
self.assertNotIn("hover tooltips", map_doc.lower())
self.assertNotIn("tile tooltips", map_doc.lower())
self.assertNotIn("host tooltips", map_doc.lower())
self.assertNotIn("guest tooltips", map_doc.lower())
self.assertNotIn("check tooltips", map_doc.lower())
self.assertNotIn("MAP.md", docs_readme)
if __name__ == "__main__":
unittest.main()