aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/frontend_test.exs22
-rw-r--r--test/pleroma/web/admin_api/controllers/frontend_controller_test.exs52
2 files changed, 58 insertions, 16 deletions
diff --git a/test/pleroma/frontend_test.exs b/test/pleroma/frontend_test.exs
index 77913b223..223625857 100644
--- a/test/pleroma/frontend_test.exs
+++ b/test/pleroma/frontend_test.exs
@@ -6,8 +6,6 @@ defmodule Pleroma.FrontendTest do
use Pleroma.DataCase
alias Pleroma.Frontend
- import ExUnit.CaptureIO, only: [capture_io: 1]
-
@dir "test/frontend_static_test"
setup do
@@ -32,9 +30,7 @@ defmodule Pleroma.FrontendTest do
%Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/frontend_dist.zip")}
end)
- capture_io(fn ->
- Frontend.install("pleroma")
- end)
+ Frontend.install("pleroma")
assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
end
@@ -54,9 +50,7 @@ defmodule Pleroma.FrontendTest do
File.write!(previously_existing, "yey")
assert File.exists?(previously_existing)
- capture_io(fn ->
- Frontend.install("pleroma", file: "test/fixtures/tesla_mock/frontend.zip")
- end)
+ Frontend.install("pleroma", file: "test/fixtures/tesla_mock/frontend.zip")
assert File.exists?(Path.join([folder, "test.txt"]))
refute File.exists?(previously_existing)
@@ -67,13 +61,11 @@ defmodule Pleroma.FrontendTest do
%Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/frontend.zip")}
end)
- capture_io(fn ->
- Frontend.install("unknown",
- ref: "baka",
- build_url: "http://gensokyo.2hu/madeup.zip",
- build_dir: ""
- )
- end)
+ Frontend.install("unknown",
+ ref: "baka",
+ build_url: "http://gensokyo.2hu/madeup.zip",
+ build_dir: ""
+ )
assert File.exists?(Path.join([@dir, "frontends", "unknown", "baka", "test.txt"]))
end
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 461d6e5c9..afe82ddf5 100644
--- a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
@@ -48,7 +48,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
end
describe "POST /api/pleroma/admin/frontends" do
- test "it installs a frontend", %{conn: conn} do
+ test "from available frontends", %{conn: conn} do
clear_config([:frontends, :available], %{
"pleroma" => %{
"ref" => "fantasy",
@@ -90,5 +90,55 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
}
]
end
+
+ test "from a file", %{conn: conn} do
+ clear_config([:frontends, :available], %{
+ "pleroma" => %{
+ "ref" => "fantasy",
+ "name" => "pleroma",
+ "build_dir" => ""
+ }
+ })
+
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/pleroma/admin/frontends", %{
+ name: "pleroma",
+ file: "test/fixtures/tesla_mock/frontend.zip"
+ })
+ |> json_response_and_validate_schema(:ok)
+
+ assert_enqueued(
+ worker: FrontendInstallerWorker,
+ args: %{
+ "name" => "pleroma",
+ "opts" => %{"file" => "test/fixtures/tesla_mock/frontend.zip"}
+ }
+ )
+
+ ObanHelpers.perform(all_enqueued(worker: FrontendInstallerWorker))
+
+ assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
+ end
+
+ test "from an URL", %{conn: conn} do
+ Tesla.Mock.mock(fn %{url: "http://gensokyo.2hu/madeup.zip"} ->
+ %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/frontend.zip")}
+ end)
+
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/pleroma/admin/frontends", %{
+ name: "unknown",
+ ref: "baka",
+ build_url: "http://gensokyo.2hu/madeup.zip",
+ build_dir: ""
+ })
+ |> json_response_and_validate_schema(:ok)
+
+ ObanHelpers.perform(all_enqueued(worker: FrontendInstallerWorker))
+
+ assert File.exists?(Path.join([@dir, "frontends", "unknown", "baka", "test.txt"]))
+ end
end
end