show proper 404 page for missing custom pages instead of redirecting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-28 08:35:01 +00:00
parent ad2f2517e5
commit f479be5728
3 changed files with 21 additions and 17 deletions

View File

@@ -49,8 +49,10 @@ defmodule BerrypodWeb.Shop.CustomPageTest do
:ok
end
test "redirects anonymous users to home", %{conn: conn} do
{:error, {:live_redirect, %{to: "/"}}} = live(conn, "/draft-page")
test "returns 404 for anonymous users", %{conn: conn} do
assert_raise BerrypodWeb.NotFoundError, fn ->
live(conn, "/draft-page")
end
end
test "renders for admin users", %{conn: conn, user: user} do
@@ -61,8 +63,10 @@ defmodule BerrypodWeb.Shop.CustomPageTest do
end
describe "nonexistent page" do
test "redirects to home with flash", %{conn: conn} do
{:error, {:live_redirect, %{to: "/"}}} = live(conn, "/does-not-exist")
test "returns 404", %{conn: conn} do
assert_raise BerrypodWeb.NotFoundError, fn ->
live(conn, "/does-not-exist")
end
end
end