feat. Mini UI to hide ugly 404s

This commit is contained in:
Space-Banane
2026-05-22 22:28:11 +02:00
parent 7067f10f10
commit 33e8fe9315
4 changed files with 156 additions and 2 deletions

40
tests/test_main_pages.py Normal file
View File

@@ -0,0 +1,40 @@
from __future__ import annotations
from fastapi.testclient import TestClient
from gitea_codex_bot.main import app
def test_root_returns_tailwind_landing_page() -> None:
client = TestClient(app)
response = client.get("/")
assert response.status_code == 200
assert response.headers["content-type"].startswith("text/html")
assert "Gitea Codex Review Bot" in response.text
assert "cdn.tailwindcss.com" in response.text
assert 'id="health-button"' in response.text
assert 'id="health-modal"' in response.text
assert 'fetch("/healthz"' in response.text
def test_404_returns_tailwind_page_for_browser_requests() -> None:
client = TestClient(app)
response = client.get("/missing", headers={"Accept": "text/html"})
assert response.status_code == 404
assert response.headers["content-type"].startswith("text/html")
assert "Error 404" in response.text
assert "cdn.tailwindcss.com" in response.text
def test_404_returns_json_for_non_browser_requests() -> None:
client = TestClient(app)
response = client.get("/missing", headers={"Accept": "application/json"})
assert response.status_code == 404
assert response.headers["content-type"].startswith("application/json")
assert response.json() == {"detail": "Not Found"}