1 defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
2 use Pleroma.Web.ConnCase
3 alias Pleroma.Web.ActivityPub.Transmogrifier
4 alias Pleroma.Web.CommonAPI
8 clear_config_all([:static_fe, :enabled]) do
9 Pleroma.Config.put([:static_fe, :enabled], true)
12 describe "user profile page" do
13 test "just the profile as HTML", %{conn: conn} do
18 |> put_req_header("accept", "text/html")
19 |> get("/users/#{user.nickname}")
21 assert html_response(conn, 200) =~ user.nickname
24 test "renders json unless there's an html accept header", %{conn: conn} do
29 |> put_req_header("accept", "application/json")
30 |> get("/users/#{user.nickname}")
32 assert json_response(conn, 200)
35 test "404 when user not found", %{conn: conn} do
38 |> put_req_header("accept", "text/html")
39 |> get("/users/limpopo")
41 assert html_response(conn, 404) =~ "not found"
44 test "profile does not include private messages", %{conn: conn} do
46 CommonAPI.post(user, %{"status" => "public"})
47 CommonAPI.post(user, %{"status" => "private", "visibility" => "private"})
51 |> put_req_header("accept", "text/html")
52 |> get("/users/#{user.nickname}")
54 html = html_response(conn, 200)
56 assert html =~ ">public<"
57 refute html =~ ">private<"
60 test "pagination", %{conn: conn} do
62 Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
66 |> put_req_header("accept", "text/html")
67 |> get("/users/#{user.nickname}")
69 html = html_response(conn, 200)
71 assert html =~ ">test30<"
72 assert html =~ ">test11<"
73 refute html =~ ">test10<"
74 refute html =~ ">test1<"
77 test "pagination, page 2", %{conn: conn} do
79 activities = Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
80 {:ok, a11} = Enum.at(activities, 11)
84 |> put_req_header("accept", "text/html")
85 |> get("/users/#{user.nickname}?max_id=#{a11.id}")
87 html = html_response(conn, 200)
89 assert html =~ ">test1<"
90 assert html =~ ">test10<"
91 refute html =~ ">test20<"
92 refute html =~ ">test29<"
96 describe "notice rendering" do
97 test "single notice page", %{conn: conn} do
99 {:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
103 |> put_req_header("accept", "text/html")
104 |> get("/notice/#{activity.id}")
106 html = html_response(conn, 200)
107 assert html =~ "<header>"
108 assert html =~ user.nickname
109 assert html =~ "testing a thing!"
112 test "shows the whole thread", %{conn: conn} do
114 {:ok, activity} = CommonAPI.post(user, %{"status" => "space: the final frontier"})
116 CommonAPI.post(user, %{
117 "status" => "these are the voyages or something",
118 "in_reply_to_status_id" => activity.id
123 |> put_req_header("accept", "text/html")
124 |> get("/notice/#{activity.id}")
126 html = html_response(conn, 200)
127 assert html =~ "the final frontier"
128 assert html =~ "voyages"
131 test "404 when notice not found", %{conn: conn} do
134 |> put_req_header("accept", "text/html")
135 |> get("/notice/88c9c317")
137 assert html_response(conn, 404) =~ "not found"
140 test "404 for private status", %{conn: conn} do
144 CommonAPI.post(user, %{"status" => "don't show me!", "visibility" => "private"})
148 |> put_req_header("accept", "text/html")
149 |> get("/notice/#{activity.id}")
151 assert html_response(conn, 404) =~ "not found"
154 test "404 for remote cached status", %{conn: conn} do
158 "@context" => "https://www.w3.org/ns/activitystreams",
159 "to" => user.follower_address,
160 "cc" => "https://www.w3.org/ns/activitystreams#Public",
163 "content" => "blah blah blah",
165 "attributedTo" => user.ap_id,
168 "actor" => user.ap_id
171 assert {:ok, activity} = Transmogrifier.handle_incoming(message)
175 |> put_req_header("accept", "text/html")
176 |> get("/notice/#{activity.id}")
178 assert html_response(conn, 404) =~ "not found"