Merge branch 'mark-converstation-as-read-on-new-direct-message' into 'develop'
[akkoma] / test / web / mastodon_api / views / account_view_test.exs
index 62b2ab7e36eb74a06de9df3bdd6416416ff392e7..ad209b4a34d8d20e1e24fa502d9ba2a67a4f55e0 100644 (file)
@@ -418,6 +418,27 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
                following_count: 1
              } = AccountView.render("show.json", %{user: user, for: user})
     end
+
+    test "shows unread_conversation_count only to the account owner" do
+      user = insert(:user)
+      other_user = insert(:user)
+
+      {:ok, _activity} =
+        CommonAPI.post(other_user, %{
+          "status" => "Hey @#{user.nickname}.",
+          "visibility" => "direct"
+        })
+
+      user = User.get_cached_by_ap_id(user.ap_id)
+
+      assert AccountView.render("show.json", %{user: user, for: other_user})[:pleroma][
+               :unread_conversation_count
+             ] == nil
+
+      assert AccountView.render("show.json", %{user: user, for: user})[:pleroma][
+               :unread_conversation_count
+             ] == 1
+    end
   end
 
   describe "follow requests counter" do