X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fadmin_api%2Fcontrollers%2Ffrontend_controller_test.exs;h=c84624affe0a837d5791f3247575392197b15c74;hb=07a48b9293e4046c50b5d424d60a1bf16c7cc198;hp=94873f6dbc9afa4e5657eac3f04ddbdadec090eb;hpb=6cd0586ef9f1991655c7736479a9a1fb39f4098c;p=akkoma
diff --git a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
index 94873f6db..c84624aff 100644
--- a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
@@ -30,11 +30,25 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
{:ok, %{admin: admin, token: token, conn: conn}}
end
- describe "GET /api/pleroma/admin/frontends" do
+ describe "GET /api/v1/pleroma/admin/frontends" do
test "it lists available frontends", %{conn: conn} do
response =
conn
- |> get("/api/pleroma/admin/frontends")
+ |> get("/api/v1/pleroma/admin/frontends")
+ |> json_response_and_validate_schema(:ok)
+
+ assert Enum.map(response, & &1["name"]) ==
+ Enum.map(Config.get([:frontends, :available]), fn {_, map} -> map["name"] end)
+
+ refute Enum.any?(response, fn frontend -> frontend["installed"] == true end)
+ end
+
+ test "it lists available frontends when no frontend folder was created yet", %{conn: conn} do
+ File.rm_rf(@dir)
+
+ response =
+ conn
+ |> get("/api/v1/pleroma/admin/frontends")
|> json_response_and_validate_schema(:ok)
assert Enum.map(response, & &1["name"]) ==
@@ -44,7 +58,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
end
end
- describe "POST /api/pleroma/admin/frontends/install" do
+ describe "POST /api/v1/pleroma/admin/frontends/install" do
test "from available frontends", %{conn: conn} do
clear_config([:frontends, :available], %{
"pleroma" => %{
@@ -60,14 +74,14 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
conn
|> put_req_header("content-type", "application/json")
- |> post("/api/pleroma/admin/frontends/install", %{name: "pleroma"})
+ |> post("/api/v1/pleroma/admin/frontends/install", %{name: "pleroma"})
|> json_response_and_validate_schema(:ok)
assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
response =
conn
- |> get("/api/pleroma/admin/frontends")
+ |> get("/api/v1/pleroma/admin/frontends")
|> json_response_and_validate_schema(:ok)
assert response == [
@@ -92,7 +106,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
conn
|> put_req_header("content-type", "application/json")
- |> post("/api/pleroma/admin/frontends/install", %{
+ |> post("/api/v1/pleroma/admin/frontends/install", %{
name: "pleroma",
file: "test/fixtures/tesla_mock/frontend.zip"
})
@@ -108,7 +122,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
conn
|> put_req_header("content-type", "application/json")
- |> post("/api/pleroma/admin/frontends/install", %{
+ |> post("/api/v1/pleroma/admin/frontends/install", %{
name: "unknown",
ref: "baka",
build_url: "http://gensokyo.2hu/madeup.zip",
@@ -127,7 +141,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
result =
conn
|> put_req_header("content-type", "application/json")
- |> post("/api/pleroma/admin/frontends/install", %{
+ |> post("/api/v1/pleroma/admin/frontends/install", %{
name: "unknown",
ref: "baka",
build_url: "http://gensokyo.2hu/madeup.zip",