ui redirects

This commit is contained in:
John Lancaster
2026-06-28 14:19:03 -05:00
parent 912cfd44de
commit dba96e7a72
3 changed files with 49 additions and 12 deletions
+24 -12
View File
@@ -1,8 +1,7 @@
"""Tests for UI page registration wiring."""
from fastapi import FastAPI
from fastapi.testclient import TestClient
import pytest
from fastapi import FastAPI
from transcription.ui import register_pages
@@ -11,16 +10,29 @@ from transcription.ui import register_pages
class TestPageRegistration:
"""Verify page registration and route wiring."""
def test_register_pages_adds_expected_routes(self):
"""register_pages wires upload and jobs routes into the app."""
def test_register_pages_wires_upload_jobs_and_mount(self, monkeypatch):
"""register_pages registers pages and mounts NiceGUI at /ui."""
calls: list[str] = []
def _record_upload() -> None:
calls.append("upload")
def _record_jobs() -> None:
calls.append("jobs")
def _record_run_with(
_app: FastAPI,
*,
mount_path: str,
show_welcome_message: bool,
) -> None:
calls.append(f"run_with:{mount_path}:{show_welcome_message}")
monkeypatch.setattr("transcription.ui.register_upload_page", _record_upload)
monkeypatch.setattr("transcription.ui.register_jobs_page", _record_jobs)
monkeypatch.setattr("transcription.ui.ui.run_with", _record_run_with)
app = FastAPI()
register_pages(app)
app.add_api_route("/healthz", lambda: {"status": "ok"}, methods=["GET"])
client = TestClient(app)
ui_response = client.get("/ui")
health_response = client.get("/healthz")
assert ui_response.status_code == 200
assert health_response.status_code == 200
assert health_response.json() == {"status": "ok"}
assert calls == ["upload", "jobs", "run_with:/ui:False"]