From 901c29c97b6b73934696d65d3ee41b929d77bcdb Mon Sep 17 00:00:00 2001 From: cyrillefr Date: Fri, 12 Apr 2024 15:07:00 +0200 Subject: [PATCH] Fix Ship Order menu choice not working - Front End ShipOrderComponent was missed for the menu to work - updated spec to test for a specific case --- .../spree/admin/shared/_order_links.html.haml | 5 ++++ spec/system/admin/order_spec.rb | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/views/spree/admin/shared/_order_links.html.haml b/app/views/spree/admin/shared/_order_links.html.haml index 9af75fffd8..a0643a4146 100644 --- a/app/views/spree/admin/shared/_order_links.html.haml +++ b/app/views/spree/admin/shared/_order_links.html.haml @@ -6,8 +6,10 @@ %i.icon-check = I18n.t 'admin.actions' %div.menu{"data-action": "click->dropdown#closeOnMenu"} + - shipment_ready = false - order_links(@order).each do |link| - if link[:name] == t(:ship_order) + - shipment_ready = true %a.menu_item{ href: link[:url], target: link[:target] || "_self", data: { "modal-link-target-value": dom_id(@order, :ship), "action": "click->modal-link#open", "controller": "modal-link" } } %span %i{ class: link[:icon] } @@ -19,3 +21,6 @@ %span=link[:name] = render 'spree/admin/shared/custom-confirm' +- if shipment_ready + %form + = render ShipOrderComponent.new(order: @order) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index f6f5f96fe0..410f36bf6f 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -1006,6 +1006,30 @@ describe ' it_behaves_like "ship order from dropdown", "Invoices" it_behaves_like "ship order from dropdown", "Return Authorizations" end + + context 'when not on the Order Details sub section' do + before do + click_link 'Customer Details' + end + it 'can ship order too' do + find('.ofn-drop-down').click + click_link 'Ship Order' + + within ".reveal-modal" do + expect(page).to have_checked_field('Send a shipment/pick up ' \ + 'notification email to the customer.') + # no test of enqueued job since it can cause failures + # if the remainder of the spec is too fasr + find_button('Confirm').click + end + + # the best & easiest way to close the modal without calling all the JS + find_button("Cancel").click + expect(order.reload.shipped?).to be true + click_link('Order Details') + expect(page).to have_text 'SHIPPED' + end + end end context "when an included variant has been deleted" do