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>
28 lines
685 B
Elixir
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
|