Files
Pulse/scripts/tests/test_localized_public_docs.py
pulse-triage[bot] 9d40b90fdd Align Cloud availability and Pro runtime switch Help docs
Align eight unclaimed shipped Help guides and their mirrored copies under
frontend-modern/public/docs/ with current Pulse runtime behavior:
- Clarify in docs/CLOUD.md that Pulse Cloud is not generally available
  (matching docs/README.md) and remove the unscheduled custom-domain
  future-release promise.
- Document the shipped Switch this install to Pulse Pro (systemd/Proxmox
  LXC) and Switch this container to Pulse Pro (Docker) cards from
  ProLicensePlanSection.tsx across docs/RBAC.md, docs/UPGRADE_v6.md,
  docs/PRODUCTION_SECURITY.md, and docs/i18n/{de,es,fr}/README.md while
  preserving manual pulserelay.pro/download.html guidance.
- Align SECURITY.md's token management breadcrumb to
  Settings -> Security -> API Access.
- Add source-bound regression tests in scripts/tests/test_cloud_migration_docs.py,
  scripts/tests/test_localized_public_docs.py, and
  scripts/tests/test_upgrade_v6_docs.py.

Contract-Neutral: Aligns shipped Help documentation and doc-verification tests with already-shipped Pro runtime switch UI, Cloud availability posture, and Security navigation without modifying runtime or API contracts.
Change-source: pulse-maintainer
2026-11-28 23:41:33 +00:00

144 lines
5.8 KiB
Python

#!/usr/bin/env python3
"""Guardrails for first-wave localized public docs."""
from __future__ import annotations
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[2]
def read(rel: str) -> str:
return (ROOT / rel).read_text(encoding="utf-8")
LOCALIZED_DOCS = (
"docs/i18n/de/README.md",
"docs/i18n/es/README.md",
"docs/i18n/fr/README.md",
)
MACHINE_FACING_STRINGS = (
"export PULSE_VERSION=v",
"curl -fsSLO \"https://github.com/rcourtman/Pulse/releases/download/${PULSE_VERSION}/install.sh\"",
"curl -fsSLO \"https://github.com/rcourtman/Pulse/releases/download/${PULSE_VERSION}/install.sh.sshsig\"",
"ssh-keygen -Y verify",
"bash install.sh --version \"${PULSE_VERSION}\"",
"docker run -d",
" rcourtman/pulse:v",
"image: ${PULSE_IMAGE:-rcourtman/pulse:v",
"docker exec pulse /app/pulse bootstrap-token",
"kubectl exec -it <pod> -- /app/pulse bootstrap-token",
"sudo pulse bootstrap-token",
"Settings → Infrastructure → Install on a host",
"Settings → System → Plans & Billing",
"License recovery",
"ppk_live_",
"http://<your-ip>:7655",
"/install.sh",
"https://pulserelay.pro/download.html",
)
class LocalizedPublicDocsTest(unittest.TestCase):
def test_public_indexes_link_to_localized_getting_started_docs(self) -> None:
root_readme = read("README.md")
docs_index = read("docs/README.md")
self.assertIn("[Deutsch](docs/i18n/de/README.md)", root_readme)
self.assertIn("[Español](docs/i18n/es/README.md)", root_readme)
self.assertIn("[Français](docs/i18n/fr/README.md)", root_readme)
self.assertIn("[Deutsch](i18n/de/README.md)", docs_index)
self.assertIn("[Español](i18n/es/README.md)", docs_index)
self.assertIn("[Français](i18n/fr/README.md)", docs_index)
def test_localized_docs_preserve_machine_facing_strings(self) -> None:
for rel in LOCALIZED_DOCS:
content = read(rel)
for value in MACHINE_FACING_STRINGS:
with self.subTest(path=rel, value=value):
self.assertIn(value, content)
def test_localized_docs_point_back_to_canonical_english_docs(self) -> None:
for rel in LOCALIZED_DOCS:
content = read(rel)
with self.subTest(path=rel):
self.assertIn("[docs/README.md](../../README.md)", content)
self.assertIn("[Installation Guide](../../INSTALL.md)", content)
self.assertIn("[Configuration](../../CONFIGURATION.md)", content)
self.assertIn("[Troubleshooting](../../TROUBLESHOOTING.md)", content)
self.assertIn("[Agent Security](../../AGENT_SECURITY.md)", content)
self.assertIn("[Plans and entitlements](../../PULSE_PRO.md)", content)
def test_localized_compose_uses_bootstrap_not_shared_credentials(self) -> None:
for rel in LOCALIZED_DOCS:
content = read(rel)
with self.subTest(path=rel):
self.assertNotIn("secret123", content)
self.assertNotIn("PULSE_AUTH_USER=", content)
self.assertNotIn("PULSE_AUTH_PASS=", content)
self.assertIn("../../CONFIGURATION.md#private-docker-authentication-file", content)
self.assertIn("docker exec pulse /app/pulse bootstrap-token", content)
def test_localized_docs_do_not_reintroduce_paid_capacity_claims(self) -> None:
forbidden = (
"unlimited",
"uncapped",
"no cap",
"no-cap",
"sin límite",
"ilimitado",
"illimité",
"sans limite",
"unbegrenzt",
)
for rel in LOCALIZED_DOCS:
content = read(rel).lower()
for phrase in forbidden:
with self.subTest(path=rel, phrase=phrase):
self.assertNotIn(phrase, content)
def test_localized_docs_keep_90_day_history_in_community_and_current_plans_path(self) -> None:
community_history = {
"docs/i18n/de/README.md": ("90 Tage Verlauf", "und 90 Tage Verlauf"),
"docs/i18n/es/README.md": ("historial de 90 días", "e historial de 90 días"),
"docs/i18n/fr/README.md": ("90 jours d'historique", "et 90 jours d'historique"),
}
for rel, (expected, stale_pro_claim) in community_history.items():
content = read(rel)
prose = " ".join(content.split())
with self.subTest(path=rel):
self.assertIn(expected, prose)
self.assertNotIn(stale_pro_claim, prose)
self.assertIn("**Settings → System → Plans & Billing**", content)
self.assertNotIn("Settings → Plans & Billing → License recovery", content)
shipped = ROOT / "frontend-modern/public/docs" / rel.removeprefix("docs/")
self.assertEqual(shipped.read_text(encoding="utf-8"), content)
def test_localized_docs_include_shipped_pro_runtime_switch_cards(self) -> None:
plan_section = (
ROOT / "frontend-modern/src/components/Settings/ProLicensePlanSection.tsx"
).read_text(encoding="utf-8")
for label in (
"Switch this install to Pulse Pro",
"Switch to Pulse Pro",
"Switch this container to Pulse Pro",
):
self.assertIn(label, plan_section)
for rel in LOCALIZED_DOCS:
prose = " ".join(read(rel).split())
for label in (
"Switch this install to Pulse Pro",
"Switch to Pulse Pro",
"Switch this container to Pulse Pro",
):
with self.subTest(path=rel, label=label):
self.assertIn(label, prose)
if __name__ == "__main__":
unittest.main()