diff options
author | Maxim Filippov <colixer@gmail.com> | 2019-10-27 16:11:25 +0300 |
---|---|---|
committer | Maxim Filippov <colixer@gmail.com> | 2019-10-27 16:11:25 +0300 |
commit | 791bcfd90f41da9d77ab5a5ad6eec22ae8050b8a (patch) | |
tree | 98ebe750f99cb6be2532e9dbaf3b334957353777 /test/web/pleroma_api/controllers/pleroma_api_controller_test.exs | |
parent | 8eff05d4c62c4d3300fee173cad84f75a0aafb4d (diff) | |
parent | 060adfd762a5183b3cc5f51e041819b24b8430d2 (diff) | |
download | pleroma-791bcfd90f41da9d77ab5a5ad6eec22ae8050b8a.tar.gz |
Merge branch 'develop' into feature/store-statuses-data-inside-flag
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.exs | 27 |
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 8a6528cbb..0c83edb56 100644 --- a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs +++ b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs @@ -95,6 +95,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) |