1 defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
2 use Pleroma.Web.ConnCase
3 alias Pleroma.Web.CommonAPI
6 clear_config_all([:static_fe, :enabled]) do
7 Pleroma.Config.put([:static_fe, :enabled], true)
10 describe "user profile page" do
11 test "just the profile as HTML", %{conn: conn} do
14 |> put_req_header("accept", "text/html")
15 |> get("/users/#{user.nickname}")
17 assert html_response(conn, 200) =~ user.nickname
20 test "renders json unless there's an html accept header", %{conn: conn} do
23 |> put_req_header("accept", "application/json")
24 |> get("/users/#{user.nickname}")
26 assert json_response(conn, 200)
29 test "404 when user not found", %{conn: conn} do
31 |> put_req_header("accept", "text/html")
32 |> get("/users/limpopo")
34 assert html_response(conn, 404) =~ "not found"
37 test "pagination", %{conn: conn} do
39 Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
41 |> put_req_header("accept", "text/html")
42 |> get("/users/#{user.nickname}")
43 html = html_response(conn, 200)
45 assert html =~ ">test30<"
46 assert html =~ ">test11<"
47 refute html =~ ">test10<"
48 refute html =~ ">test1<"
51 test "pagination, page 2", %{conn: conn} do
54 Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
55 {:ok, a11} = Enum.at(activities, 11)
57 |> put_req_header("accept", "text/html")
58 |> get("/users/#{user.nickname}?max_id=#{a11.id}")
59 html = html_response(conn, 200)
61 assert html =~ ">test1<"
62 assert html =~ ">test10<"
63 refute html =~ ">test20<"
64 refute html =~ ">test29<"
68 describe "notice rendering" do
69 test "single notice page", %{conn: conn} do
71 {:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
74 |> put_req_header("accept", "text/html")
75 |> get("/notice/#{activity.id}")
77 html = html_response(conn, 200)
78 assert html =~ "<header>"
79 assert html =~ user.nickname
80 assert html =~ "testing a thing!"
83 test "404 when notice not found", %{conn: conn} do
85 |> put_req_header("accept", "text/html")
86 |> get("/notice/88c9c317")
88 assert html_response(conn, 404) =~ "not found"