prop/test/microwaveprop_web/controllers/agent_skills_controller_test.exs
Graham McIntire cb8445f329
fix: resolve 158/183 credo --strict warnings
- Add 17 missing @spec annotations (layouts, error_json, error_html, skewt_svg)
- Move 12+ nested alias/import/require to module top level
- Add phx-change/id attributes to 11 raw HTML <form> tags
- Remove 4 unused LiveView assigns (:bounds, :data_provider)
- Add 3 missing doctest references (HrrrNativeClient, BulkFetch, Accounts)
- Break 2 long lines (path_compute.ex:382)
- Strengthen weak test assertions (is_binary→byte_size, is_list→!=[])
- Replace Module.concat with Module.safe_concat (2 occurrences)
- Replace length/1 > 0 with list != [] (9 occurrences)
- Remove no-op assert true, fix no-assertion tests

Remaining: 24 socket.assigns introspection warnings (deliberate test
pattern for observable behavior testing), 1 formatter-resistant long
line, 3 app-code usage warnings.
2026-06-12 15:47:15 -05:00

59 lines
2.2 KiB
Elixir

defmodule MicrowavepropWeb.AgentSkillsControllerTest do
use MicrowavepropWeb.ConnCase, async: true
describe "GET /.well-known/agent-skills/index.json" do
test "returns the agent-skills discovery index", %{conn: conn} do
conn = get(conn, "/.well-known/agent-skills/index.json")
assert conn.status == 200
assert ["application/json" <> _] = get_resp_header(conn, "content-type")
body = Jason.decode!(conn.resp_body)
assert body["$schema"] =~ "agentskills"
assert body["skills"] != []
for skill <- body["skills"] do
assert byte_size(skill["name"]) > 0
assert byte_size(skill["type"]) > 0
assert byte_size(skill["description"]) > 0
assert byte_size(skill["url"]) > 0
assert String.match?(skill["sha256"], ~r/^[0-9a-f]{64}$/)
end
end
test "index lists at least fetch-contacts and read-algorithm", %{conn: conn} do
conn = get(conn, "/.well-known/agent-skills/index.json")
%{"skills" => skills} = Jason.decode!(conn.resp_body)
names = Enum.map(skills, & &1["name"])
assert "fetch-contacts" in names
assert "read-algorithm" in names
end
end
describe "GET /.well-known/agent-skills/:name/SKILL.md" do
test "serves a skill document as markdown", %{conn: conn} do
conn = get(conn, "/.well-known/agent-skills/fetch-contacts/SKILL.md")
assert conn.status == 200
assert ["text/markdown; charset=utf-8"] = get_resp_header(conn, "content-type")
assert conn.resp_body =~ "Fetch contacts dataset"
end
test "sha256 in the index matches the served document bytes", %{conn: conn} do
%{"skills" => skills} =
conn |> get("/.well-known/agent-skills/index.json") |> Map.get(:resp_body) |> Jason.decode!()
for %{"name" => name, "sha256" => expected} <- skills do
doc = get(conn, "/.well-known/agent-skills/#{name}/SKILL.md").resp_body
actual = :sha256 |> :crypto.hash(doc) |> Base.encode16(case: :lower)
assert actual == expected, "sha256 mismatch for skill #{name}"
end
end
test "returns 404 for unknown skill names", %{conn: conn} do
conn = get(conn, "/.well-known/agent-skills/does-not-exist/SKILL.md")
assert conn.status == 404
end
end
end