import pytest from django.urls import reverse from review_agent.models import ( Conversation, FileSummaryBatch, RegulatoryReviewBatch, WorkflowNodeRun, ) pytestmark = pytest.mark.django_db def test_workspace_renders_regulatory_workflow_card(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-OK", status=FileSummaryBatch.Status.SUCCESS, ) regulatory = RegulatoryReviewBatch.objects.create( conversation=conversation, user=user, source_summary_batch=summary, batch_no="RR-CARD", status=RegulatoryReviewBatch.Status.SUCCESS, risk_summary={"blocking": 1, "high": 1}, ) WorkflowNodeRun.objects.create( workflow_type="regulatory_review", workflow_batch_id=regulatory.pk, node_group="regulatory_review", node_code="risk_assess", node_name="风险评估", status=WorkflowNodeRun.Status.SUCCESS, progress=100, ) client.force_login(user) response = client.get(f"{reverse('home')}?conversation={conversation.pk}") content = response.content.decode("utf-8") assert "RR-CARD" in content assert 'data-workflow-type="regulatory_review"' in content assert "阻断项 1" in content assert "风险评估" in content assert "data-regulatory-status-url-template" in content def test_frontend_selects_status_url_by_workflow_type(): script = open("static/js/app.js", encoding="utf-8").read() assert "workflow_type" in script assert "data-regulatory-status-url-template" in script assert "statusUrlForWorkflow" in script