mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
- New /transformations/feed endpoint returning message diffs - Alpine.js drawer UI with virtual scrolling and auto-stream pause - Live Feed button hidden when log_full_messages=false - Added --log-messages CLI flag to enable full message logging - Backend stores request/response messages when enabled Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""Tests for the /transformations/feed endpoint in the proxy server."""
|
|
|
|
import pytest
|
|
|
|
# Skip if fastapi not available
|
|
pytest.importorskip("fastapi")
|
|
|
|
from httpx import ASGITransport, AsyncClient
|
|
|
|
from headroom.proxy.server import create_app
|
|
|
|
|
|
@pytest.fixture
|
|
def app():
|
|
return create_app()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_transformations_feed_endpoint_returns_list(app):
|
|
"""The endpoint should return a list of recent transformations."""
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
response = await client.get("/transformations/feed")
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert isinstance(data, dict)
|
|
assert "transformations" in data
|
|
assert isinstance(data["transformations"], list)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_transformations_feed_returns_messages(app):
|
|
"""Each transformation should include request_messages and response_content."""
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
response = await client.get("/transformations/feed")
|
|
|
|
data = response.json()
|
|
transformations = data["transformations"]
|
|
for t in transformations:
|
|
assert "request_messages" in t or t.get("request_messages") is None
|
|
assert "response_content" in t or t.get("response_content") is None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_transformations_feed_respects_limit(app):
|
|
"""The endpoint should respect a ?limit= query parameter."""
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
response = await client.get("/transformations/feed?limit=5")
|
|
|
|
data = response.json()
|
|
assert len(data["transformations"]) <= 5
|