summaryrefslogtreecommitdiff
path: root/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-11-08 13:27:11 +0100
committerlain <lain@soykaf.club>2019-11-08 13:27:11 +0100
commitb22ee9d9666c49d1a3b1757b275e9d303eed4afc (patch)
treee7b4138a82c7382f2e2819f0a52481ec39cb12f3 /test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
parentd7f9679ff2c9c4bd2b9967d7a32b5a4fe145305e (diff)
parent278674223d36f4d789dce92cd541c47b7e19b674 (diff)
downloadpleroma-b22ee9d9666c49d1a3b1757b275e9d303eed4afc.tar.gz
pleroma-b22ee9d9666c49d1a3b1757b275e9d303eed4afc.zip
Merge remote-tracking branch 'origin/develop' into reactions
Diffstat (limited to 'test/web/pleroma_api/controllers/pleroma_api_controller_test.exs')
-rw-r--r--test/web/pleroma_api/controllers/pleroma_api_controller_test.exs27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
index 44ea85b45..b1b59beed 100644
--- a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
+++ b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
@@ -155,6 +155,33 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
assert other_user in participation.recipients
end
+ test "POST /api/v1/pleroma/conversations/read", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, _activity} =
+ CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
+
+ {:ok, _activity} =
+ CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
+
+ [participation2, participation1] = Participation.for_user(other_user)
+ assert Participation.get(participation2.id).read == false
+ assert Participation.get(participation1.id).read == false
+ assert User.get_cached_by_id(other_user.id).unread_conversation_count == 2
+
+ [%{"unread" => false}, %{"unread" => false}] =
+ conn
+ |> assign(:user, other_user)
+ |> post("/api/v1/pleroma/conversations/read", %{})
+ |> json_response(200)
+
+ [participation2, participation1] = Participation.for_user(other_user)
+ assert Participation.get(participation2.id).read == true
+ assert Participation.get(participation1.id).read == true
+ assert User.get_cached_by_id(other_user.id).unread_conversation_count == 0
+ end
+
describe "POST /api/v1/pleroma/notifications/read" do
test "it marks a single notification as read", %{conn: conn} do
user1 = insert(:user)