from app.version import VERSION


def test_healthz_ok(client):
    resp = client.get("/healthz")
    assert resp.status_code == 200
    assert resp.json() == {"status": "ok"}


def test_meta_reports_version_and_db_state(authed_client):
    resp = authed_client.get("/api/meta")
    assert resp.status_code == 200
    body = resp.json()
    assert body["app"] == "with"
    assert body["version"] == VERSION
    assert "changelog_head" in body
    assert body["db"]["connected"] is False  # unit tests run without a DB
    # every response carries the version — the SPA's skew-banner contract
    assert resp.headers["x-with-version"] == VERSION
