feat: show feishu notification status

This commit is contained in:
2026-06-07 22:13:56 +08:00
parent cbc7493df8
commit 1a1b3ee9d4
9 changed files with 191 additions and 5 deletions

View File

@@ -46,3 +46,32 @@ def test_frontend_selects_application_form_fill_status_url_and_terminal_status()
assert 'workflow_type === "application_form_fill"' in script
assert "data-application-form-fill-status-url-template" in script
assert 'status === "partial_success"' in script
def test_application_form_fill_status_includes_no_feishu_notification(client, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")
summary = FileSummaryBatch.objects.create(conversation=conversation, user=user, batch_no="FS-AFF")
batch = ApplicationFormFillBatch.objects.create(
conversation=conversation,
user=user,
source_summary_batch=summary,
batch_no="AFF-FEISHU",
)
client.force_login(user)
response = client.get(f"/api/review-agent/application-form-fill/{batch.pk}/status/")
payload = response.json()
assert payload["latest_notification"] is None
assert payload["notifications"] == []
def test_frontend_renders_feishu_notification_status():
script = open("static/js/app.js", encoding="utf-8").read()
css = open("static/css/login.css", encoding="utf-8").read()
assert "renderNotificationSummary" in script
assert "暂无飞书通知记录" in script
assert "workflow-notification" in script
assert ".workflow-notification" in css

View File

@@ -1,7 +1,7 @@
import pytest
from django.urls import reverse
from review_agent.models import Conversation, FileAttachment, FileSummaryBatch, Message, WorkflowNodeRun
from review_agent.models import Conversation, FileAttachment, FileSummaryBatch, Message, WorkflowNodeRun, WorkflowNotificationRecord
pytestmark = pytest.mark.django_db
@@ -223,6 +223,31 @@ def test_frontend_renders_workflow_error_messages():
assert ".workflow-error" in css
def test_file_summary_status_includes_feishu_notification(client, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")
batch = FileSummaryBatch.objects.create(conversation=conversation, user=user, batch_no="FS-FEISHU")
WorkflowNotificationRecord.objects.create(
workflow_type="file_summary",
workflow_batch_id=batch.pk,
workflow_batch_no=batch.batch_no,
workflow_status=batch.status,
dedupe_key=f"file_summary:{batch.pk}:{batch.status}",
trigger_user=user,
channel=WorkflowNotificationRecord.Channel.FEISHU_API,
target="负责人",
send_status=WorkflowNotificationRecord.SendStatus.SUCCESS,
message_title="自动汇总完成",
)
client.force_login(user)
response = client.get(f"/api/review-agent/file-summary/{batch.pk}/status/")
payload = response.json()
assert payload["latest_notification"]["status_label"] == "飞书通知已发送"
assert payload["notifications"][0]["target"] == "负责人"
def test_frontend_renders_workflow_batches_as_carousel():
script = open("static/js/app.js", encoding="utf-8").read()
css = open("static/css/login.css", encoding="utf-8").read()

View File

@@ -8,6 +8,7 @@ from review_agent.models import (
RegulatoryArtifact,
RegulatoryNotificationRecord,
RegulatoryReviewBatch,
WorkflowNotificationRecord,
WorkflowNodeRun,
)
@@ -230,3 +231,35 @@ def test_frontend_keeps_single_condition_confirmation_prompt():
assert "data-condition-confirmation-card" in script
assert "removeStaleConditionConfirmationCards" in script
assert '[data-condition-confirmation-card]' in script
def test_regulatory_status_includes_failed_feishu_notification(client, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")
summary = FileSummaryBatch.objects.create(conversation=conversation, user=user, batch_no="FS-RR")
batch = RegulatoryReviewBatch.objects.create(
conversation=conversation,
user=user,
source_summary_batch=summary,
batch_no="RR-FEISHU",
)
WorkflowNotificationRecord.objects.create(
workflow_type="regulatory_review",
workflow_batch_id=batch.pk,
workflow_batch_no=batch.batch_no,
workflow_status=batch.status,
dedupe_key=f"regulatory_review:{batch.pk}:{batch.status}",
trigger_user=user,
channel=WorkflowNotificationRecord.Channel.FEISHU_API,
target="负责人",
send_status=WorkflowNotificationRecord.SendStatus.FAILED,
message_title="法规核查完成",
error_message="bad receive_id",
)
client.force_login(user)
response = client.get(f"/api/review-agent/regulatory-review/{batch.pk}/status/")
payload = response.json()
assert payload["latest_notification"]["status_label"] == "飞书通知失败"
assert payload["latest_notification"]["error_message"] == "bad receive_id"