summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-03-23 15:58:55 +0100
committerlain <lain@soykaf.club>2020-03-23 15:58:55 +0100
commiteec1fcaf55bdcbc2d3aed4eaf044bb8ef6c4effa (patch)
tree7ffb6355fe5c4194490b0e19e025093897d7fbfb
parent86f2fbc81e5f3df6c16e05127e9e39c8fca0cde9 (diff)
Home timeline tests: Add failing test for relationships
-rw-r--r--test/web/mastodon_api/controllers/timeline_controller_test.exs57
1 files changed, 53 insertions, 4 deletions
diff --git a/test/web/mastodon_api/controllers/timeline_controller_test.exs b/test/web/mastodon_api/controllers/timeline_controller_test.exs
index 6fedb4223..47849fc48 100644
--- a/test/web/mastodon_api/controllers/timeline_controller_test.exs
+++ b/test/web/mastodon_api/controllers/timeline_controller_test.exs
@@ -21,9 +21,12 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
setup do: oauth_access(["read:statuses"])
test "the home timeline", %{user: user, conn: conn} do
- following = insert(:user)
+ following = insert(:user, nickname: "followed")
+ third_user = insert(:user, nickname: "repeated")
- {:ok, _activity} = CommonAPI.post(following, %{"status" => "test"})
+ {:ok, _activity} = CommonAPI.post(following, %{"status" => "post"})
+ {:ok, activity} = CommonAPI.post(third_user, %{"status" => "repeated post"})
+ {:ok, _, _} = CommonAPI.repeat(activity.id, following)
ret_conn = get(conn, "/api/v1/timelines/home")
@@ -31,9 +34,55 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
{:ok, _user} = User.follow(user, following)
- conn = get(conn, "/api/v1/timelines/home")
+ ret_conn = get(conn, "/api/v1/timelines/home")
- assert [%{"content" => "test"}] = json_response(conn, :ok)
+ assert [
+ %{
+ "reblog" => %{
+ "content" => "repeated post",
+ "account" => %{
+ "pleroma" => %{
+ "relationship" => %{"following" => false, "followed_by" => false}
+ }
+ }
+ },
+ "account" => %{"pleroma" => %{"relationship" => %{"following" => true}}}
+ },
+ %{
+ "content" => "post",
+ "account" => %{
+ "acct" => "followed",
+ "pleroma" => %{"relationship" => %{"following" => true}}
+ }
+ }
+ ] = json_response(ret_conn, :ok)
+
+ {:ok, _user} = User.follow(third_user, user)
+
+ ret_conn = get(conn, "/api/v1/timelines/home")
+
+ assert [
+ %{
+ "reblog" => %{
+ "content" => "repeated post",
+ "account" => %{
+ "acct" => "repeated",
+ "pleroma" => %{
+ # This part does not match correctly
+ "relationship" => %{"following" => false, "followed_by" => true}
+ }
+ }
+ },
+ "account" => %{"pleroma" => %{"relationship" => %{"following" => true}}}
+ },
+ %{
+ "content" => "post",
+ "account" => %{
+ "acct" => "followed",
+ "pleroma" => %{"relationship" => %{"following" => true}}
+ }
+ }
+ ] = json_response(ret_conn, :ok)
end
test "the home timeline when the direct messages are excluded", %{user: user, conn: conn} do