From b6e88624013b093e240d020654ef148f2619486f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 6 Jan 2022 15:32:39 +0100 Subject: [PATCH] Update test for guest checkout when distributor doesn't allow --- spec/system/consumer/split_checkout_spec.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index d2b4d998fe..5b9f1bf347 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -19,7 +19,7 @@ describe "As a consumer, I want to checkout my order", js: true do } let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor, bill_address_id: nil, - ship_address_id: nil) + ship_address_id: nil, state: "cart") } let(:fee_tax_rate) { create(:tax_rate, amount: 0.10, zone: zone, included_in_price: true) } @@ -51,6 +51,25 @@ describe "As a consumer, I want to checkout my order", js: true do distributor.shipping_methods << shipping_with_fee end + context "guest checkout when distributor doesn't allow guest orders" do + before do + visit checkout_path + end + + it "should display the split checkout login page" do + expect(page).to have_content distributor.name + expect(page).to have_current_path("/checkout/guest") + expect(page).to have_content("Ok, ready to checkout?") + expect(page).to have_content("Login") + expect(page).to have_no_content("Checkout as guest") + end + + it "should redirect to the login page when clicking the login button" do + click_on "Login" + expect(page).to have_current_path "/" + end + end + context "as a guest user" do before do distributor.update!(allow_guest_orders: true)