Add test runner dashboard service (test.rose-ash.com)
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Public Quart microservice that runs pytest against shared/tests/ and shared/sexp/tests/, serving an HTMX-powered sexp-rendered dashboard with pass/fail/running status, auto-refresh polling, and re-run button. No database — results stored in memory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1
test/bp/__init__.py
Normal file
1
test/bp/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .dashboard.routes import register as register_dashboard
|
||||
0
test/bp/dashboard/__init__.py
Normal file
0
test/bp/dashboard/__init__.py
Normal file
64
test/bp/dashboard/routes.py
Normal file
64
test/bp/dashboard/routes.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""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()
|
||||
|
||||
html = await render_dashboard_page(ctx, result, running, csrf)
|
||||
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()
|
||||
|
||||
html = await render_results_partial(result, running, csrf)
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user