add no-JS fallback for cart country selector
All checks were successful
deploy / deploy (push) Successful in 59s
All checks were successful
deploy / deploy (push) Successful in 59s
The delivery country form now has action="/cart/country" with a noscript submit button. Without JS, changing the country and clicking Update POSTs to a new CartController.update_country action that saves the country to session and redirects back to /cart. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -108,4 +108,19 @@ defmodule BerrypodWeb.CartControllerTest do
|
||||
assert cart == []
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /cart/country" do
|
||||
test "saves country to session and redirects to /cart", %{conn: conn} do
|
||||
conn = post(conn, ~p"/cart/country", %{"country" => "DE"})
|
||||
|
||||
assert redirected_to(conn) == "/cart"
|
||||
assert get_session(conn, "country_code") == "DE"
|
||||
end
|
||||
|
||||
test "handles missing country param", %{conn: conn} do
|
||||
conn = post(conn, ~p"/cart/country", %{})
|
||||
|
||||
assert redirected_to(conn) == "/cart"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user