From 20df4df5663acb23f4b0cdfac8d15729553fe361 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 17 Apr 2026 14:00:57 -0500 Subject: [PATCH] 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 count. --- .../controllers/sitemap_controller_test.exs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/towerops_web/controllers/sitemap_controller_test.exs b/test/towerops_web/controllers/sitemap_controller_test.exs index 1472cd05..8baf81d1 100644 --- a/test/towerops_web/controllers/sitemap_controller_test.exs +++ b/test/towerops_web/controllers/sitemap_controller_test.exs @@ -2,17 +2,20 @@ defmodule ToweropsWeb.SitemapControllerTest do use ToweropsWeb.ConnCase, async: true describe "GET /sitemap.xml" do - test "returns valid XML with public pages", %{conn: conn} do + test "returns valid XML with all public pages", %{conn: conn} do conn = get(conn, "/sitemap.xml") - assert response(conn, 200) - assert get_resp_header(conn, "content-type") == ["text/xml; charset=utf-8"] body = response(conn, 200) + assert get_resp_header(conn, "content-type") == ["text/xml; charset=utf-8"] assert body =~ ~r/<\?xml/ assert body =~ "" - assert body =~ "/privacy" - assert body =~ "/terms" + assert body =~ ~r|http[^<]+/| + assert body =~ "/privacy" + assert body =~ "/terms" + assert body =~ "/docs/api" + assert body =~ "/docs/graphql" + assert body =~ "/help" + assert length(Regex.scan(~r//, body)) == 6 end end end