X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fstatic_fe%2Fstatic_fe_controller_test.exs;h=25ed6e193720ccbd52f3ef8b47ddf8412f60bd2b;hb=7c4b415929cfef17c409eab095b8e1eb956607cc;hp=19506f1d8622996fba7c26ede5def15051253bc6;hpb=6163fbf55328808d90bb1a84cf05ae986f941b31;p=akkoma diff --git a/test/pleroma/web/static_fe/static_fe_controller_test.exs b/test/pleroma/web/static_fe/static_fe_controller_test.exs index 19506f1d8..25ed6e193 100644 --- a/test/pleroma/web/static_fe/static_fe_controller_test.exs +++ b/test/pleroma/web/static_fe/static_fe_controller_test.exs @@ -1,12 +1,15 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do use Pleroma.Web.ConnCase alias Pleroma.Activity + alias Pleroma.User + alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Transmogrifier + alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.CommonAPI import Pleroma.Factory @@ -41,8 +44,67 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do html = html_response(conn, 200) - assert html =~ ">public<" - refute html =~ ">private<" + assert html =~ "\npublic\n" + refute html =~ "\nprivate\n" + end + + test "main page does not include replies", %{conn: conn, user: user} do + {:ok, op} = CommonAPI.post(user, %{status: "beep"}) + CommonAPI.post(user, %{status: "boop", in_reply_to_id: op}) + + conn = get(conn, "/users/#{user.nickname}") + + html = html_response(conn, 200) + + assert html =~ "\nbeep\n" + refute html =~ "\nboop\n" + end + + test "media page only includes posts with attachments", %{conn: conn, user: user} do + file = %Plug.Upload{ + content_type: "image/jpeg", + path: Path.absname("test/fixtures/image.jpg"), + filename: "an_image.jpg" + } + + {:ok, %{id: media_id}} = ActivityPub.upload(file, actor: user.ap_id) + + CommonAPI.post(user, %{status: "virgin text post"}) + CommonAPI.post(user, %{status: "chad post with attachment", media_ids: [media_id]}) + + conn = get(conn, "/users/#{user.nickname}/media") + + html = html_response(conn, 200) + + assert html =~ "\nchad post with attachment\n" + refute html =~ "\nvirgin text post\n" + end + + test "show follower list", %{conn: conn, user: user} do + follower = insert(:user) + CommonAPI.follow(follower, user) + + conn = get(conn, "/users/#{user.nickname}/followers") + + html = html_response(conn, 200) + + assert html =~ "user-card" + end + + test "don't show followers if hidden", %{conn: conn, user: user} do + follower = insert(:user) + CommonAPI.follow(follower, user) + + {:ok, user} = + user + |> User.update_changeset(%{hide_followers: true}) + |> User.update_and_set_cache() + + conn = get(conn, "/users/#{user.nickname}/followers") + + html = html_response(conn, 200) + + refute html =~ "user-card" end test "pagination", %{conn: conn, user: user} do @@ -52,10 +114,10 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do html = html_response(conn, 200) - assert html =~ ">test30<" - assert html =~ ">test11<" - refute html =~ ">test10<" - refute html =~ ">test1<" + assert html =~ "\ntest30\n" + assert html =~ "\ntest11\n" + refute html =~ "\ntest10\n" + refute html =~ "\ntest1\n" end test "pagination, page 2", %{conn: conn, user: user} do @@ -66,10 +128,10 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do html = html_response(conn, 200) - assert html =~ ">test1<" - assert html =~ ">test10<" - refute html =~ ">test20<" - refute html =~ ">test29<" + assert html =~ "\ntest1\n" + assert html =~ "\ntest10\n" + refute html =~ "\ntest20\n" + refute html =~ "\ntest29\n" end test "does not require authentication on non-federating instances", %{ @@ -103,7 +165,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do conn = get(conn, "/notice/#{activity.id}") html = html_response(conn, 200) - assert html =~ "
" + assert html =~ "
" assert html =~ user.nickname assert html =~ "testing a thing!" end @@ -185,16 +247,16 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do test "302 for remote cached status", %{conn: conn, user: user} do message = %{ "@context" => "https://www.w3.org/ns/activitystreams", - "to" => user.follower_address, - "cc" => "https://www.w3.org/ns/activitystreams#Public", "type" => "Create", + "actor" => user.ap_id, "object" => %{ + "to" => user.follower_address, + "cc" => "https://www.w3.org/ns/activitystreams#Public", + "id" => Utils.generate_object_id(), "content" => "blah blah blah", "type" => "Note", - "attributedTo" => user.ap_id, - "inReplyTo" => nil - }, - "actor" => user.ap_id + "attributedTo" => user.ap_id + } } assert {:ok, activity} = Transmogrifier.handle_incoming(message)