X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fpleroma_api%2Fcontrollers%2Fpleroma_api_controller_test.exs;h=593aa92b253713dc28c50e68551d109eb9ebd8e5;hb=7ac0cffb34567dd72877e13968a10d206f643ad8;hp=36868db38c9f96a28a8bd0ec2aa9865aea257e57;hpb=61d9f43e463a3b3b0c1e4b9c98c22e222797bd82;p=akkoma
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 36868db38..593aa92b2 100644
--- a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
+++ b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
@@ -41,7 +41,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
other_user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
- {:ok, activity, _object} = CommonAPI.react_with_emoji(activity.id, other_user, "â")
+ {:ok, activity} = CommonAPI.react_with_emoji(activity.id, other_user, "â")
result =
conn
@@ -71,8 +71,8 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
assert result == []
- {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, other_user, "ð
")
- {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, doomed_user, "ð
")
+ {:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "ð
")
+ {:ok, _} = CommonAPI.react_with_emoji(activity.id, doomed_user, "ð
")
User.perform(:delete, doomed_user)
@@ -96,6 +96,32 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
result
end
+ test "GET /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
+
+ result =
+ conn
+ |> get("/api/v1/pleroma/statuses/#{activity.id}/reactions/ð
")
+ |> json_response(200)
+
+ assert result == []
+
+ {:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "ð
")
+ {:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "â")
+
+ result =
+ conn
+ |> get("/api/v1/pleroma/statuses/#{activity.id}/reactions/ð
")
+ |> json_response(200)
+
+ [%{"name" => "ð
", "count" => 1, "accounts" => [represented_user], "me" => false}] = result
+
+ assert represented_user["id"] == other_user.id
+ end
+
test "/api/v1/pleroma/conversations/:id" do
user = insert(:user)
%{user: other_user, conn: conn} = oauth_access(["read:statuses"])
@@ -143,6 +169,23 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
id_one = activity.id
id_two = activity_two.id
assert [%{"id" => ^id_one}, %{"id" => ^id_two}] = result
+
+ {:ok, %{id: id_three}} =
+ CommonAPI.post(other_user, %{
+ "status" => "Bye!",
+ "in_reply_to_status_id" => activity.id,
+ "in_reply_to_conversation_id" => participation.id
+ })
+
+ assert [%{"id" => ^id_two}, %{"id" => ^id_three}] =
+ conn
+ |> get("/api/v1/pleroma/conversations/#{participation.id}/statuses?limit=2")
+ |> json_response(:ok)
+
+ assert [%{"id" => ^id_three}] =
+ conn
+ |> get("/api/v1/pleroma/conversations/#{participation.id}/statuses?min_id=#{id_two}")
+ |> json_response(:ok)
end
test "PATCH /api/v1/pleroma/conversations/:id" do
@@ -177,7 +220,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
test "POST /api/v1/pleroma/conversations/read" do
user = insert(:user)
- %{user: other_user, conn: conn} = oauth_access(["write:notifications"])
+ %{user: other_user, conn: conn} = oauth_access(["write:conversations"])
{:ok, _activity} =
CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})