logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 5c139be42e46bef5ec37d974804fc21c704fcec9
parent a80776b2607bbfdab888d2939c1597b1ad31f220
Author: nicole mikołajczyk <git@mkljczk.pl>
Date:   Fri, 28 Nov 2025 16:30:03 +0100

Add tests

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>

Diffstat:

Mtest/pleroma/web/plugs/frontend_static_plug_test.exs33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git a/test/pleroma/web/plugs/frontend_static_plug_test.exs b/test/pleroma/web/plugs/frontend_static_plug_test.exs @@ -97,6 +97,7 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do "users", "tags", "mailer", + "frontend_switcher", "inbox", "relay", "internal", @@ -113,4 +114,36 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do assert expected_routes == Pleroma.Web.Router.get_api_routes() end + + describe "preferred frontend cookie handling" do + test "returns preferred frontend file", %{conn: conn} do + name = "test-fe" + ref = "develop" + + clear_config([:frontends, :pickable], ["#{name}/#{ref}"]) + path = "#{@dir}/frontends/#{name}/#{ref}" + + Pleroma.Backports.mkdir_p!(path) + File.write!("#{path}/index.html", "from frontend plug") + + index = + conn + |> put_req_cookie("preferred_frontend", "#{name}/#{ref}") + |> get("/") + + assert html_response(index, 200) == "from frontend plug" + end + + test "only returns content from pickable frontends", %{conn: conn} do + clear_config([:instance, :static_dir], "instance/static") + clear_config([:frontends, :pickable], ["pleroma-fe/develop", "pl-fe/develop"]) + + config_file = + conn + |> put_req_cookie("preferred_frontend", "../../../config") + |> get("/config.exs") + + refute response(config_file, 200) =~ "import Config" + end + end end