mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-30 01:32:00 +01:00
Clarify in docs/RELAY.md (and its frontend-modern/public/docs/ mirror) that all six Relay and mobile onboarding routes require administrator access for browser sessions (via RequireAdmin or ensureSettingsReadScope in internal/api/router_routes_ai_relay.go), while API tokens require an instance-wide settings:read or settings:write token on /api/settings/relay* and accept either relay:mobile:access or settings:read on /api/onboarding/*. Update scripts/tests/test_relay_and_map_docs.py to verify this contract and assert Map stays unlinked before release while featureReleases.json is not at stage released. Contract-Neutral: Documentation accuracy correction and docs-only test update aligned to existing shipped router and scope contracts with no runtime behavior change. Change-source: pulse-maintainer
70 lines
3.0 KiB
Python
70 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify Relay API reference and Preview Map inspector documentation against live source."""
|
|
|
|
import json
|
|
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")
|
|
scopes = (ROOT / "pkg/auth/scopes.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('ScopeRelayMobileAccess = "relay:mobile:access"', scopes)
|
|
self.assertIn("ensureSettingsReadScope(r.config, w, req)", router)
|
|
self.assertIn("`relay` licence entitlement", relay_doc)
|
|
self.assertIn("administrator access for browser sessions", relay_doc)
|
|
self.assertIn("`relay:mobile:access` or `settings:read`", relay_doc)
|
|
|
|
def test_map_doc_describes_bottom_inspector_bar_and_stays_unlinked_before_release(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")
|
|
releases = json.loads(
|
|
(ROOT / "frontend-modern/src/utils/featureReleases.json").read_text(encoding="utf-8")
|
|
)
|
|
|
|
self.assertNotEqual(releases["infrastructureMap"]["stage"], "released")
|
|
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()
|