generated from john/python-template
UI updates, changes sync'd to UI docs
This commit is contained in:
@@ -29,7 +29,28 @@ class TestDocumentsPageRendering:
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Documents" in response.text
|
||||
assert "Create new document" in response.text
|
||||
assert "No documents yet." in response.text
|
||||
assert "Create your first document" in response.text
|
||||
|
||||
def test_document_create_page_renders_fields(self, app_client):
|
||||
"""GET /ui/documents/new renders document-create form fields."""
|
||||
_, client = app_client
|
||||
|
||||
response = client.get("/ui/documents/new")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Create document" in response.text
|
||||
assert "Document name is required." in response.text
|
||||
assert "Document name" in response.text
|
||||
assert "Document type" in response.text
|
||||
assert "Author (Person)" in response.text
|
||||
assert "Exact date (YYYY-MM-DD)" in response.text
|
||||
assert "Approximate date" in response.text
|
||||
assert "Document location" in response.text
|
||||
assert "Archive identifier" in response.text
|
||||
assert "Notes" in response.text
|
||||
assert "Save document" in response.text
|
||||
|
||||
def test_documents_page_lists_seeded_documents(self, app_client):
|
||||
"""GET /ui/documents lists seeded document cards."""
|
||||
@@ -75,6 +96,7 @@ class TestDocumentsPageRendering:
|
||||
assert response.status_code == 200
|
||||
assert "Zenna Letter" in response.text
|
||||
assert "Document type: letter" in response.text
|
||||
assert "Author: not set" in response.text
|
||||
assert "Exact date: 1885-07-13" in response.text
|
||||
assert "Approximate date: c. 1885" in response.text
|
||||
assert "Location created: Ohio" in response.text
|
||||
@@ -83,12 +105,12 @@ class TestDocumentsPageRendering:
|
||||
assert "Created at (read-only):" in response.text
|
||||
assert "Updated at (read-only):" in response.text
|
||||
assert "No linked people yet." in response.text
|
||||
assert "No sources added yet." in response.text
|
||||
assert "No jobs created yet." in response.text
|
||||
assert "0 source(s) linked" in response.text
|
||||
assert "0 job(s) linked" in response.text
|
||||
assert "Add sources" in response.text
|
||||
assert "Create job" in response.text
|
||||
assert "View sources" in response.text
|
||||
assert "View jobs" in response.text
|
||||
assert "Sources" in response.text
|
||||
assert "Jobs" in response.text
|
||||
assert "Edit document" in response.text
|
||||
assert "Delete document" in response.text
|
||||
|
||||
@@ -135,8 +157,9 @@ class TestDocumentsPageRendering:
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Jane Doe (author)" in response.text
|
||||
assert "Page 1: 001_page.png" in response.text
|
||||
assert "queued -" in response.text
|
||||
assert "Author: Jane Doe" in response.text
|
||||
assert "1 source(s) linked" in response.text
|
||||
assert "1 job(s) linked" in response.text
|
||||
|
||||
def test_document_jobs_page_filters_to_document_context(self, app_client):
|
||||
_, client = app_client
|
||||
@@ -245,6 +268,7 @@ class TestDocumentsPageRendering:
|
||||
assert "Document name and document type are required." in response.text
|
||||
assert "Document name" in response.text
|
||||
assert "Document type" in response.text
|
||||
assert "Author (Person)" in response.text
|
||||
assert "Exact date (YYYY-MM-DD)" in response.text
|
||||
assert "Approximate date" in response.text
|
||||
assert "Document location" in response.text
|
||||
|
||||
+12
-41
@@ -1,7 +1,6 @@
|
||||
"""Tests for the jobs page route."""
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
@@ -33,6 +32,7 @@ class TestPageRendering:
|
||||
assert response.status_code == 200
|
||||
assert "Create job" in response.text
|
||||
assert "No documents available. Create a Document before creating a Job." in response.text
|
||||
assert "Create document" in response.text
|
||||
|
||||
def test_job_create_page_lists_available_documents(self, app_client):
|
||||
"""GET /ui/jobs/new renders document choices when Documents exist."""
|
||||
@@ -52,7 +52,7 @@ class TestPageRendering:
|
||||
assert "Seeded Document" in response.text
|
||||
assert "Files are processed alphabetically by original filename." in response.text
|
||||
assert "No files uploaded yet." in response.text
|
||||
assert "Upload folder" in response.text
|
||||
assert "Select source files or a folder" in response.text
|
||||
|
||||
def test_jobs_page_lists_seeded_jobs(self, app_client, seed_job):
|
||||
"""GET /ui/jobs lists seeded jobs from the in-memory database."""
|
||||
@@ -65,37 +65,28 @@ class TestPageRendering:
|
||||
assert "sample.pdf" in response.text
|
||||
assert "transcribed" in response.text
|
||||
|
||||
def test_job_detail_page_renders_seeded_job(self, app_client, seed_job):
|
||||
"""GET /ui/jobs/{job_id} renders detail content for a real seeded job."""
|
||||
def test_job_detail_page_renders_document_links(self, app_client, seed_job):
|
||||
"""GET /ui/jobs/{job_id} renders document-scoped navigation links."""
|
||||
_, client = app_client
|
||||
fixture_path = Path(__file__).resolve().parents[1] / "fixtures" / "images" / "valid" / "single_page_pdf.pdf"
|
||||
job_id = seed_job(
|
||||
filename="detail.pdf",
|
||||
status=JobStatus.TRANSCRIBED,
|
||||
transcription_text="original text",
|
||||
revision_text="hello",
|
||||
source_file=fixture_path,
|
||||
)
|
||||
|
||||
response = client.get(f"/ui/jobs/{job_id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Original Transcription" in response.text
|
||||
assert "detail.pdf" in response.text
|
||||
assert "Source revision" in response.text
|
||||
assert "Source revision" in response.text
|
||||
assert "hello" in response.text
|
||||
assert "original text" in response.text
|
||||
assert "Document preview" in response.text
|
||||
assert "/uploads/detail.pdf" in response.text
|
||||
assert "Job" in response.text
|
||||
assert "Provider:" in response.text
|
||||
assert "Model:" in response.text
|
||||
assert "Prompt:" in response.text
|
||||
assert "Retry count:" in response.text
|
||||
assert "Last updated:" in response.text
|
||||
assert "Delete job" in response.text
|
||||
assert "Delete source" in response.text
|
||||
assert "This permanently deletes the source from this job context." in response.text
|
||||
assert "Document Links" in response.text
|
||||
assert "Sources" in response.text
|
||||
assert "Jobs" in response.text
|
||||
assert "Delete job" not in response.text
|
||||
|
||||
def test_job_detail_page_rejects_invalid_id(self, app_client):
|
||||
"""GET /ui/jobs/{job_id} shows validation feedback for malformed IDs."""
|
||||
@@ -114,39 +105,19 @@ class TestPageRendering:
|
||||
assert response.status_code == 200
|
||||
assert "Job not found" in response.text
|
||||
|
||||
def test_job_detail_page_shows_revision_editor_when_none_exists(self, app_client, seed_job):
|
||||
"""GET /ui/jobs/{job_id} renders revision editor and create action for sources with no revision."""
|
||||
def test_job_detail_page_hides_delete_action(self, app_client, seed_job):
|
||||
"""GET /ui/jobs/{job_id} does not expose job deletion controls in this revision."""
|
||||
_, client = app_client
|
||||
job_id = seed_job(
|
||||
filename="no-revision.pdf",
|
||||
status=JobStatus.TRANSCRIBED,
|
||||
transcription_text="original text",
|
||||
revision_text=None,
|
||||
)
|
||||
|
||||
response = client.get(f"/ui/jobs/{job_id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Revision Editor" in response.text
|
||||
assert "Create revision" in response.text
|
||||
assert "No source revision exists for this source." in response.text
|
||||
|
||||
def test_job_detail_page_shows_update_action_for_existing_revision(self, app_client, seed_job):
|
||||
"""GET /ui/jobs/{job_id} renders revision editor with update action when revision exists."""
|
||||
_, client = app_client
|
||||
job_id = seed_job(
|
||||
filename="with-revision.pdf",
|
||||
status=JobStatus.TRANSCRIBED,
|
||||
transcription_text="original text",
|
||||
revision_text="hello",
|
||||
)
|
||||
|
||||
response = client.get(f"/ui/jobs/{job_id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Revision Editor" in response.text
|
||||
assert "Update revision" in response.text
|
||||
assert "hello" in response.text
|
||||
assert "Delete job" not in response.text
|
||||
|
||||
def test_job_delete_page_shows_confirmation_when_not_processing(self, app_client, seed_job):
|
||||
_, client = app_client
|
||||
|
||||
@@ -85,6 +85,7 @@ class TestPeoplePageRendering:
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Grace Hopper" in response.text
|
||||
assert "Full name: Grace Hopper" in response.text
|
||||
assert "Display name: Grace" in response.text
|
||||
assert "Maiden name: Murray" in response.text
|
||||
assert "Birth date: 1906-12-09" in response.text
|
||||
|
||||
@@ -15,13 +15,13 @@ class TestPageRendering:
|
||||
assert response.status_code == 307
|
||||
assert response.headers["location"] == "/ui"
|
||||
|
||||
def test_ui_redirects_to_upload(self, app_client):
|
||||
"""GET /ui redirects to the jobs page."""
|
||||
def test_ui_redirects_to_documents(self, app_client):
|
||||
"""GET /ui redirects to the documents page."""
|
||||
_, client = app_client
|
||||
response = client.get("/ui", follow_redirects=False)
|
||||
|
||||
assert response.status_code == 307
|
||||
assert response.headers["location"] == "/ui/jobs"
|
||||
assert response.headers["location"] == "/ui/documents"
|
||||
|
||||
def test_upload_page_renders_expected_controls(self, app_client):
|
||||
"""GET /ui/upload redirects to the job-create flow."""
|
||||
|
||||
Reference in New Issue
Block a user