1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.FallbackTest do
6 use Pleroma.Web.ConnCase
9 describe "neither preloaded data nor metadata attached to" do
10 test "GET /registration/:token", %{conn: conn} do
11 response = get(conn, "/registration/foo")
13 assert html_response(response, 200) =~ "<!--server-generated-meta-->"
16 test "GET /*path", %{conn: conn} do
19 |> html_response(200) =~ "<!--server-generated-meta-->"
23 test "GET /*path adds a title", %{conn: conn} do
24 clear_config([:instance, :name], "a cool title")
28 |> html_response(200) =~ "<title>a cool title</title>"
31 describe "preloaded data and metadata attached to" do
32 test "GET /:maybe_nickname_or_id", %{conn: conn} do
33 clear_config([:instance, :name], "a cool title")
36 user_missing = get(conn, "/foo")
37 user_present = get(conn, "/#{user.nickname}")
39 assert html_response(user_missing, 200) =~ "<!--server-generated-meta-->"
40 refute html_response(user_present, 200) =~ "<!--server-generated-meta-->"
41 assert html_response(user_present, 200) =~ "initial-results"
42 assert html_response(user_present, 200) =~ "<title>a cool title</title>"
45 test "GET /*path", %{conn: conn} do
48 |> html_response(200) =~ "<!--server-generated-meta-->"
52 |> html_response(200) =~ "<!--server-generated-meta-->"
56 describe "preloaded data is attached to" do
57 test "GET /main/public", %{conn: conn} do
58 clear_config([:instance, :name], "a cool title")
60 public_page = get(conn, "/main/public")
62 refute html_response(public_page, 200) =~ "<!--server-generated-meta-->"
63 assert html_response(public_page, 200) =~ "initial-results"
64 assert html_response(public_page, 200) =~ "<title>a cool title</title>"
67 test "GET /main/all", %{conn: conn} do
68 public_page = get(conn, "/main/all")
70 refute html_response(public_page, 200) =~ "<!--server-generated-meta-->"
71 assert html_response(public_page, 200) =~ "initial-results"
75 test "GET /api*path", %{conn: conn} do
78 |> json_response(404) == %{"error" => "Not implemented"}
81 test "GET /pleroma/admin -> /pleroma/admin/", %{conn: conn} do
82 assert redirected_to(get(conn, "/pleroma/admin")) =~ "/pleroma/admin/"
85 test "OPTIONS /*path", %{conn: conn} do
88 |> response(204) == ""
91 |> options("/foo/bar")
92 |> response(204) == ""