Merge branch 'bugfix/mix.exs-version-dot-git-less' into 'develop'
[akkoma] / test / web / pleroma_api / controllers / chat_controller_test.exs
index 63cd89c735adedbf941ae164a62200e7c321a2d8..82e16741db325b457a61457c83db3a34679fee00 100644 (file)
@@ -43,30 +43,10 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
   describe "POST /api/v1/pleroma/chats/:id/read" do
     setup do: oauth_access(["write:chats"])
 
-    test "it marks all messages in a chat as read", %{conn: conn, user: user} do
-      other_user = insert(:user)
-
-      {:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
-      {:ok, _create} = CommonAPI.post_chat_message(other_user, user, "sup part 2")
-      {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id)
-      object = Object.normalize(create, false)
-      cm_ref = MessageReference.for_chat_and_object(chat, object)
-
-      assert cm_ref.unread == true
-
-      result =
-        conn
-        |> post("/api/v1/pleroma/chats/#{chat.id}/read")
-        |> json_response_and_validate_schema(200)
-
-      assert result["unread"] == 0
-
-      cm_ref = MessageReference.for_chat_and_object(chat, object)
-
-      assert cm_ref.unread == false
-    end
-
-    test "it given a `last_read_id` ", %{conn: conn, user: user} do
+    test "given a `last_read_id`, it marks everything until then as read", %{
+      conn: conn,
+      user: user
+    } do
       other_user = insert(:user)
 
       {:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup")
@@ -309,7 +289,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
       assert length(result) == 0
     end
 
-    test "it paginates", %{conn: conn, user: user} do
+    test "it returns all chats", %{conn: conn, user: user} do
       Enum.each(1..30, fn _ ->
         recipient = insert(:user)
         {:ok, _} = Chat.get_or_create(user.id, recipient.ap_id)
@@ -320,14 +300,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
         |> get("/api/v1/pleroma/chats")
         |> json_response_and_validate_schema(200)
 
-      assert length(result) == 20
-
-      result =
-        conn
-        |> get("/api/v1/pleroma/chats?max_id=#{List.last(result)["id"]}")
-        |> json_response_and_validate_schema(200)
-
-      assert length(result) == 10
+      assert length(result) == 30
     end
 
     test "it return a list of chats the current user is participating in, in descending order of updates",