feat(conversations): 支持删除对话并优化侧栏

This commit is contained in:
2026-06-08 21:39:38 +08:00
parent 2244b69d62
commit ef0a9ee13e
7 changed files with 918 additions and 17 deletions

View File

@@ -254,6 +254,33 @@ def test_conversation_list_api_returns_owned_conversations_with_attachment_count
assert payload["conversations"][0]["attachment_count"] == 1
def test_conversation_delete_api_removes_owned_conversation(client, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
other = django_user_model.objects.create_user(username="other", password="pass")
owned = Conversation.objects.create(user=user, title="待删除")
other_conversation = Conversation.objects.create(user=other, title="别人的会话")
client.force_login(user)
response = client.delete(reverse("review_agent_conversation_detail", args=[owned.pk]))
assert response.status_code == 200
assert response.json()["ok"] is True
assert not Conversation.objects.filter(pk=owned.pk).exists()
assert Conversation.objects.filter(pk=other_conversation.pk).exists()
def test_conversation_delete_api_rejects_unowned_conversation(client, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
other = django_user_model.objects.create_user(username="other", password="pass")
other_conversation = Conversation.objects.create(user=other, title="别人的会话")
client.force_login(user)
response = client.delete(reverse("review_agent_conversation_detail", args=[other_conversation.pk]))
assert response.status_code == 404
assert Conversation.objects.filter(pk=other_conversation.pk).exists()
def test_patch_attachment_updates_name_and_active_state(client, django_user_model):
user = django_user_model.objects.create_user(username="owner", password="pass")
conversation = Conversation.objects.create(user=user, title="会话")