towerops/test/towerops_web/plugs/detect_eu_user_test.exs
Graham McIntire 03ec909e3a test: add LiveView tests following testing-liveview patterns
Apply Testing LiveView course patterns (live/2, has_element?,
render_click, form/3). Add tests for MobileQRLive, WeathermapLive,
StatusPageLive, controllers, plugs, and pure function modules.
Expand proto decode coverage to 85.24%.
2026-05-07 12:55:39 -05:00

28 lines
786 B
Elixir

defmodule ToweropsWeb.Plugs.DetectEUUserTest do
use ToweropsWeb.ConnCase, async: true
alias ToweropsWeb.Plugs.DetectEUUser
describe "call/2" do
test "requires cookie consent on localhost", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> Map.put(:host, "localhost")
|> DetectEUUser.call([])
assert conn.assigns.requires_cookie_consent == true
end
test "does not require consent when consent cookie is present", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> Map.put(:host, "localhost")
|> Plug.Conn.put_req_header("cookie", "cookie_consent=accepted")
|> DetectEUUser.call([])
assert conn.assigns.requires_cookie_consent == false
end
end
end