1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.FrontendTest do
9 @dir "test/frontend_static_test"
13 clear_config([:instance, :static_dir], @dir)
20 test "it downloads and unzips a known frontend" do
21 clear_config([:frontends, :available], %{
25 "build_url" => "http://gensokyo.2hu/builds/${ref}"
29 Tesla.Mock.mock(fn %{url: "http://gensokyo.2hu/builds/fantasy"} ->
30 %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/frontend_dist.zip")}
33 Frontend.install("pleroma")
35 assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
38 test "it also works given a file" do
39 clear_config([:frontends, :available], %{
47 folder = Path.join([@dir, "frontends", "pleroma", "fantasy"])
48 previously_existing = Path.join([folder, "temp"])
50 File.write!(previously_existing, "yey")
51 assert File.exists?(previously_existing)
53 Frontend.install("pleroma", file: "test/fixtures/tesla_mock/frontend.zip")
55 assert File.exists?(Path.join([folder, "test.txt"]))
56 refute File.exists?(previously_existing)
59 test "it downloads and unzips unknown frontends" do
60 Tesla.Mock.mock(fn %{url: "http://gensokyo.2hu/madeup.zip"} ->
61 %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/frontend.zip")}
64 Frontend.install("unknown",
66 build_url: "http://gensokyo.2hu/madeup.zip",
70 assert File.exists?(Path.join([@dir, "frontends", "unknown", "baka", "test.txt"]))