berrypod/test/berrypod_web/plugs/broken_url_tracker_test.exs
jamey ad2f2517e5 add custom page LiveView with catch-all routing
Shop.CustomPage handles /:slug catch-all for CMS pages. Restructured
router so the catch-all is last — all admin, auth, setup, and SEO
routes defined before the shop scope to prevent interception.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 02:21:11 +00:00

28 lines
685 B
Elixir

defmodule BerrypodWeb.Plugs.BrokenUrlTrackerTest do
use BerrypodWeb.ConnCase, async: true
alias Berrypod.Redirects
setup do
Redirects.create_table()
:ok
end
test "records broken URL on 404", %{conn: conn} do
# Multi-segment path — not caught by the /:slug catch-all route
conn = get(conn, "/zz/nonexistent-path")
assert conn.status in [404, 500]
[broken_url] = Redirects.list_broken_urls()
assert broken_url.path == "/zz/nonexistent-path"
assert broken_url.recent_404_count == 1
end
test "skips static asset paths", %{conn: conn} do
get(conn, "/assets/missing-file.js")
assert Redirects.list_broken_urls() == []
end
end