Merge branch 'rich-media-parser-exclude-attachment-links' into 'develop'
[akkoma] / test / web / mastodon_api / controllers / timeline_controller_test.exs
index 3474c0cf949ba4b614dcb06c7501ea8f28817311..f069390c11aca746b8b0acf11898199cf72e9d68 100644 (file)
@@ -60,9 +60,9 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
   describe "public" do
     @tag capture_log: true
     test "the public timeline", %{conn: conn} do
-      following = insert(:user)
+      user = insert(:user)
 
-      {:ok, _activity} = CommonAPI.post(following, %{status: "test"})
+      {:ok, activity} = CommonAPI.post(user, %{status: "test"})
 
       _activity = insert(:note_activity, local: false)
 
@@ -77,6 +77,13 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       conn = get(build_conn(), "/api/v1/timelines/public?local=1")
 
       assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok)
+
+      # does not contain repeats
+      {:ok, _} = CommonAPI.repeat(activity.id, user)
+
+      conn = get(build_conn(), "/api/v1/timelines/public?local=true")
+
+      assert [_] = json_response_and_validate_schema(conn, :ok)
     end
 
     test "the public timeline includes only public statuses for an authenticated user" do
@@ -111,7 +118,6 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       [%{"id" => ^activity_id}] = json_response_and_validate_schema(res_conn, 200)
     end
 
-    # TODO: update after benchmarks
     test "doesn't return replies if follow is posting with users from blocked domain" do
       %{conn: conn, user: blocker} = oauth_access(["read:statuses"])
       friend = insert(:user)
@@ -129,31 +135,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       {:ok, _reply_from_friend} =
         CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee})
 
-      res_conn = get(conn, "/api/v1/timelines/public?method=fun")
-
-      activities = json_response_and_validate_schema(res_conn, 200)
-      [%{"id" => ^activity_id}] = activities
-    end
-
-    # TODO: update after benchmarks
-    test "doesn't return replies if follow is posting with users from blocked domain with unnest param" do
-      %{conn: conn, user: blocker} = oauth_access(["read:statuses"])
-      friend = insert(:user)
-      blockee = insert(:user, ap_id: "https://example.com/users/blocked")
-      {:ok, blocker} = User.follow(blocker, friend)
-      {:ok, blocker} = User.block_domain(blocker, "example.com")
-
-      conn = assign(conn, :user, blocker)
-
-      {:ok, %{id: activity_id} = activity} = CommonAPI.post(friend, %{status: "hey!"})
-
-      {:ok, reply_from_blockee} =
-        CommonAPI.post(blockee, %{status: "heya", in_reply_to_status_id: activity})
-
-      {:ok, _reply_from_friend} =
-        CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee})
-
-      res_conn = get(conn, "/api/v1/timelines/public?method=unnest")
+      res_conn = get(conn, "/api/v1/timelines/public")
 
       activities = json_response_and_validate_schema(res_conn, 200)
       [%{"id" => ^activity_id}] = activities