aprs.me/test/aprsme_web/controllers/error_html_test.exs
Graham McIntire fa893dd12e
test: cover ErrorHTML, Layouts, MapLive.Components, CoreComponents, Accounts
- ErrorHTML: explicit 400 path + 401/403/999 delegation.
- Layouts.body_class/1 returns the expected light/dark theme classes.
- MapLive.Components: map_container + slideover_panel exercising all
  connection_status variants, loading state, tracked_callsign clear
  button, and view-mode radios.
- CoreComponents: icon (found + fallback), button, label, error,
  flash (info + error + close=false), checkbox input, JS composers.
- Accounts: get_user_by_email{_and_password}, get_user!, register_user
  happy-path + error paths, change_* changesets, session-token
  round-trip.

Refactor: DeviceIdentification.maybe_refresh_devices splits its nested
logic into fetch_most_recent_device/0, to_datetime/1, and
refresh_if_stale/2 — each a multi-clause function matching on shape.

Coverage 68.28 → 69.56%.
2026-04-23 16:16:31 -05:00

27 lines
890 B
Elixir

defmodule AprsmeWeb.ErrorHTMLTest do
use AprsmeWeb.ConnCase
# Bring render_to_string/3 for testing custom views
import Phoenix.Template
test "renders 404.html" do
assert render_to_string(AprsmeWeb.ErrorHTML, "404", "html", []) == "Not Found"
end
test "renders 500.html" do
assert render_to_string(AprsmeWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
end
test "renders explicit 'Bad Request' for 400.html" do
assert AprsmeWeb.ErrorHTML.render("400.html", %{}) == "Bad Request"
end
test "delegates 403/401 to Phoenix default template messages" do
assert AprsmeWeb.ErrorHTML.render("403.html", %{}) == "Forbidden"
assert AprsmeWeb.ErrorHTML.render("401.html", %{}) == "Unauthorized"
end
test "unknown template falls through to the delegated default" do
assert is_binary(AprsmeWeb.ErrorHTML.render("999.html", %{}))
end
end