refactor: initial step - remove comments/annotations from file_detail and file_view templates
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/12276514-bd3d-4e3e-84d9-5977d1f82b19
This commit is contained in:
+47
-29
@@ -1,4 +1,4 @@
|
||||
"""Tests for the comments and annotations UI on the file detail page."""
|
||||
"""Tests for the comments and annotations UI on the file view page."""
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
@@ -7,7 +7,7 @@ from app.models import FileRecord
|
||||
|
||||
|
||||
def _create_file(db_session, tmp_path) -> FileRecord:
|
||||
"""Create a minimal FileRecord with a real file path for the detail page."""
|
||||
"""Create a minimal FileRecord with a real file path for the view page."""
|
||||
file_path = tmp_path / "test.pdf"
|
||||
file_path.write_bytes(b"%PDF-1.4")
|
||||
f = FileRecord(
|
||||
@@ -26,77 +26,77 @@ def _create_file(db_session, tmp_path) -> FileRecord:
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestCommentsUIRendering:
|
||||
"""Verify the file detail page includes the comments panel HTML."""
|
||||
"""Verify the file view page includes the comments panel HTML."""
|
||||
|
||||
def test_detail_page_contains_comments_section(self, client: TestClient, db_session, tmp_path):
|
||||
"""The detail page should render the comments panel container."""
|
||||
def test_view_page_contains_comments_section(self, client: TestClient, db_session, tmp_path):
|
||||
"""The view page should render the comments panel container."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert 'id="comments-list"' in html
|
||||
assert 'id="comment-form"' in html
|
||||
assert 'id="comment-input"' in html
|
||||
|
||||
def test_detail_page_contains_annotations_section(self, client: TestClient, db_session, tmp_path):
|
||||
"""The detail page should render the annotations panel container."""
|
||||
def test_view_page_contains_annotations_section(self, client: TestClient, db_session, tmp_path):
|
||||
"""The view page should render the annotations panel container."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert 'id="annotations-list"' in html
|
||||
assert 'id="annotation-form"' in html
|
||||
assert 'id="annotation-content-input"' in html
|
||||
|
||||
def test_detail_page_loads_comments_js(self, client: TestClient, db_session, tmp_path):
|
||||
"""The detail page should include the comments JavaScript file."""
|
||||
def test_view_page_loads_comments_js(self, client: TestClient, db_session, tmp_path):
|
||||
"""The view page should include the comments JavaScript file."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
assert "js/comments.js" in resp.text
|
||||
|
||||
def test_detail_page_loads_annotations_js(self, client: TestClient, db_session, tmp_path):
|
||||
"""The detail page should include the annotations JavaScript file."""
|
||||
def test_view_page_loads_annotations_js(self, client: TestClient, db_session, tmp_path):
|
||||
"""The view page should include the annotations JavaScript file."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
assert "js/annotations.js" in resp.text
|
||||
|
||||
def test_detail_page_has_mention_dropdown(self, client: TestClient, db_session, tmp_path):
|
||||
def test_view_page_has_mention_dropdown(self, client: TestClient, db_session, tmp_path):
|
||||
"""The mention autocomplete dropdown should be present."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
assert 'id="mention-dropdown"' in resp.text
|
||||
|
||||
def test_detail_page_has_annotation_form_fields(self, client: TestClient, db_session, tmp_path):
|
||||
def test_view_page_has_annotation_form_fields(self, client: TestClient, db_session, tmp_path):
|
||||
"""Annotation form should have page, type, and color inputs."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert 'id="annotation-page-input"' in html
|
||||
assert 'id="annotation-type-input"' in html
|
||||
assert 'id="annotation-color-input"' in html
|
||||
|
||||
def test_detail_page_has_collab_grid(self, client: TestClient, db_session, tmp_path):
|
||||
def test_view_page_has_collab_grid(self, client: TestClient, db_session, tmp_path):
|
||||
"""Comments and annotations should be in a side-by-side grid layout."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
assert "collab-grid" in resp.text
|
||||
|
||||
def test_detail_page_no_comments_for_missing_file(self, client: TestClient):
|
||||
def test_view_page_no_comments_for_missing_file(self, client: TestClient):
|
||||
"""When file is not found, no comments section should appear."""
|
||||
resp = client.get("/files/99999/detail")
|
||||
resp = client.get("/files/99999")
|
||||
assert resp.status_code == 200
|
||||
# The error block is shown, not the main content
|
||||
assert 'id="comments-list"' not in resp.text
|
||||
|
||||
def test_detail_page_annotation_type_options(self, client: TestClient, db_session, tmp_path):
|
||||
def test_view_page_annotation_type_options(self, client: TestClient, db_session, tmp_path):
|
||||
"""Annotation type selector should include all four types."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert 'value="note"' in html
|
||||
@@ -104,20 +104,38 @@ class TestCommentsUIRendering:
|
||||
assert 'value="underline"' in html
|
||||
assert 'value="strikethrough"' in html
|
||||
|
||||
def test_detail_page_comments_panel_accessibility(self, client: TestClient, db_session, tmp_path):
|
||||
def test_view_page_comments_panel_accessibility(self, client: TestClient, db_session, tmp_path):
|
||||
"""Comments panel should have proper ARIA attributes."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert 'aria-live="polite"' in html
|
||||
assert 'role="listbox"' in html
|
||||
|
||||
def test_detail_page_init_script(self, client: TestClient, db_session, tmp_path):
|
||||
def test_view_page_init_script(self, client: TestClient, db_session, tmp_path):
|
||||
"""The init script should call initComments and initAnnotations."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
resp = client.get(f"/files/{f.id}")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert "initComments" in html
|
||||
assert "initAnnotations" in html
|
||||
|
||||
def test_detail_page_no_comments_section(self, client: TestClient, db_session, tmp_path):
|
||||
"""The detail page should NOT render the comments panel (moved to view page)."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert 'id="comments-list"' not in html
|
||||
assert 'id="comment-form"' not in html
|
||||
|
||||
def test_detail_page_no_annotations_section(self, client: TestClient, db_session, tmp_path):
|
||||
"""The detail page should NOT render the annotations panel (moved to view page)."""
|
||||
f = _create_file(db_session, tmp_path)
|
||||
resp = client.get(f"/files/{f.id}/detail")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert 'id="annotations-list"' not in html
|
||||
assert 'id="annotation-form"' not in html
|
||||
|
||||
Reference in New Issue
Block a user