Revise Source detail page to improve line-wrap issues.
Quality Gate / gate (push) Failing after 11s

This commit is contained in:
Jim Lancaster
2026-08-22 18:56:22 -05:00
parent 0d554c0648
commit 94db493756
3 changed files with 160 additions and 19 deletions
+34
View File
@@ -6,6 +6,7 @@ from pathlib import Path
from uuid import uuid4
import pytest
from PIL import Image
from sqlmodel import select
from transcription.db import session_scope
@@ -20,6 +21,8 @@ from transcription.db.models import JobStatus
from transcription.db.models import Source
from transcription.providers.evidence import TransportEvidence
from transcription.services.sources import SourceService
from transcription.ui.pages.sources_page import _is_wide_narrow_image
from transcription.ui.pages.sources_page import _resolve_source_detail_layout
# --- Unit Tests for Model @property Definitions ---
@@ -44,6 +47,37 @@ class TestSourceModelProperties:
assert source.latest_error_detail is None
assert source.document_name is None
def test_wide_narrow_aspect_detection_threshold(self):
assert _is_wide_narrow_image(width=2200, height=1000)
assert not _is_wide_narrow_image(width=1800, height=1000)
assert not _is_wide_narrow_image(width=0, height=1000)
@pytest.mark.asyncio
async def test_source_detail_layout_switches_for_wide_narrow_images(self, app_client):
app, _ = app_client
async with session_scope() as session:
document = Document(name="Layout test doc")
session.add(document)
await session.flush()
wide_path = app.state.settings.upload_dir / "documents" / str(document.id) / "wide-strip.png"
wide_path.parent.mkdir(parents=True, exist_ok=True)
Image.new("RGB", (2400, 800), color=(255, 255, 255)).save(wide_path, format="PNG")
source = Source(
document_id=document.id,
page_number=1,
upload_name="wide-strip.png",
filename="wide-strip.png",
file_path=wide_path.relative_to(app.state.settings.upload_dir).as_posix(),
file_hash="c" * 64,
file_size_bytes=wide_path.stat().st_size,
)
session.add(source)
await session.commit()
assert _resolve_source_detail_layout(source=source, settings=app.state.settings) == "wide_narrow"
@pytest.mark.asyncio
async def test_source_properties_with_document_and_job_sources(self, seed_job):
job_id = await seed_job(