fix(api): surface Work Item handoff in Telegram cards
All checks were successful
Code Review / ai-code-review (push) Successful in 15s
CD Pipeline / tests (push) Successful in 1m37s
CD Pipeline / build-and-deploy (push) Successful in 4m49s
CD Pipeline / post-deploy-checks (push) Successful in 1m34s

This commit is contained in:
Your Name
2026-06-25 23:19:26 +08:00
parent 558762a307
commit 4e81439386
3 changed files with 173 additions and 12 deletions

View File

@@ -1337,6 +1337,53 @@ async def test_build_inline_keyboard_hides_approval_for_no_action() -> None:
} in buttons
@pytest.mark.asyncio
async def test_build_inline_keyboard_links_work_item_for_no_action_handoff() -> None:
"""NO_ACTION 卡片要直接開 owner review Work Item不能只丟給人工找頁面。"""
gateway = TelegramGateway()
keyboard = await gateway._build_inline_keyboard(
approval_id="approval-no-repair-work-item",
include_auto_tuning=False,
incident_id="INC-20260625-977E5F",
suggested_action=(
"DRAFT_READY - REPAIR_CANDIDATE_OWNER_REVIEW_REQUIRED: "
"PlayBook 只有觀察或診斷步驟"
),
repair_candidate_work_item_href=(
"/awooop/work-items?project_id=awoooi"
"&incident_id=INC-20260625-977E5F"
"&work_item_id=repair-candidate-draft%3Aawoooi%3AINC-20260625-977E5F"
),
)
buttons = [
button
for row in keyboard["inline_keyboard"]
for button in row
]
button_texts = {button["text"] for button in buttons}
assert "✅ 批准" not in button_texts
assert "❌ 拒絕" not in button_texts
assert {
"text": "🧾 Work Item",
"url": (
"https://awoooi.wooo.work/zh-TW/awooop/work-items"
"?project_id=awoooi&incident_id=INC-20260625-977E5F"
"&work_item_id=repair-candidate-draft%3Aawoooi%3AINC-20260625-977E5F"
),
} in buttons
assert "🧰 處置包" in button_texts
assert "🔄 重診" in button_texts
assert {
"text": "🧭 Runs",
"url": (
"https://awoooi.wooo.work/zh-TW/awooop/runs"
"?project_id=awoooi&incident_id=INC-20260625-977E5F"
),
} in buttons
@pytest.mark.asyncio
async def test_send_request_strips_awooop_callback_metadata_before_telegram_api(monkeypatch):
"""AwoooP truth-chain metadata must be mirrored, not sent to Telegram Bot API."""