static-fe overhaul (#236)
[akkoma] / test / pleroma / web / static_fe / static_fe_controller_test.exs
index 5752cffda5f18b1f5c8fce7acbb787ed6eea234e..25ed6e193720ccbd52f3ef8b47ddf8412f60bd2b 100644 (file)
@@ -6,6 +6,8 @@ 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
@@ -42,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
@@ -53,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
@@ -67,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", %{
@@ -104,7 +165,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
       conn = get(conn, "/notice/#{activity.id}")
 
       html = html_response(conn, 200)
-      assert html =~ "<header>"
+      assert html =~ "<div class=\"panel conversation\">"
       assert html =~ user.nickname
       assert html =~ "testing a thing!"
     end