fix(training): 出国规章企微卡片改跳通用入口聊天页

This commit is contained in:
runny committed 2026-09-18 08:55:39 +08:00
1 parent 80d78130f8
commit 89a033f0f9
3 files changed
+72 -2

No files matched your search

+44
View File
@@ -305,6 +305,50 @@ def test_overseas_regulations_video_completion_sends_wecom_notice_each_time(clie
assert all(message["content"] == "中国员工出差泰国的行为准则" for message in sent_messages)
def test_overseas_regulations_wecom_notice_jumps_to_generic_entrance_chat(client, app, monkeypatch):
"""关键断言:出国规章完成的企微通知必须跳转「通用入口」聊天页(/chat/<id>),不得落入 /workspace 应用管理页。"""
sent_messages = []
monkeypatch.setattr(
training_service,
"send_wecom_event_message",
lambda **kwargs: sent_messages.append(kwargs) or {"ok": True, "trace_id": "training-notice-trace"},
)
with app.app_context():
user = _create_user(username="overseas_wecom_jump")
entrance_agent = Agent(
name="通用入口",
type="api",
agent_code="generic",
runtime_provider="dify",
conversation_mode="chat",
dify_app_type="chatflow",
handler_config={"content_profile": "generic_entrance"},
)
db.session.add(entrance_agent)
db.session.add(TrainingConfig(
training_type="overseas_jump_v1",
name="出国规章培训",
version="v1",
status="published",
))
db.session.commit()
entrance_agent_id = entrance_agent.id
response = client.put("/api/user/training-record/progress", headers=_auth_headers(user), json={
"type": "overseas_jump_v1",
"stage": "result",
"score": 100,
"passed": True,
"attempt_count": 0,
"answer_details": [],
})
assert response.status_code == 200
assert len(sent_messages) == 1
# [ASSERT] 卡片跳转路径必须指向通用入口聊天页,员工点击后进入图二页面而非应用管理工作台
assert sent_messages[0]["jump_path"] == f"/chat/{entrance_agent_id}"
def test_safety_training_progress_round_trip(client, app):
"""安全培训应持久化培训版本、考试模式、三级状态和级别进度。"""
with app.app_context():