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.
This commit is contained in:
parent
3f82c1c110
commit
20df4df566
1 changed files with 9 additions and 6 deletions
|
|
@ -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 =~ "<urlset"
|
||||
assert body =~ "<loc>"
|
||||
assert body =~ "/privacy"
|
||||
assert body =~ "/terms"
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue