From 967b0640eac64199f355d1767b601ca91258b077 Mon Sep 17 00:00:00 2001 From: Monica Giambitto Date: Wed, 4 Oct 2023 12:18:55 +0200 Subject: [PATCH] Add test for order_details_spec The test interacts with the headless browser, but manipulates the order behind the scenes to simulate the shipping of the order in a second tab Co-authored-by: An Stewart --- .../admin/orders/order_details_spec.rb | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/backend/spec/features/admin/orders/order_details_spec.rb b/backend/spec/features/admin/orders/order_details_spec.rb index 459a4c5e94c..cbadb3273ed 100644 --- a/backend/spec/features/admin/orders/order_details_spec.rb +++ b/backend/spec/features/admin/orders/order_details_spec.rb @@ -399,6 +399,31 @@ expect(page).not_to have_selector('.fa-arrows-h') expect(page).not_to have_selector('.fa-trash') end + + context 'and on the cart page the cart is emptied' do + it 'should show the empty cart page' do + order = create(:order_ready_to_ship) + + visit spree.cart_admin_order_path(order) + order.fulfill! + + ## simulate shipping order in another tab + shipment = order.shipments.first + order.shipping.ship( + inventory_units: shipment.inventory_units, + stock_location: shipment.stock_location, + address: order.ship_address, + shipping_method: shipment.shipping_method + ) + + accept_alert 'Are you sure you want to delete this record?' do + click_on 'Empty Cart' + end + + expect(page.current_path).to eq(spree.cart_admin_order_path(order)) + expect(page).not_to have_content(order.line_items.first.variant.sku) + end + end end end