2019-05-21 10:39:32 +09:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-03 05:38:50 +09:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2019-05-21 10:39:32 +09:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.FallbackTest do
|
|
|
|
use Pleroma.Web.ConnCase
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
2020-11-12 01:10:59 +09:00
|
|
|
test "GET /*path adds a title", %{conn: conn} do
|
|
|
|
clear_config([:instance, :name], "a cool title")
|
|
|
|
|
|
|
|
assert conn
|
|
|
|
|> get("/")
|
|
|
|
|> html_response(200) =~ "<title>a cool title</title>"
|
|
|
|
end
|
|
|
|
|
2020-05-13 00:08:00 +09:00
|
|
|
describe "preloaded data and metadata attached to" do
|
2023-11-15 17:04:41 +09:00
|
|
|
test "GET /:maybe_nickname_or_id with existing user", %{conn: conn} do
|
2020-11-12 01:10:59 +09:00
|
|
|
clear_config([:instance, :name], "a cool title")
|
2020-05-13 00:08:00 +09:00
|
|
|
user = insert(:user)
|
2019-05-21 10:39:32 +09:00
|
|
|
|
2023-11-15 17:04:41 +09:00
|
|
|
resp = get(conn, "/#{user.nickname}")
|
|
|
|
|
|
|
|
assert html_response(resp, 200) =~ "<title>a cool title</title>"
|
|
|
|
refute html_response(resp, 200) =~ "<!--server-generated-meta-->"
|
|
|
|
assert html_response(resp, 200) =~ "initial-results"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /:maybe_nickname_or_id with missing user", %{conn: conn} do
|
|
|
|
clear_config([:instance, :name], "a cool title")
|
|
|
|
|
|
|
|
resp = get(conn, "/foo")
|
|
|
|
|
|
|
|
assert html_response(resp, 200) =~ "<title>a cool title</title>"
|
|
|
|
refute html_response(resp, 200) =~ "initial-results"
|
2020-06-02 23:18:06 +09:00
|
|
|
end
|
2019-05-21 10:39:32 +09:00
|
|
|
|
2020-06-02 23:18:06 +09:00
|
|
|
test "GET /*path", %{conn: conn} do
|
2023-11-15 17:04:41 +09:00
|
|
|
refute conn
|
2020-06-02 23:18:06 +09:00
|
|
|
|> get("/foo")
|
|
|
|
|> html_response(200) =~ "<!--server-generated-meta-->"
|
|
|
|
|
|
|
|
refute conn
|
|
|
|
|> get("/foo/bar")
|
|
|
|
|> html_response(200) =~ "<!--server-generated-meta-->"
|
2020-05-13 00:08:00 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-02 23:18:06 +09:00
|
|
|
describe "preloaded data is attached to" do
|
|
|
|
test "GET /main/public", %{conn: conn} do
|
2020-11-12 01:10:59 +09:00
|
|
|
clear_config([:instance, :name], "a cool title")
|
|
|
|
|
2020-05-13 00:08:00 +09:00
|
|
|
public_page = get(conn, "/main/public")
|
|
|
|
|
2020-06-02 23:18:06 +09:00
|
|
|
refute html_response(public_page, 200) =~ "<!--server-generated-meta-->"
|
|
|
|
assert html_response(public_page, 200) =~ "initial-results"
|
2020-11-12 01:10:59 +09:00
|
|
|
assert html_response(public_page, 200) =~ "<title>a cool title</title>"
|
2020-06-02 23:18:06 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /main/all", %{conn: conn} do
|
2023-11-15 17:04:41 +09:00
|
|
|
clear_config([:instance, :name], "a cool title")
|
2020-06-02 23:18:06 +09:00
|
|
|
public_page = get(conn, "/main/all")
|
|
|
|
|
|
|
|
refute html_response(public_page, 200) =~ "<!--server-generated-meta-->"
|
|
|
|
assert html_response(public_page, 200) =~ "initial-results"
|
2023-11-15 17:04:41 +09:00
|
|
|
assert html_response(public_page, 200) =~ "<title>a cool title</title>"
|
2020-05-13 00:08:00 +09:00
|
|
|
end
|
2019-05-21 10:39:32 +09:00
|
|
|
end
|
|
|
|
|
2019-05-21 10:40:29 +09:00
|
|
|
test "GET /api*path", %{conn: conn} do
|
|
|
|
assert conn
|
|
|
|
|> get("/api/foo")
|
|
|
|
|> json_response(404) == %{"error" => "Not implemented"}
|
|
|
|
end
|
|
|
|
|
2019-07-27 05:27:38 +09:00
|
|
|
test "GET /pleroma/admin -> /pleroma/admin/", %{conn: conn} do
|
|
|
|
assert redirected_to(get(conn, "/pleroma/admin")) =~ "/pleroma/admin/"
|
|
|
|
end
|
|
|
|
|
2019-05-21 10:39:32 +09:00
|
|
|
test "OPTIONS /*path", %{conn: conn} do
|
|
|
|
assert conn
|
|
|
|
|> options("/foo")
|
|
|
|
|> response(204) == ""
|
|
|
|
|
|
|
|
assert conn
|
|
|
|
|> options("/foo/bar")
|
|
|
|
|> response(204) == ""
|
|
|
|
end
|
|
|
|
end
|