+ test "it paginates", %{conn: conn} do
+ user = insert(:user)
+ recipient = insert(:user)
+
+ Enum.each(1..30, fn _ ->
+ {:ok, _} = CommonAPI.post_chat_message(user, recipient, "hey")
+ end)
+
+ chat = Chat.get(user.id, recipient.ap_id)
+
+ result =
+ conn
+ |> assign(:user, user)
+ |> get("/api/v1/pleroma/chats/#{chat.id}/messages")
+ |> json_response(200)
+
+ assert length(result) == 20
+
+ result =
+ conn
+ |> assign(:user, user)
+ |> get("/api/v1/pleroma/chats/#{chat.id}/messages", %{"max_id" => List.last(result)["id"]})
+ |> json_response(200)
+
+ assert length(result) == 10
+ end
+