fix(awooop): mirror telegram outbound messages
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 1m4s
CD Pipeline / build-and-deploy (push) Successful in 3m57s
CD Pipeline / post-deploy-checks (push) Successful in 1m27s

This commit is contained in:
Your Name
2026-05-07 00:23:32 +08:00
parent 012cd27b4a
commit 9365bdab93
4 changed files with 139 additions and 0 deletions

View File

@@ -231,6 +231,43 @@ async def test_append_incident_update_suppresses_duplicate_failure_across_incide
]
def test_outbound_message_type_inference():
"""Legacy Telegram 訊息 mirror 到 Channel Hub 時,必須映射成有限分類。"""
assert (
telegram_gateway_module._infer_outbound_message_type(
" ACTION REQUIRED | 低風險",
{"reply_markup": {"inline_keyboard": []}},
)
== "approval_request"
)
assert (
telegram_gateway_module._infer_outbound_message_type(
"🤖❌ [AUTO] AI 自動修復失敗",
{"reply_to_message_id": 123},
)
== "error"
)
assert (
telegram_gateway_module._infer_outbound_message_type(
"✅ 執行成功",
{"reply_to_message_id": 123},
)
== "final"
)
def test_legacy_outbound_run_id_is_stable():
"""沒有正式 run_id 的 legacy Telegram 發送,要有穩定 soft run_id 供查詢串接。"""
first = telegram_gateway_module._legacy_outbound_run_id("-1001", "42")
second = telegram_gateway_module._legacy_outbound_run_id("-1001", "42")
other = telegram_gateway_module._legacy_outbound_run_id("-1001", "43")
assert first == second
assert first != other
class TestSentryErrorMessage:
"""測試 Sentry 錯誤訊息"""