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:
@@ -106,6 +106,36 @@ defmodule BerrypodWeb.Shop.CartTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "no-JS fallback" do
|
||||
setup [:create_cart_with_product]
|
||||
|
||||
test "country selector form has action for no-JS submission", %{
|
||||
conn: conn,
|
||||
variant: variant
|
||||
} do
|
||||
# Insert a shipping rate so the country selector renders
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
pc = Berrypod.ProductsFixtures.provider_connection_fixture()
|
||||
|
||||
Berrypod.Repo.insert_all(Berrypod.Shipping.ShippingRate, [
|
||||
[
|
||||
blueprint_id: 1,
|
||||
print_provider_id: 1,
|
||||
country_code: "GB",
|
||||
first_item_cost: 399,
|
||||
additional_item_cost: 100,
|
||||
provider_connection_id: pc.id,
|
||||
inserted_at: now,
|
||||
updated_at: now
|
||||
]
|
||||
])
|
||||
|
||||
{:ok, view, _html} = conn |> conn_with_cart(variant.id) |> live(~p"/cart")
|
||||
|
||||
assert has_element?(view, "form[action='/cart/country'][method='post']")
|
||||
end
|
||||
end
|
||||
|
||||
describe "Cart page title" do
|
||||
test "page title is Cart", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/cart")
|
||||
|
||||
Reference in New Issue
Block a user