defmodule BerrypodWeb.Admin.ThemeTest do
  use BerrypodWeb.ConnCase, async: false

  import Berrypod.AccountsFixtures

  setup do
    user = user_fixture()
    %{user: user}
  end

  describe "/admin/theme redirect" do
    test "redirects unauthenticated users to login", %{conn: conn} do
      conn = get(conn, ~p"/admin/theme")

      assert redirected_to(conn) == ~p"/users/log-in"
    end

    test "redirects authenticated users to on-site editor", %{conn: conn, user: user} do
      conn = conn |> log_in_user(user) |> get(~p"/admin/theme")

      assert redirected_to(conn) == "/?edit=theme"
    end
  end
end
