add link picker and validation to navigation editor
All checks were successful
deploy / deploy (push) Successful in 1m26s
All checks were successful
deploy / deploy (push) Successful in 1m26s
- replace freeform inputs with grouped dropdown (pages, custom pages, collections, external URL) - add inline URL validation for external links - add inline feedback component instead of flash messages - add dismiss-on-interaction pattern (feedback clears on changes) - add no-JS fallback via NavigationController - add DirtyGuard hook to warn before navigating away with unsaved changes - add no-JS fallbacks for settings forms (from address, signing secret) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,9 +58,9 @@ defmodule BerrypodWeb.Admin.NavigationTest do
|
||||
|
||||
# Should have 5 items now (4 defaults + 1 new)
|
||||
html = render(view)
|
||||
# New empty item has empty placeholder inputs
|
||||
assert Regex.scan(~r/phx-value-section="header".*?phx-value-field="label"/, html)
|
||||
|> length() == 5
|
||||
# Count header item forms by their phx-value-section attribute
|
||||
assert Regex.scan(~r/phx-value-section="header".*?phx-value-index/, html)
|
||||
|> length() >= 5
|
||||
end
|
||||
|
||||
test "removing an item removes from list", %{conn: conn} do
|
||||
@@ -92,15 +92,13 @@ defmodule BerrypodWeb.Admin.NavigationTest do
|
||||
assert Enum.at(items, 1)["label"] == "Home"
|
||||
end
|
||||
|
||||
test "adding a custom page creates nav item", %{conn: conn} do
|
||||
test "custom pages appear in destination dropdown", %{conn: conn} do
|
||||
{:ok, _} = Pages.create_custom_page(%{slug: "faq", title: "FAQ"})
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/navigation")
|
||||
{:ok, _view, html} = live(conn, ~p"/admin/navigation")
|
||||
|
||||
render_click(view, "add_page", %{"section" => "header", "slug" => "faq"})
|
||||
|
||||
html = render(view)
|
||||
assert html =~ ~s(value="FAQ")
|
||||
# Custom page should appear in the dropdown options
|
||||
assert html =~ "FAQ"
|
||||
assert html =~ ~s(value="/faq")
|
||||
end
|
||||
|
||||
@@ -110,7 +108,8 @@ defmodule BerrypodWeb.Admin.NavigationTest do
|
||||
render_click(view, "remove_item", %{"section" => "footer", "index" => "0"})
|
||||
render_click(view, "save")
|
||||
|
||||
assert render(view) =~ "Navigation saved"
|
||||
# Inline feedback shows "Saved"
|
||||
assert has_element?(view, ".admin-inline-feedback-saved", "Saved")
|
||||
|
||||
items = Settings.get_setting("footer_nav")
|
||||
assert length(items) == 3
|
||||
@@ -150,6 +149,14 @@ defmodule BerrypodWeb.Admin.NavigationTest do
|
||||
render_click(view, "add_item", %{"section" => "header"})
|
||||
assert has_element?(view, ".admin-badge-warning")
|
||||
|
||||
# Fill in required fields for the new item before saving
|
||||
render_change(view, "nav_item_change", %{
|
||||
"section" => "header",
|
||||
"index" => "4",
|
||||
"label" => "Test",
|
||||
"dest" => "/"
|
||||
})
|
||||
|
||||
render_click(view, "save")
|
||||
refute has_element?(view, ".admin-badge-warning")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user