Files
cc-ci/tests/uptime-kuma/custom/test_spa_branding.py
T
notplantsandClaude Fable 5.1 9a80002b37
continuous-integration/drone/push Build is failing
lint: ruff format + one auto-fix so the push self-test is green again
`scripts/lint.sh --fix` from the pinned lint devshell: 90 Python files
reformatted (ruff format, mechanical) and one C420 (dict comprehension →
dict.fromkeys) in tests/unit/test_f211_sso_skip.py. The push self-test had
been failing at the lint stage since build 1313 (2026-08-31) on exactly
these files; nothing else changed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FqkQq3CDmFWcQ7u1LzoyRz
2026-09-07 21:15:05 +00:00

55 lines
2.0 KiB
Python

"""uptime-kuma — recipe-specific functional test (Phase 2 P3).
GETs `/` and asserts the served HTML carries uptime-kuma-specific markers:
- "uptime kuma" (or just "kuma") brand string somewhere in the page (title/body).
- A reference to one of the SPA's bundled assets (e.g., `/assets/`, `/icon.svg`, `kuma`).
Distinguishes "the SPA bundle is bound and being served" from "a generic 200 response with
some other content." Non-vacuous: an empty fallback page from a wedged uptime-kuma backend
would 200 but contain none of these markers.
"""
from __future__ import annotations
import os
import ssl
import sys
import urllib.request
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
from harness import http as harness_http # noqa: E402
def _get_body(url: str) -> tuple[int, str]:
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
req = urllib.request.Request(url, method="GET")
with urllib.request.urlopen(req, timeout=15, context=ctx) as r:
return r.status, r.read().decode(errors="replace")
def test_uptime_kuma_spa_has_branding(live_app):
"""GET /; assert uptime-kuma branding + asset references in HTML."""
url = f"https://{live_app}/"
def _ready():
try:
status, body = _get_body(url)
except Exception: # noqa: BLE001
return None
return body if status == 200 else None
body = harness_http.assert_converges(_ready, f"GET {url}", max_wait=60, interval=3)
lower = body.lower()
assert "uptime kuma" in lower or "kuma" in lower, (
f"Page body has no 'kuma' brand. Excerpt: {body[:200]!r}"
)
# SPA-bundle markers: at least one of these reference paths should be present
bundle_markers = ("/assets/", "/icon.svg", "favicon", "main.")
present = [m for m in bundle_markers if m in body]
assert present, (
f"GET {url} HTML references none of {bundle_markers} (SPA bundle not wired?). "
f"Excerpt: {body[:300]!r}"
)