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."""
from uuid import UUID
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from transcription.ui import register_pages
from transcription.ui.pages import jobs_page
from transcription.ui.pages.jobs_page import JobTableRow
@pytest.fixture
@@ -13,7 +16,16 @@ def client(monkeypatch):
"""Provide a minimal app client with jobs data patched for rendering."""
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)
@@ -27,11 +39,15 @@ def client(monkeypatch):
class TestPageRendering:
"""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."""
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 "Transcription Jobs" in response.text
assert "Refresh" in response.text
assert "Back to upload" in response.text
assert "No jobs yet." in response.text