Files
mono/test/bp/dashboard/routes.py
giles 3809affcab Test dashboard: full menu system, all-service tests, filtering
- Run tests for all 10 services via per-service pytest subprocesses
- Group results by service with section headers
- Clickable summary cards filter by outcome (passed/failed/errors/skipped)
- Service filter nav using ~nav-link buttons in menu bar
- Full menu integration: ~header-row + ~header-child + ~menu-row
- Show logo image via cart-mini rendering
- Mount full service directories in docker-compose for test access
- Add 24 unit test files across 9 services

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 22:54:25 +00:00

77 lines
2.4 KiB
Python

"""Test dashboard routes."""
from __future__ import annotations
import asyncio
from quart import Blueprint, Response, make_response, request
def register(url_prefix: str = "/") -> Blueprint:
bp = Blueprint("dashboard", __name__, url_prefix=url_prefix)
@bp.get("/")
async def index():
"""Full page dashboard with last results."""
from shared.sexp.page import get_template_context
from shared.browser.app.csrf import generate_csrf_token
from sexp.sexp_components import render_dashboard_page
import runner
ctx = await get_template_context()
result = runner.get_results()
running = runner.is_running()
csrf = generate_csrf_token()
active_filter = request.args.get("filter")
active_service = request.args.get("service")
html = await render_dashboard_page(
ctx, result, running, csrf,
active_filter=active_filter,
active_service=active_service,
)
return await make_response(html, 200)
@bp.post("/run")
async def run():
"""Trigger a test run, redirect to /."""
import runner
if not runner.is_running():
asyncio.create_task(runner.run_tests())
# HX-Redirect for HTMX, regular redirect for non-HTMX
if request.headers.get("HX-Request"):
resp = Response("", status=200)
resp.headers["HX-Redirect"] = "/"
return resp
from quart import redirect as qredirect
return qredirect("/")
@bp.get("/results")
async def results():
"""HTMX partial — poll target for results table."""
from shared.browser.app.csrf import generate_csrf_token
from sexp.sexp_components import render_results_partial
import runner
result = runner.get_results()
running = runner.is_running()
csrf = generate_csrf_token()
active_filter = request.args.get("filter")
active_service = request.args.get("service")
html = await render_results_partial(
result, running, csrf,
active_filter=active_filter,
active_service=active_service,
)
resp = Response(html, status=200, content_type="text/html")
# If still running, tell HTMX to keep polling
if running:
resp.headers["HX-Trigger-After-Swap"] = "test-still-running"
return resp
return bp