handoff fixes
This commit is contained in:
parent
3f4bcc26d9
commit
6c52cd19cb
8 changed files with 561 additions and 59 deletions
63
backend/tests/test_reply_extractor.py
Normal file
63
backend/tests/test_reply_extractor.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
from app.services.handoff_email_templates import external_reply_subject, handoff_email_subject
|
||||
from app.services.reply_extractor import extract_new_reply_content, validate_external_reply_body
|
||||
|
||||
SCREENSHOT_REPLY = """ahan, did you receive a response?
|
||||
|
||||
On Tue, Oct 6, 2026 at 2:11 AM <suyash@gentic.email> wrote:
|
||||
|
||||
> Human Handoff
|
||||
>
|
||||
> A conversation needs your attention.
|
||||
>
|
||||
> From
|
||||
> 091rabbytes@gmail.com
|
||||
>
|
||||
> Subject
|
||||
> are you ready?
|
||||
>
|
||||
> Latest message
|
||||
> "lets start a threaddddd"
|
||||
>
|
||||
> Why this was handed off
|
||||
> No handoff instructions were set, so this step passes.
|
||||
>
|
||||
> Reply to this email to respond to the original sender through suyash@gentic.email.
|
||||
>
|
||||
> Your reply will be sent to the customer.
|
||||
>
|
||||
> Gentic Human Handoff"""
|
||||
|
||||
|
||||
def test_extracts_new_reply_from_gmail_quote():
|
||||
result = extract_new_reply_content(body_text=SCREENSHOT_REPLY)
|
||||
assert result["new_reply_content"] == "ahan, did you receive a response?"
|
||||
assert "Human Handoff" in result["quoted_content"]
|
||||
assert "091rabbytes@gmail.com" in result["quoted_content"]
|
||||
|
||||
|
||||
def test_extracted_reply_passes_leakage_guard():
|
||||
result = extract_new_reply_content(body_text=SCREENSHOT_REPLY)
|
||||
assert validate_external_reply_body(result["new_reply_content"]) is True
|
||||
|
||||
|
||||
def test_leakage_guard_blocks_private_template():
|
||||
assert validate_external_reply_body(SCREENSHOT_REPLY) is False
|
||||
|
||||
|
||||
def test_external_reply_subject_uses_customer_subject():
|
||||
assert external_reply_subject("are you ready?") == "Re: are you ready?"
|
||||
assert external_reply_subject("Human Handoff · are you ready?") == "Re: are you ready?"
|
||||
|
||||
|
||||
def test_handoff_subject_format():
|
||||
assert handoff_email_subject("are you ready?") == "Human Handoff · are you ready?"
|
||||
|
||||
|
||||
def test_outlook_original_message_split():
|
||||
body = """Thanks for the update.
|
||||
|
||||
-----Original Message-----
|
||||
From: support@gentic.email
|
||||
Subject: Human Handoff"""
|
||||
result = extract_new_reply_content(body_text=body)
|
||||
assert result["new_reply_content"] == "Thanks for the update."
|
||||
Loading…
Add table
Add a link
Reference in a new issue