From 79f9bd182b4ee338bced1710caad7a777427032b Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 17 Jun 2026 15:06:05 +0200 Subject: [PATCH] test truncated document processing titles --- .../messages/test_document_processing.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/surfsense_backend/tests/unit/notifications/service/messages/test_document_processing.py b/surfsense_backend/tests/unit/notifications/service/messages/test_document_processing.py index 2f0a6a9d3..9fc93d3ed 100644 --- a/surfsense_backend/tests/unit/notifications/service/messages/test_document_processing.py +++ b/surfsense_backend/tests/unit/notifications/service/messages/test_document_processing.py @@ -61,3 +61,21 @@ def test_completion_failure(): assert message == "Processing failed: bad" assert status == "failed" assert meta["processing_stage"] == "failed" + + +def test_started_title_truncates_long_name(): + """Very long filenames are truncated to fit the notification title column.""" + long_name = "a" * 250 + title = msg.started_title(long_name) + assert len(title) <= 200 + assert title.startswith("Processing: ") + assert title.endswith("...") + + +def test_completion_truncates_long_name(): + """Completion titles truncate long document names.""" + long_name = "b" * 250 + title, _, _, _ = msg.completion(long_name, document_id=1) + assert len(title) <= 200 + assert title.startswith("Ready: ") + assert title.endswith("...")