55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
import pytest
|
|
from django.urls import reverse
|
|
|
|
from review_agent.models import Conversation, Message
|
|
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
def test_workspace_renders_summary_panel(client, django_user_model):
|
|
user = django_user_model.objects.create_user(username="owner", password="pass")
|
|
conversation = Conversation.objects.create(user=user, title="会话")
|
|
Message.objects.create(
|
|
conversation=conversation,
|
|
role=Message.Role.ASSISTANT,
|
|
content="| 序号 | 文件名 |\n| --- | --- |\n| 1 | a.pdf |\n\n[下载](/api/review-agent/file-summary/exports/1/download/)",
|
|
)
|
|
client.force_login(user)
|
|
|
|
response = client.get(f"{reverse('home')}?conversation={conversation.pk}")
|
|
|
|
assert response.status_code == 200
|
|
content = response.content.decode("utf-8")
|
|
assert 'id="summaryPanel"' in content
|
|
assert 'id="uploadDropzone"' in content
|
|
assert 'id="workflowCardList"' in content
|
|
assert 'data-conversation-id="' in content
|
|
assert 'class="message-content markdown-content"' in content
|
|
assert 'class="message-raw"' in content
|
|
assert "自动汇总文件目录与页数" in content
|
|
|
|
|
|
def test_frontend_prevents_long_message_overflow():
|
|
css = open("static/css/login.css", encoding="utf-8").read()
|
|
|
|
assert ".message-bubble" in css
|
|
assert "overflow-wrap: anywhere" in css
|
|
assert "word-break: break-word" in css
|
|
|
|
|
|
def test_frontend_polls_running_workflow_cards():
|
|
script = open("static/js/app.js", encoding="utf-8").read()
|
|
|
|
assert "startWorkflowPolling" in script
|
|
assert "setInterval" in script
|
|
assert "refreshRunningWorkflowCards" in script
|
|
|
|
|
|
def test_frontend_updates_sidebar_conversation_by_stable_id():
|
|
script = open("static/js/app.js", encoding="utf-8").read()
|
|
|
|
assert "data-conversation-id" in script
|
|
assert "setAttribute(\"data-conversation-id\"" in script
|
|
assert ".history-item[data-conversation-id=" in script
|