diff options
| author | Mark Felder <feld@FreeBSD.org> | 2019-10-18 17:56:15 -0500 |
|---|---|---|
| committer | Mark Felder <feld@FreeBSD.org> | 2019-10-18 17:56:15 -0500 |
| commit | dcb23a85b6b05db4958b82ad14083cfa8577f477 (patch) | |
| tree | cc8197a3780fcab86a10b1055501ba570b8e0c3b /test/conversation | |
| parent | 152caef51d69ba4a47ac59346c782dfff8488f8b (diff) | |
| parent | 5c6c3026ea7bd20cb2c10f6e2e34a54734d2509e (diff) | |
| download | pleroma-dcb23a85b6b05db4958b82ad14083cfa8577f477.tar.gz pleroma-dcb23a85b6b05db4958b82ad14083cfa8577f477.zip | |
Merge branch 'develop' into feature/push-subject-for-dm
Diffstat (limited to 'test/conversation')
| -rw-r--r-- | test/conversation/participation_test.exs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/conversation/participation_test.exs b/test/conversation/participation_test.exs index f430bdf75..a5af0d1b2 100644 --- a/test/conversation/participation_test.exs +++ b/test/conversation/participation_test.exs @@ -23,6 +23,39 @@ defmodule Pleroma.Conversation.ParticipationTest do assert %Pleroma.Conversation{} = participation.conversation end + test "for a new conversation or a reply, it doesn't mark the author's participation as unread" do + user = insert(:user) + other_user = insert(:user) + + {:ok, _} = + CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"}) + + user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) + + [%{read: true}] = Participation.for_user(user) + [%{read: false} = participation] = Participation.for_user(other_user) + + assert User.get_cached_by_id(user.id).info.unread_conversation_count == 0 + assert User.get_cached_by_id(other_user.id).info.unread_conversation_count == 1 + + {:ok, _} = + CommonAPI.post(other_user, %{ + "status" => "Hey @#{user.nickname}.", + "visibility" => "direct", + "in_reply_to_conversation_id" => participation.id + }) + + user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) + + [%{read: false}] = Participation.for_user(user) + [%{read: true}] = Participation.for_user(other_user) + + assert User.get_cached_by_id(user.id).info.unread_conversation_count == 1 + assert User.get_cached_by_id(other_user.id).info.unread_conversation_count == 0 + end + test "for a new conversation, it sets the recipents of the participation" do user = insert(:user) other_user = insert(:user) @@ -32,7 +65,7 @@ defmodule Pleroma.Conversation.ParticipationTest do CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"}) user = User.get_cached_by_id(user.id) - other_user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) [participation] = Participation.for_user(user) participation = Pleroma.Repo.preload(participation, :recipients) |
