test updates

This commit is contained in:
John Lancaster
2026-06-28 15:18:31 -05:00
parent 83ee7b31e0
commit 593388ef3a
3 changed files with 25 additions and 8 deletions
+21 -5
View File
@@ -1,11 +1,14 @@
"""Tests for the jobs page route.""" """Tests for the jobs page route."""
from uuid import UUID
import pytest import pytest
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from transcription.ui import register_pages from transcription.ui import register_pages
from transcription.ui.pages import jobs_page from transcription.ui.pages import jobs_page
from transcription.ui.pages.jobs_page import JobTableRow
@pytest.fixture @pytest.fixture
@@ -13,7 +16,16 @@ def client(monkeypatch):
"""Provide a minimal app client with jobs data patched for rendering.""" """Provide a minimal app client with jobs data patched for rendering."""
async def _fetch_jobs_stub(): async def _fetch_jobs_stub():
return [] return [
JobTableRow(
id=UUID("00000000-0000-0000-0000-000000000001"),
status="queued",
filename="sample.pdf",
retry_count=2,
created_at="2026-01-01T12:00:00+00:00",
updated_at="2026-01-01T12:01:00+00:00",
)
]
monkeypatch.setattr(jobs_page, "fetch_jobs", _fetch_jobs_stub) monkeypatch.setattr(jobs_page, "fetch_jobs", _fetch_jobs_stub)
@@ -27,11 +39,15 @@ def client(monkeypatch):
class TestPageRendering: class TestPageRendering:
"""Verify the jobs page is available and includes the main controls.""" """Verify the jobs page is available and includes the main controls."""
def test_jobs_page_renders_expected_controls(self, client): def test_jobs_page_renders_expected_controls(self, client, monkeypatch):
"""GET /ui/jobs returns the page shell and jobs controls.""" """GET /ui/jobs returns the page shell and jobs controls."""
response = client.get("/ui/jobs") response = client.get("/ui/jobs")
async def _fetch_jobs_empty():
return []
monkeypatch.setattr(jobs_page, "fetch_jobs", _fetch_jobs_empty)
response = client.get("/ui/jobs")
assert response.status_code == 200 assert response.status_code == 200
assert "Transcription Jobs" in response.text assert "No jobs yet." in response.text
assert "Refresh" in response.text
assert "Back to upload" in response.text
+3 -2
View File
@@ -25,8 +25,9 @@ class TestPageRegistration:
*, *,
mount_path: str, mount_path: str,
show_welcome_message: bool, show_welcome_message: bool,
dark: bool,
) -> None: ) -> None:
calls.append(f"run_with:{mount_path}:{show_welcome_message}") calls.append(f"run_with:{mount_path}:{show_welcome_message}:{dark}")
monkeypatch.setattr("transcription.ui.register_upload_page", _record_upload) monkeypatch.setattr("transcription.ui.register_upload_page", _record_upload)
monkeypatch.setattr("transcription.ui.register_jobs_page", _record_jobs) monkeypatch.setattr("transcription.ui.register_jobs_page", _record_jobs)
@@ -35,4 +36,4 @@ class TestPageRegistration:
app = FastAPI() app = FastAPI()
register_pages(app) register_pages(app)
assert calls == ["upload", "jobs", "run_with:/ui:False"] assert calls == ["upload", "jobs", "run_with:/ui:False:True"]
+1 -1
View File
@@ -52,4 +52,4 @@ class TestPageRendering:
assert response.status_code == 200 assert response.status_code == 200
assert "Upload Document" in response.text assert "Upload Document" in response.text
assert "Select document file" in response.text assert "Select document file" in response.text
assert "View jobs" in response.text assert "Jobs" in response.text