diff options
author | lain <lain@soykaf.club> | 2019-11-08 13:27:11 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-11-08 13:27:11 +0100 |
commit | b22ee9d9666c49d1a3b1757b275e9d303eed4afc (patch) | |
tree | e7b4138a82c7382f2e2819f0a52481ec39cb12f3 /test/web/mastodon_api/controllers/timeline_controller_test.exs | |
parent | d7f9679ff2c9c4bd2b9967d7a32b5a4fe145305e (diff) | |
parent | 278674223d36f4d789dce92cd541c47b7e19b674 (diff) | |
download | pleroma-b22ee9d9666c49d1a3b1757b275e9d303eed4afc.tar.gz pleroma-b22ee9d9666c49d1a3b1757b275e9d303eed4afc.zip |
Merge remote-tracking branch 'origin/develop' into reactions
Diffstat (limited to 'test/web/mastodon_api/controllers/timeline_controller_test.exs')
-rw-r--r-- | test/web/mastodon_api/controllers/timeline_controller_test.exs | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/test/web/mastodon_api/controllers/timeline_controller_test.exs b/test/web/mastodon_api/controllers/timeline_controller_test.exs index d3652d964..61b6cea75 100644 --- a/test/web/mastodon_api/controllers/timeline_controller_test.exs +++ b/test/web/mastodon_api/controllers/timeline_controller_test.exs @@ -11,7 +11,6 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do alias Pleroma.Config alias Pleroma.User alias Pleroma.Web.CommonAPI - alias Pleroma.Web.OStatus clear_config([:instance, :public]) @@ -20,27 +19,52 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do :ok end - test "the home timeline", %{conn: conn} do - user = insert(:user) - following = insert(:user) + describe "home" do + test "the home timeline", %{conn: conn} do + user = insert(:user) + following = insert(:user) + + {:ok, _activity} = CommonAPI.post(following, %{"status" => "test"}) + + conn = + conn + |> assign(:user, user) + |> get("/api/v1/timelines/home") + + assert Enum.empty?(json_response(conn, :ok)) + + {:ok, user} = User.follow(user, following) + + conn = + build_conn() + |> assign(:user, user) + |> get("/api/v1/timelines/home") - {:ok, _activity} = CommonAPI.post(following, %{"status" => "test"}) + assert [%{"content" => "test"}] = json_response(conn, :ok) + end - conn = - conn - |> assign(:user, user) - |> get("/api/v1/timelines/home") + test "the home timeline when the direct messages are excluded", %{conn: conn} do + user = insert(:user) + {:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"}) + {:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"}) - assert Enum.empty?(json_response(conn, :ok)) + {:ok, unlisted_activity} = + CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"}) - {:ok, user} = User.follow(user, following) + {:ok, private_activity} = + CommonAPI.post(user, %{"status" => ".", "visibility" => "private"}) - conn = - build_conn() - |> assign(:user, user) - |> get("/api/v1/timelines/home") + conn = + conn + |> assign(:user, user) + |> get("/api/v1/timelines/home", %{"exclude_visibilities" => ["direct"]}) - assert [%{"content" => "test"}] = json_response(conn, :ok) + assert status_ids = json_response(conn, :ok) |> Enum.map(& &1["id"]) + assert public_activity.id in status_ids + assert unlisted_activity.id in status_ids + assert private_activity.id in status_ids + refute direct_activity.id in status_ids + end end describe "public" do @@ -50,8 +74,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do {:ok, _activity} = CommonAPI.post(following, %{"status" => "test"}) - {:ok, [_activity]} = - OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873") + _activity = insert(:note_activity, local: false) conn = get(conn, "/api/v1/timelines/public", %{"local" => "False"}) @@ -246,9 +269,6 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do {:ok, activity} = CommonAPI.post(following, %{"status" => "test #2hu"}) - {:ok, [_activity]} = - OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873") - nconn = get(conn, "/api/v1/timelines/tag/2hu") assert [%{"id" => id}] = json_response(nconn, :ok) |