Files
chess-endgame-trainer/test/chesstrainer_web/controllers/robots_controller_test.exs
T
owenrees eaf72a7686 add sitemap, robots, and noindex admin routes (#85)
Serve a runtime sitemap.xml with the indexable marketing pages only; endgame play pages are left out to avoid indexing tens of thousands of near-identical pages. Generate robots.txt at runtime so it points at the sitemap on the deployment's host, and send X-Robots-Tag: noindex from every /admin response.
2026-11-06 23:04:10 +01:00

23 lines
654 B
Elixir

defmodule ChesstrainerWeb.RobotsControllerTest do
use ChesstrainerWeb.ConnCase, async: true
alias ChesstrainerWeb.Endpoint
describe "GET /robots.txt" do
test "allows crawlers and points at the sitemap", %{conn: conn} do
body = conn |> get(~p"/robots.txt") |> response(200)
assert body =~ "User-agent: *"
assert body =~ "Allow: /"
assert body =~ "Sitemap: #{Endpoint.url()}/sitemap.xml"
end
test "is served as plain text", %{conn: conn} do
conn = get(conn, ~p"/robots.txt")
assert [content_type] = get_resp_header(conn, "content-type")
assert content_type =~ "text/plain"
end
end
end