67 lines
3.0 KiB
Python
67 lines
3.0 KiB
Python
from services.telegram_templates import triaged_alert
|
||
|
||
|
||
def test_ea_escalation_uses_structured_incident_brief():
|
||
msg, keyboard = triaged_alert(
|
||
base_event={
|
||
"event_type": "ea_escalation",
|
||
"title": "🐘 EA 升級審核 · 價格下滑警報",
|
||
"summary": "自主決策信心度 0.82 低於門檻,需人工批准",
|
||
"id": "ea_review_test",
|
||
},
|
||
tier_label="🐘 Elephant Alpha · L3 HITL",
|
||
ai_summary=(
|
||
"分析顯示 5 個代表性 SKU 的價格差異分別為 16.7%~38.3%,"
|
||
"且每件價差至多 370 元。"
|
||
),
|
||
ai_cause="觸發類型:價格下滑警報 | 信心度:0.82 | 參與模組:Hermes, NemoTron",
|
||
ai_actions=[
|
||
"[5900068] [derma Angel 護妍天使] 集中抗痘精華|"
|
||
"MOMO $300 vs PChome $250 (+16.7%)|"
|
||
"每件價差 NT$ 50|"
|
||
"建議人工確認 PChome identity_v2 後評估跟價或促銷|"
|
||
"PChome DABC53-A9009OEF",
|
||
"[3518670] L'Occitane 歐舒丹 官方直營 乳油木|"
|
||
"MOMO $1,220 vs PChome $850 (+30.3%)|"
|
||
"每件價差 NT$ 370|"
|
||
"建議人工確認 PChome identity_v2 後評估跟價或促銷|"
|
||
"PChome DDADKS-A900HIG5Y",
|
||
],
|
||
)
|
||
|
||
assert "🧭 <b>決策狀態</b>" in msg
|
||
assert "📊 <b>風險摘要</b>" in msg
|
||
assert "📋 <b>TOP 待審 SKU</b>" in msg
|
||
assert "✅ <b>建議處置</b>" in msg
|
||
assert "• 待審 SKU:<b>2</b> 件" in msg
|
||
assert "• 價差範圍:<b>+16.7%~+30.3%</b>" in msg
|
||
assert "• 最大單件價差:<b>NT$ 370</b>" in msg
|
||
assert "<b>1. [5900068]" in msg
|
||
assert "MOMO:<b>$300</b> PChome:<b>$250</b>" in msg
|
||
assert "PChome:<code>DABC53-A9009OEF</code>" in msg
|
||
assert " • [5900068]" not in msg
|
||
assert keyboard["inline_keyboard"][0][0]["callback_data"] == "momo:eig:ea_review_test"
|
||
|
||
|
||
def test_ea_escalation_generic_actions_do_not_render_as_sku_cards():
|
||
msg, _ = triaged_alert(
|
||
base_event={
|
||
"event_type": "ea_escalation",
|
||
"title": "🐘 EA 升級審核 · 程式碼異常偵測",
|
||
"summary": "低信心且缺少可格式化的具體行動",
|
||
"id": "ea_review_generic",
|
||
},
|
||
tier_label="🐘 Elephant Alpha · L3 HITL",
|
||
ai_summary="已隱藏 LLM plan 文字,避免把推測當成事實。",
|
||
ai_cause="觸發類型:程式碼異常偵測 | 信心度:0.62 | 缺少可直接審核的實證資料",
|
||
ai_actions=[
|
||
"檢查觸發條件:{\"scan_containers\": [\"momo-pro-system\"]}",
|
||
"不執行自動動作;請先在觀測台確認對應資料來源與最近錯誤紀錄。",
|
||
],
|
||
)
|
||
|
||
assert "📋 <b>待確認事項</b>" in msg
|
||
assert "📋 <b>TOP 待審 SKU</b>" not in msg
|
||
assert "• 待審 SKU" not in msg
|
||
assert "未取得實證前,不執行自動調價、修復或策略派發" in msg
|