From 8d5fee886fd6eb6f24fa2bb9fef288e28b425443 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sun, 28 Jun 2026 13:44:49 -0500 Subject: [PATCH] pruned jobs page --- tests/ui/test_jobs_page.py | 116 ++++++++++--------------------------- 1 file changed, 29 insertions(+), 87 deletions(-) diff --git a/tests/ui/test_jobs_page.py b/tests/ui/test_jobs_page.py index 622af6b..94f7b8a 100644 --- a/tests/ui/test_jobs_page.py +++ b/tests/ui/test_jobs_page.py @@ -1,95 +1,37 @@ -"""Tests for transcription.ui.jobs_page.""" - -from uuid import uuid4 +"""Tests for the jobs page route.""" import pytest +from fastapi import FastAPI +from fastapi.testclient import TestClient -from transcription.models import Document, Job, Transcript -from transcription.ui.jobs_page import fetch_job_detail, fetch_jobs +from transcription.ui import register_pages +from transcription.ui.pages import jobs_page + + +@pytest.fixture +def client(monkeypatch): + """Provide a minimal app client with jobs data patched for rendering.""" + + async def _fetch_jobs_stub(): + return [] + + monkeypatch.setattr(jobs_page, "fetch_jobs", _fetch_jobs_stub) + + app = FastAPI() + register_pages(app) + with TestClient(app) as test_client: + yield test_client @pytest.mark.integration -class TestJobsListBehavior: - """Verify job list data and rendering helpers.""" +class TestPageRendering: + """Verify the jobs page is available and includes the main controls.""" - def test_fetch_jobs_returns_job_view_rows(self, session, monkeypatch): - """fetch_jobs returns normalized JobView rows for UI consumption.""" - document = Document(filename="letter.jpg", file_path="uploads/letter.jpg") - session.add(document) - session.commit() - session.refresh(document) + def test_jobs_page_renders_expected_controls(self, client): + """GET /ui/jobs returns the page shell and jobs controls.""" + response = client.get("/ui/jobs") - job = Job(document_id=document.id) - session.add(job) - session.commit() - - class _SessionContext: - def __enter__(self): - return session - - def __exit__(self, exc_type, exc, tb): - return False - - monkeypatch.setattr("transcription.ui.jobs_page.get_session", lambda: _SessionContext()) - - rows = fetch_jobs() - - assert len(rows) == 1 - assert rows[0].id == job.id - assert rows[0].status == "queued" - - -@pytest.mark.integration -class TestJobDetailBehavior: - """Verify job detail retrieval behavior.""" - - def test_fetch_job_detail_returns_related_records_when_present(self, session, monkeypatch): - """fetch_job_detail returns job, document, and transcript when available.""" - document = Document(filename="typed.jpg", file_path="uploads/typed.jpg") - session.add(document) - session.commit() - session.refresh(document) - - job = Job(document_id=document.id) - session.add(job) - session.commit() - session.refresh(job) - - transcript = Transcript(job_id=job.id, text="Transcript text") - session.add(transcript) - session.commit() - - class _SessionContext: - def __enter__(self): - return session - - def __exit__(self, exc_type, exc, tb): - return False - - monkeypatch.setattr("transcription.ui.jobs_page.get_session", lambda: _SessionContext()) - - fetched_job, fetched_document, fetched_transcript = fetch_job_detail(job.id) - - assert fetched_job is not None - assert fetched_document is not None - assert fetched_transcript is not None - assert fetched_job.id == job.id - assert fetched_document.id == document.id - assert fetched_transcript.job_id == job.id - - def test_fetch_job_detail_returns_nones_for_missing_job(self, session, monkeypatch): - """fetch_job_detail returns triple None when job does not exist.""" - class _SessionContext: - def __enter__(self): - return session - - def __exit__(self, exc_type, exc, tb): - return False - - monkeypatch.setattr("transcription.ui.jobs_page.get_session", lambda: _SessionContext()) - - fetched_job, fetched_document, fetched_transcript = fetch_job_detail(uuid4()) - - assert fetched_job is None - assert fetched_document is None - assert fetched_transcript is None + assert response.status_code == 200 + assert "Transcription Jobs" in response.text + assert "Refresh" in response.text + assert "Back to upload" in response.text