diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/user_test.exs | 5 | ||||
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 2 | ||||
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 12 | ||||
-rw-r--r-- | test/web/mastodon_api/status_view_test.exs | 5 |
4 files changed, 19 insertions, 5 deletions
diff --git a/test/user_test.exs b/test/user_test.exs index 092cfc5dc..a0657c7b6 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -672,12 +672,13 @@ defmodule Pleroma.UserTest do "status" => "hey @#{addressed.nickname} @#{addressed_remote.nickname}" }) - assert [addressed] == User.get_recipients_from_activity(activity) + assert Enum.map([actor, addressed], & &1.ap_id) -- + Enum.map(User.get_recipients_from_activity(activity), & &1.ap_id) == [] {:ok, user} = User.follow(user, actor) {:ok, _user_two} = User.follow(user_two, actor) recipients = User.get_recipients_from_activity(activity) - assert length(recipients) == 2 + assert length(recipients) == 3 assert user in recipients assert addressed in recipients end diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 18f094379..d2e54d804 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -160,7 +160,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert activity.data["to"] == ["user1", "user2"] assert activity.actor == user.ap_id - assert activity.recipients == ["user1", "user2"] + assert activity.recipients == ["user1", "user2", user.ap_id] end end diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 8443dc856..6004285d6 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -148,7 +148,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert %{"id" => id, "visibility" => "direct"} = json_response(conn, 200) assert activity = Repo.get(Activity, id) - assert activity.recipients == [user2.ap_id] + assert activity.recipients == [user2.ap_id, user1.ap_id] assert activity.data["to"] == [user2.ap_id] assert activity.data["cc"] == [] end @@ -182,6 +182,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert %{"visibility" => "direct"} = status assert status["url"] != direct.data["id"] + # User should be able to see his own direct message + res_conn = + build_conn() + |> assign(:user, user_one) + |> get("api/v1/timelines/direct") + + [status] = json_response(res_conn, 200) + + assert %{"visibility" => "direct"} = status + # Both should be visible here res_conn = conn diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index e33479368..ebf6273e8 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -149,7 +149,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do status = StatusView.render("status.json", %{activity: activity}) - assert status.mentions == [AccountView.render("mention.json", %{user: user})] + actor = Repo.get_by(User, ap_id: activity.actor) + + assert status.mentions == + Enum.map([user, actor], fn u -> AccountView.render("mention.json", %{user: u}) end) end test "attachments" do |