Improve test code quality based on code review feedback
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
WORKDIR=/tmp/docuelevate_workdir
|
||||
DATABASE_URL=sqlite:////tmp/docuelevate_test.db
|
||||
REDIS_URL=redis://localhost:6379/0
|
||||
EXTERNAL_HOSTNAME=localhost
|
||||
GOTENBERG_URL=http://localhost:3000
|
||||
ALLOW_FILE_DELETE=true
|
||||
|
||||
AUTH_ENABLED=False
|
||||
SESSION_SECRET=test_secret_key_for_testing_must_be_at_least_32_characters_long
|
||||
|
||||
OPENAI_API_KEY=test-key
|
||||
AZURE_AI_KEY=test-key
|
||||
AZURE_REGION=test
|
||||
AZURE_ENDPOINT=https://test.com
|
||||
|
||||
UPTIME_KUMA_PING_INTERVAL=5
|
||||
+12
-11
@@ -6,6 +6,12 @@ from fastapi.testclient import TestClient
|
||||
from app.models import FileRecord
|
||||
|
||||
|
||||
def _assert_no_template_errors(content: str):
|
||||
"""Helper function to check that min/max undefined errors are not present."""
|
||||
assert "'min' is undefined" not in content
|
||||
assert "'max' is undefined" not in content
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
@pytest.mark.requires_db
|
||||
class TestFilesView:
|
||||
@@ -36,12 +42,11 @@ class TestFilesView:
|
||||
content = response.text
|
||||
assert "File Records" in content
|
||||
|
||||
# Ensure no 'min' is undefined error - this is the key fix
|
||||
assert "'min' is undefined" not in content.lower()
|
||||
assert "'max' is undefined" not in content.lower()
|
||||
# Ensure no 'min' or 'max' is undefined error - this is the key fix we're testing
|
||||
_assert_no_template_errors(content)
|
||||
|
||||
def test_files_view_pagination_with_many_pages(self, client: TestClient, db_session):
|
||||
"""Test that pagination works correctly with many pages."""
|
||||
"""Test that pagination works correctly with many pages and min/max functions work."""
|
||||
# Create enough files to span multiple pages (e.g., 150 files with 50 per page = 3 pages)
|
||||
for i in range(150):
|
||||
file_record = FileRecord(
|
||||
@@ -59,11 +64,7 @@ class TestFilesView:
|
||||
assert response.status_code == 200
|
||||
|
||||
content = response.text
|
||||
# Check for pagination elements
|
||||
assert "Showing" in content # Pagination info
|
||||
assert "of 150 files" in content
|
||||
|
||||
# Ensure the min/max functions work in the template (they're used for pagination)
|
||||
# The page should render successfully without JavaScript errors
|
||||
assert "'min' is undefined" not in content.lower()
|
||||
assert "'max' is undefined" not in content.lower()
|
||||
# The key test: ensure the min/max functions work in the template
|
||||
# (they're used for pagination on lines 397 and 406 of files.html)
|
||||
_assert_no_template_errors(content)
|
||||
|
||||
Reference in New Issue
Block a user