aboutsummaryrefslogtreecommitdiff
path: root/test/tasks/frontend_test.exs
diff options
context:
space:
mode:
Diffstat (limited to 'test/tasks/frontend_test.exs')
-rw-r--r--test/tasks/frontend_test.exs67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/tasks/frontend_test.exs b/test/tasks/frontend_test.exs
new file mode 100644
index 000000000..2f9458f89
--- /dev/null
+++ b/test/tasks/frontend_test.exs
@@ -0,0 +1,67 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Mix.Tasks.Pleroma.FrontendTest do
+ use ExUnit.Case
+ use Pleroma.Tests.Helpers
+
+ import Tesla.Mock, only: [mock_global: 1, json: 1]
+
+ @bundle_zip_path Path.absname("test/fixtures/tesla_mock/fe-bundle.zip")
+
+ @dir "test/tmp/instance_static"
+
+ setup_all do
+ Mix.shell(Mix.Shell.Process)
+
+ on_exit(fn ->
+ Mix.shell(Mix.Shell.IO)
+ end)
+
+ :ok
+ end
+
+ setup do
+ mock_global(fn
+ %{method: :get, url: "https://git.pleroma.social/api/v4/projects/" <> rest} ->
+ if String.ends_with?(rest, "repository/branches") do
+ "test/fixtures/tesla_mock/gitlab-api-pleroma-fe-branches.json"
+ else
+ "test/fixtures/tesla_mock/gitlab-api-pleroma-fe-releases.json"
+ end
+ |> Path.absname()
+ |> File.read!()
+ |> Jason.decode!()
+ |> json()
+
+ %{method: :get, url: _download_url} ->
+ %Tesla.Env{status: 200, body: File.read!(@bundle_zip_path)}
+ end)
+
+ File.mkdir_p!(@dir)
+ on_exit(fn -> File.rm_rf(@dir) end)
+
+ clear_config([:instance, :static_dir], @dir)
+
+ :ok
+ end
+
+ test "installations" do
+ frontends = ~w(pleroma kenoma mastodon admin)
+ refs = ~w(develop stable 1.2.3)
+
+ Enum.each(frontends, fn frontend ->
+ Enum.each(refs, fn ref ->
+ Mix.Tasks.Pleroma.Frontend.run([
+ "install",
+ frontend,
+ "--ref",
+ ref
+ ])
+
+ assert File.exists?(Path.join([@dir, "frontends/#{frontend}/#{ref}/index.html"]))
+ end)
+ end)
+ end
+end