X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fweb%2Fpleroma_api%2Fcontrollers%2Fpleroma_api_controller_test.exs;h=8bf7eb3be3384911d02a6e9a05010885cdee3bed;hb=b1c1d2e5e1e1c43a068a7223f9ba69c689c878a3;hp=be5007de52b00acbaa8a256b9a84693ec207a2fc;hpb=e84fee5b8624c8909ddd8a7e0d99c6beea4f54d0;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 be5007de5..8bf7eb3be 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
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
import Pleroma.Factory
- test "POST /api/v1/pleroma/statuses/:id/react_with_emoji", %{conn: conn} do
+ test "PUT /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
user = insert(:user)
other_user = insert(:user)
@@ -24,18 +24,19 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
conn
|> assign(:user, other_user)
|> assign(:token, insert(:oauth_token, user: other_user, scopes: ["write:statuses"]))
- |> post("/api/v1/pleroma/statuses/#{activity.id}/react_with_emoji", %{"emoji" => "â"})
+ |> put("/api/v1/pleroma/statuses/#{activity.id}/reactions/â")
|> json_response(200)
+ # We return the status, but this our implementation detail.
assert %{"id" => id} = result
assert to_string(activity.id) == id
assert result["pleroma"]["emoji_reactions"] == [
- %{"emoji" => "â", "count" => 1, "reacted" => true}
+ %{"name" => "â", "count" => 1, "me" => true}
]
end
- test "POST /api/v1/pleroma/statuses/:id/unreact_with_emoji", %{conn: conn} do
+ test "DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
user = insert(:user)
other_user = insert(:user)
@@ -46,7 +47,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
conn
|> assign(:user, other_user)
|> assign(:token, insert(:oauth_token, user: other_user, scopes: ["write:statuses"]))
- |> post("/api/v1/pleroma/statuses/#{activity.id}/unreact_with_emoji", %{"emoji" => "â"})
+ |> delete("/api/v1/pleroma/statuses/#{activity.id}/reactions/â")
assert %{"id" => id} = json_response(result, 200)
assert to_string(activity.id) == id
@@ -56,7 +57,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
assert object.data["reaction_count"] == 0
end
- test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do
+ test "GET /api/v1/pleroma/statuses/:id/reactions", %{conn: conn} do
user = insert(:user)
other_user = insert(:user)
doomed_user = insert(:user)
@@ -65,7 +66,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
result =
conn
- |> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
+ |> get("/api/v1/pleroma/statuses/#{activity.id}/reactions")
|> json_response(200)
assert result == []
@@ -77,11 +78,10 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
result =
conn
- |> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
+ |> get("/api/v1/pleroma/statuses/#{activity.id}/reactions")
|> json_response(200)
- [%{"emoji" => "ð
", "count" => 1, "accounts" => [represented_user], "reacted" => false}] =
- result
+ [%{"name" => "ð
", "count" => 1, "accounts" => [represented_user], "me" => false}] = result
assert represented_user["id"] == other_user.id
@@ -89,13 +89,39 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
conn
|> assign(:user, other_user)
|> assign(:token, insert(:oauth_token, user: other_user, scopes: ["read:statuses"]))
- |> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
+ |> get("/api/v1/pleroma/statuses/#{activity.id}/reactions")
|> json_response(200)
- assert [%{"emoji" => "ð
", "count" => 1, "accounts" => [_represented_user], "reacted" => true}] =
+ assert [%{"name" => "ð
", "count" => 1, "accounts" => [_represented_user], "me" => true}] =
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