summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/activity_test.exs14
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs2
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs38
-rw-r--r--test/web/twitter_api/twitter_api_test.exs2
4 files changed, 51 insertions, 5 deletions
diff --git a/test/activity_test.exs b/test/activity_test.exs
index ad889f544..dc9c56a21 100644
--- a/test/activity_test.exs
+++ b/test/activity_test.exs
@@ -28,4 +28,18 @@ defmodule Pleroma.ActivityTest do
assert activity == found_activity
end
+
+ test "reply count" do
+ %{id: id, data: %{"object" => %{"id" => object_ap_id}}} = activity = insert(:note_activity)
+
+ replies_count = activity.data["object"]["repliesCount"] || 0
+ expected_increase = replies_count + 1
+ Activity.increase_replies_count(object_ap_id)
+ %{data: %{"object" => %{"repliesCount" => actual_increase}}} = Activity.get_by_id(id)
+ assert expected_increase == actual_increase
+ expected_decrease = expected_increase - 1
+ Activity.decrease_replies_count(object_ap_id)
+ %{data: %{"object" => %{"repliesCount" => actual_decrease}}} = Activity.get_by_id(id)
+ assert expected_decrease == actual_decrease
+ end
end
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index 47cffe257..c857a7ec1 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -58,8 +58,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert returned_activity.data["object"]["inReplyToAtomUri"] ==
"https://shitposter.club/notice/2827873"
-
- assert returned_activity.data["object"]["inReplyToStatusId"] == activity.id
end
test "it works for incoming notices" do
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index 86c411f24..48dc8dd2f 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -342,7 +342,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
activity = Activity.get_by_id(id)
assert activity.data["context"] == replied_to.data["context"]
- assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
+ assert Activity.get_in_reply_to_activity(activity).id == replied_to.id
end
test "posting a status with an invalid in_reply_to_id", %{conn: conn} do
@@ -1620,6 +1620,40 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert id == to_string(other_user.id)
end
+ test "following / unfollowing errors" do
+ user = insert(:user)
+
+ conn =
+ build_conn()
+ |> assign(:user, user)
+
+ # self follow
+ conn_res = post(conn, "/api/v1/accounts/#{user.id}/follow")
+ assert %{"error" => "Record not found"} = json_response(conn_res, 404)
+
+ # self unfollow
+ user = User.get_cached_by_id(user.id)
+ conn_res = post(conn, "/api/v1/accounts/#{user.id}/unfollow")
+ assert %{"error" => "Record not found"} = json_response(conn_res, 404)
+
+ # self follow via uri
+ user = User.get_cached_by_id(user.id)
+ conn_res = post(conn, "/api/v1/follows", %{"uri" => user.nickname})
+ assert %{"error" => "Record not found"} = json_response(conn_res, 404)
+
+ # follow non existing user
+ conn_res = post(conn, "/api/v1/accounts/doesntexist/follow")
+ assert %{"error" => "Record not found"} = json_response(conn_res, 404)
+
+ # follow non existing user via uri
+ conn_res = post(conn, "/api/v1/follows", %{"uri" => "doesntexist"})
+ assert %{"error" => "Record not found"} = json_response(conn_res, 404)
+
+ # unfollow non existing user
+ conn_res = post(conn, "/api/v1/accounts/doesntexist/unfollow")
+ assert %{"error" => "Record not found"} = json_response(conn_res, 404)
+ end
+
test "muting / unmuting a user", %{conn: conn} do
user = insert(:user)
other_user = insert(:user)
@@ -2757,7 +2791,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
activity = Activity.get_by_id(id)
assert activity.data["object"]["inReplyTo"] == replied_to.data["object"]["id"]
- assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
+ assert Activity.get_in_reply_to_activity(activity).id == replied_to.id
# Reblog from the third user
conn2 =
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index 6d43bd13a..8781061d4 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -105,7 +105,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
get_in(activity.data, ["object", "context"])
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
- assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
+ assert Activity.get_in_reply_to_activity(reply).id == activity.id
end
test "Follow another user using user_id" do