diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2019-10-19 19:55:16 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2019-10-19 19:55:16 +0000 |
commit | cec4b00140ea67de5933357f46e9519271a074a9 (patch) | |
tree | cd96776891e12f87d59d55b5b98e277699b0136b /test/web/pleroma_api/controllers/pleroma_api_controller_test.exs | |
parent | 289f011e0aae5c6365e30bf0db533d597e48e702 (diff) | |
parent | 52ed2f8f2d962154ba61b31a3f5aab13dc7217fc (diff) | |
download | pleroma-cec4b00140ea67de5933357f46e9519271a074a9.tar.gz pleroma-cec4b00140ea67de5933357f46e9519271a074a9.zip |
Merge branch 'mark-all-conversations-as-read' into 'develop'
Pleroma API: `POST /api/v1/pleroma/conversations/read`
See merge request pleroma/pleroma!1830
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..9cccc8c8a 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).info.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).info.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) |