Implements the subset of the isitagentready.com checklist that maps to
real capabilities of this site:
- RFC 8288 Link headers on every browser response advertising
service-doc (/algo), about, privacy-policy, and sitemap.
- Markdown-for-Agents content negotiation: requests with
Accept: text/markdown for / or /algo return real markdown
(curated summary + verbatim algo.md) with x-markdown-tokens hint.
Other paths still 406 — no synthesizing markdown from LiveView HTML.
- Content-Signal directive in robots.txt declaring
search=yes, ai-train=no, ai-input=no.
- RFC 9727 API catalog at /.well-known/api-catalog with the sole
public endpoint (/api/contacts/map) linking status -> /health and
service-desc -> /openapi.json (a new minimal OpenAPI 3.0 spec).
- Agent Skills Discovery index at /.well-known/agent-skills/index.json
listing two skill documents (fetch-contacts, read-algorithm) with
sha256 digests computed at compile time; documents served at
/.well-known/agent-skills/{name}/SKILL.md.
Skipped (don't match actual site capabilities): Web Bot Auth JWKS,
OAuth/OIDC discovery, MCP server card.
75 lines
2.7 KiB
Elixir
75 lines
2.7 KiB
Elixir
defmodule MicrowavepropWeb.PageControllerTest do
|
|
use MicrowavepropWeb.ConnCase
|
|
|
|
test "GET / redirects to /map", %{conn: conn} do
|
|
conn = get(conn, ~p"/")
|
|
assert redirected_to(conn) == "/map"
|
|
end
|
|
|
|
# RFC 8288 Link headers for agent discovery. These advertise resources
|
|
# that actually exist in this app to crawlers/agents that look at
|
|
# response headers before parsing HTML.
|
|
describe "Link headers (RFC 8288)" do
|
|
test "homepage response carries Link headers", %{conn: conn} do
|
|
conn = get(conn, ~p"/")
|
|
[link] = get_resp_header(conn, "link")
|
|
|
|
assert link =~ ~s(</algo>; rel="service-doc")
|
|
assert link =~ ~s(</about>; rel="about")
|
|
assert link =~ ~s(</privacy>; rel="privacy-policy")
|
|
assert link =~ ~s(</sitemap.xml>; rel="sitemap")
|
|
end
|
|
|
|
test "browser-pipeline pages carry the same Link headers", %{conn: conn} do
|
|
conn = get(conn, ~p"/about")
|
|
[link] = get_resp_header(conn, "link")
|
|
assert link =~ ~s(rel="service-doc")
|
|
assert link =~ ~s(rel="about")
|
|
end
|
|
end
|
|
|
|
# Markdown for Agents: content negotiation so agents that send
|
|
# `Accept: text/markdown` get a real markdown document instead of a 406.
|
|
# We only serve markdown for paths where we actually have markdown source
|
|
# (the homepage summary and /algo). Other paths still 406 rather than lie
|
|
# with a converted-on-the-fly body.
|
|
describe "Markdown for Agents" do
|
|
test "GET / with Accept: text/markdown returns a markdown document", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> put_req_header("accept", "text/markdown")
|
|
|> get(~p"/")
|
|
|
|
assert conn.status == 200
|
|
assert ["text/markdown; charset=utf-8"] = get_resp_header(conn, "content-type")
|
|
[tokens] = get_resp_header(conn, "x-markdown-tokens")
|
|
assert String.to_integer(tokens) > 0
|
|
assert conn.resp_body =~ "# "
|
|
end
|
|
|
|
test "GET /algo with Accept: text/markdown returns algo.md", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> put_req_header("accept", "text/markdown")
|
|
|> get(~p"/algo")
|
|
|
|
assert conn.status == 200
|
|
assert ["text/markdown; charset=utf-8"] = get_resp_header(conn, "content-type")
|
|
assert conn.resp_body =~ "Microwave Propagation Algorithm"
|
|
end
|
|
|
|
test "GET / without markdown Accept still redirects to /map", %{conn: conn} do
|
|
conn = get(conn, ~p"/")
|
|
assert redirected_to(conn) == "/map"
|
|
end
|
|
|
|
test "Accept lists with both html and markdown prefer markdown when specified", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> put_req_header("accept", "text/markdown, text/html;q=0.9")
|
|
|> get(~p"/")
|
|
|
|
assert ["text/markdown; charset=utf-8"] = get_resp_header(conn, "content-type")
|
|
end
|
|
end
|
|
end
|