From eb8050d61d5d49123c12d45454369cbcbe89dff4 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Wed, 25 Sep 2024 15:58:28 +1000 Subject: [PATCH] Add spec reproducing the bug --- spec/system/consumer/checkout/summary_spec.rb | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/spec/system/consumer/checkout/summary_spec.rb b/spec/system/consumer/checkout/summary_spec.rb index a15b800528..f1b67ea33a 100644 --- a/spec/system/consumer/checkout/summary_spec.rb +++ b/spec/system/consumer/checkout/summary_spec.rb @@ -10,6 +10,7 @@ RSpec.describe "As a consumer, I want to checkout my order" do include StripeStubs include PaypalHelper include AuthenticationHelper + include UIComponentHelper let!(:zone) { create(:zone_with_member) } let(:supplier) { create(:supplier_enterprise) } @@ -48,7 +49,6 @@ RSpec.describe "As a consumer, I want to checkout my order" do before do login_as(user) - visit checkout_path end context "summary step" do @@ -311,6 +311,47 @@ RSpec.describe "As a consumer, I want to checkout my order" do end end + context "when updating cart after summary step" do + let(:order) { + create(:order_ready_for_payment, distributor:) + } + let!(:payment_with_fee) { + create( + :payment_method, + distributors: [distributor], + name: "Payment with Fee", description: "Payment with fee", + calculator: Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 0.1) + ) + } + + it "calculated the correct order total" do + pending + visit checkout_step_path(:payment) + expect(page).to have_checked_field "Payment with Fee" + + click_button "Next - Order summary" + expect(page).to have_title "Checkout Summary - Open Food Network" + + # Back to the shop + click_link "Shopping @ #{distributor.name}" + expect(page).to have_content(distributor.name) + + # Add item to cart + within_variant(order.line_items.first.variant) do + click_button increase_quantity_symbol + end + wait_for_cart + + # Checkout + toggle_cart + click_link "Checkout" + + # Check summary page total + expect(page).to have_title "Checkout Summary - Open Food Network" + expect(page).to have_selector("#order_total", text: 20.02) + end + end + context "with previous open orders" do let(:order) { create(:order_ready_for_confirmation, distributor:,