From 6ee8a317164aaf48972f842749f698bcfb52aa7a Mon Sep 17 00:00:00 2001 From: jamey Date: Tue, 24 Feb 2026 23:00:02 +0000 Subject: [PATCH] add test asserting add-to-cart button renders as submit Checks the button is type="submit" inside the phx-submit form. This would have caught the :shop vs :live mode mismatch. Co-Authored-By: Claude Opus 4.6 --- test/berrypod_web/live/shop/product_show_test.exs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/berrypod_web/live/shop/product_show_test.exs b/test/berrypod_web/live/shop/product_show_test.exs index 4fd78e8..e1e957a 100644 --- a/test/berrypod_web/live/shop/product_show_test.exs +++ b/test/berrypod_web/live/shop/product_show_test.exs @@ -305,6 +305,12 @@ defmodule BerrypodWeb.Shop.ProductShowTest do end describe "Add to cart" do + test "add to basket button is a submit button inside the form", %{conn: conn, print: print} do + {:ok, view, _html} = live(conn, ~p"/products/#{print.slug}") + + assert has_element?(view, "form[phx-submit='add_to_cart'] button[type='submit']", "Add to basket") + end + test "add to cart opens the cart drawer", %{conn: conn, print: print} do {:ok, view, _html} = live(conn, ~p"/products/#{print.slug}")