towerops/test/towerops_web/controllers/sitemap_controller_test.exs
Graham McIntire 20df4df566 test: improve sitemap controller test coverage
Assign response body once to fix the double call, rename the test,
and assert all 6 public URLs plus the exact <loc> count.
2026-04-17 14:00:57 -05:00

21 lines
718 B
Elixir

defmodule ToweropsWeb.SitemapControllerTest do
use ToweropsWeb.ConnCase, async: true
describe "GET /sitemap.xml" do
test "returns valid XML with all public pages", %{conn: conn} do
conn = get(conn, "/sitemap.xml")
body = response(conn, 200)
assert get_resp_header(conn, "content-type") == ["text/xml; charset=utf-8"]
assert body =~ ~r/<\?xml/
assert body =~ "<urlset"
assert body =~ ~r|<loc>http[^<]+/</loc>|
assert body =~ "/privacy</loc>"
assert body =~ "/terms</loc>"
assert body =~ "/docs/api</loc>"
assert body =~ "/docs/graphql</loc>"
assert body =~ "/help</loc>"
assert length(Regex.scan(~r/<loc>/, body)) == 6
end
end
end