1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.FrontendTest do
7 alias Mix.Tasks.Pleroma.Frontend
9 import ExUnit.CaptureIO, only: [capture_io: 1]
11 @dir "test/frontend_static_test"
15 clear_config([:instance, :static_dir], @dir)
22 test "it downloads and unzips a known frontend" do
23 clear_config([:frontends, :available], %{
27 "build_url" => "http://gensokyo.2hu/builds/${ref}"
31 Tesla.Mock.mock(fn %{url: "http://gensokyo.2hu/builds/fantasy"} ->
32 %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/frontend_dist.zip")}
36 Frontend.run(["install", "pleroma"])
39 assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
42 test "it also works given a file" do
43 clear_config([:frontends, :available], %{
52 Frontend.run(["install", "pleroma", "--file", "test/fixtures/tesla_mock/frontend.zip"])
55 assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
58 test "it downloads and unzips unknown frontends" do
59 Tesla.Mock.mock(fn %{url: "http://gensokyo.2hu/madeup.zip"} ->
60 %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/frontend.zip")}
70 "http://gensokyo.2hu/madeup.zip",
76 assert File.exists?(Path.join([@dir, "frontends", "unknown", "baka", "test.txt"]))