aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-08-02 19:53:08 +0200
committerlain <lain@soykaf.club>2019-08-02 19:53:08 +0200
commiteee98aaa738c1aa5f2e4203a61b67648d62965c8 (patch)
tree47a25c269f81a514359feffe6f3e16534717a73f /test
parent56b1c3af13c9519e13da688bdbbfdd8d69cda4ac (diff)
downloadpleroma-eee98aaa738c1aa5f2e4203a61b67648d62965c8.tar.gz
Pleroma API: Add endpoint to get conversation statuses.
Diffstat (limited to 'test')
-rw-r--r--test/web/common_api/common_api_utils_test.exs16
-rw-r--r--test/web/pleroma_api/pleroma_api_controller_test.exs45
2 files changed, 53 insertions, 8 deletions
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs
index af320f31f..7510c8def 100644
--- a/test/web/common_api/common_api_utils_test.exs
+++ b/test/web/common_api/common_api_utils_test.exs
@@ -239,7 +239,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
mentioned_user = insert(:user)
mentions = [mentioned_user.ap_id]
- {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "public")
+ {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "public", nil)
assert length(to) == 2
assert length(cc) == 1
@@ -256,7 +256,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
mentions = [mentioned_user.ap_id]
- {to, cc} = Utils.get_to_and_cc(user, mentions, activity, "public")
+ {to, cc} = Utils.get_to_and_cc(user, mentions, activity, "public", nil)
assert length(to) == 3
assert length(cc) == 1
@@ -272,7 +272,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
mentioned_user = insert(:user)
mentions = [mentioned_user.ap_id]
- {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "unlisted")
+ {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "unlisted", nil)
assert length(to) == 2
assert length(cc) == 1
@@ -289,7 +289,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
mentions = [mentioned_user.ap_id]
- {to, cc} = Utils.get_to_and_cc(user, mentions, activity, "unlisted")
+ {to, cc} = Utils.get_to_and_cc(user, mentions, activity, "unlisted", nil)
assert length(to) == 3
assert length(cc) == 1
@@ -305,7 +305,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
mentioned_user = insert(:user)
mentions = [mentioned_user.ap_id]
- {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "private")
+ {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "private", nil)
assert length(to) == 2
assert length(cc) == 0
@@ -321,7 +321,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
mentions = [mentioned_user.ap_id]
- {to, cc} = Utils.get_to_and_cc(user, mentions, activity, "private")
+ {to, cc} = Utils.get_to_and_cc(user, mentions, activity, "private", nil)
assert length(to) == 3
assert length(cc) == 0
@@ -336,7 +336,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
mentioned_user = insert(:user)
mentions = [mentioned_user.ap_id]
- {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "direct")
+ {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "direct", nil)
assert length(to) == 1
assert length(cc) == 0
@@ -351,7 +351,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
mentions = [mentioned_user.ap_id]
- {to, cc} = Utils.get_to_and_cc(user, mentions, activity, "direct")
+ {to, cc} = Utils.get_to_and_cc(user, mentions, activity, "direct", nil)
assert length(to) == 2
assert length(cc) == 0
diff --git a/test/web/pleroma_api/pleroma_api_controller_test.exs b/test/web/pleroma_api/pleroma_api_controller_test.exs
new file mode 100644
index 000000000..43104e36e
--- /dev/null
+++ b/test/web/pleroma_api/pleroma_api_controller_test.exs
@@ -0,0 +1,45 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
+ use Pleroma.Web.ConnCase
+
+ alias Pleroma.Conversation.Participation
+ alias Pleroma.Web.CommonAPI
+
+ import Pleroma.Factory
+
+ test "/api/v1/pleroma/conversations/:id/statuses", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+ third_user = insert(:user)
+
+ {:ok, _activity} =
+ CommonAPI.post(user, %{"status" => "Hi @#{third_user.nickname}!", "visibility" => "direct"})
+
+ {:ok, activity} =
+ CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}!", "visibility" => "direct"})
+
+ [participation] = Participation.for_user(other_user)
+
+ {:ok, activity_two} =
+ CommonAPI.post(other_user, %{
+ "status" => "Hi!",
+ "in_reply_to_status_id" => activity.id,
+ "in_reply_to_conversation_id" => participation.id
+ })
+
+ result =
+ conn
+ |> assign(:user, other_user)
+ |> get("/api/v1/pleroma/conversations/#{participation.id}/statuses")
+ |> json_response(200)
+
+ assert length(result) == 2
+
+ id_one = activity.id
+ id_two = activity_two.id
+ assert [%{"id" => ^id_one}, %{"id" => ^id_two}] = result
+ end
+end