towerops/test/towerops_web/controllers/error_html_test.exs
Graham McIntie c790794191 Fix tests, credo issues, and Gaiia sync bugs
- Fix CLOAK_KEY placeholder in nix shell (invalid base64)
- Fix error HTML test assertion to match actual template
- Fix Gaiia sync: read 'subnet' field instead of 'block' for IP blocks
- Fix Gaiia sync: extract nested status name from subscription objects
- Fix security headers tests for environment detection
- Fix mobile auth tests to use raw_token
- Fix LiveView test assertions to match actual template content
- Fix SNMP config test expectations for test environment
- Refactor: resolve all Credo complexity/nesting issues
  - Extract helper functions in NetBox sync, VISP sync, Sonar sync
  - Flatten nested conditionals in settings, integrations, alerts
  - Use with/validate_present pattern for connection testing
2026-02-15 11:55:49 -06:00

31 lines
1 KiB
Elixir

defmodule ToweropsWeb.ErrorHTMLTest do
use ToweropsWeb.ConnCase, async: true
# Bring render_to_string/4 for testing custom views
import Phoenix.Template, only: [render_to_string: 4]
test "renders 404.html" do
html = render_to_string(ToweropsWeb.ErrorHTML, "404", "html", [])
assert html =~ "404"
assert html =~ "Oops, a squirrel must have eaten that wire!"
assert html =~ "/images/squirrel.jpg"
end
test "renders 500.html" do
html = render_to_string(ToweropsWeb.ErrorHTML, "500", "html", [])
assert html =~ "500"
assert html =~ "Something went wrong"
end
test "renders fallback status message for unknown templates" do
# Test the fallback render/2 function for error codes without custom templates
result = ToweropsWeb.ErrorHTML.render("503.html", %{})
assert result == "Service Unavailable"
result = ToweropsWeb.ErrorHTML.render("401.html", %{})
assert result == "Unauthorized"
result = ToweropsWeb.ErrorHTML.render("403.html", %{})
assert result == "Forbidden"
end
end