"""custom-html — parity port of recipe-maintainer's health_check.py (Phase 2 P2).

SOURCE: references/recipe-maintainer/recipe-info/custom-html/tests/health_check.py

The recipe-maintainer original asserted `HTTP 200` from `https://custom-html.<DOMAIN_SUFFIX>`. The
cc-ci port preserves that assertion shape (the served response is a real, non-error HTTP) but adapts
to the ephemeral per-run domain via the `live_app` fixture from `tests/conftest.py`. It runs in the
**custom** tier against the shared post-install live deployment — no deploy/teardown here.
"""

from __future__ import annotations

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
from harness import http as harness_http  # noqa: E402


def test_custom_html_returns_200(live_app):
    """Parity with recipe-info/custom-html/tests/health_check.py: HTTP 200 from the app root.

    Uses harness.http.retry_http_get so the cc-ci test is tolerant of any brief reconverge after the
    deploy (the orchestrator already waited for services_converged + ok status, so this should be
    immediate; the short retry is a safety net only)."""
    url = f"https://{live_app}/"
    status, _ = harness_http.retry_http_get(url, expect_status=200, max_wait=30, interval=2)
    assert status == 200, f"custom-html at {url} returned HTTP {status} (expected 200)"
