from app.services.handoff_email_templates import ( build_mirror_handoff_html, build_mirror_handoff_text, external_reply_subject, format_sender_line, handoff_email_subject, ) from app.services.html_sanitizer import sanitize_email_html from app.services.mime_body_extractor import extract_mirror_content from app.services.thread_service import threading_fields_from_parent def test_mirror_template_is_minimal(): html = build_mirror_handoff_html( sender_line="091rabbytes@gmail.com", external_subject="lets try one more time", original_html="
one last attempt. i am tired
", agent_email="suyash@gentic.email", ) assert "LATEST MESSAGE" not in html assert "Why you" not in html assert "gentic-handoff-original" in html assert "one last attempt. i am tired" in html assert "✦ Human Handoff" in html assert "091rabbytes@gmail.com" in html assert "lets try one more time" in html def test_mirror_plain_text_template(): text = build_mirror_handoff_text( sender_line="091rabbytes@gmail.com", external_subject="lets try one more time", original_body_text="one last attempt. i am tired", agent_email="suyash@gentic.email", ) assert "one last attempt. i am tired" in text assert "LATEST MESSAGE" not in text assert "Reply normally" in text def test_format_sender_with_name(): assert ( format_sender_line({"name": "Rahul Sharma", "address": "rahul@example.com"}) == "Rahul SharmaHello