Merge pull request #11347 from abdellani/fix-edit-order-button

fix cancel order button
This commit is contained in:
Konrad
2023-08-18 17:07:42 +02:00
committed by GitHub
2 changed files with 36 additions and 14 deletions

View File

@@ -10,3 +10,5 @@
%span
%i{ class: link[:icon] }
%span=link[:name]
= render 'spree/admin/shared/custom-confirm'

View File

@@ -608,26 +608,46 @@ describe '
end
context "Canceling an order" do
before do
visit spree.edit_admin_order_path(order)
find("#links-dropdown .ofn-drop-down").click
shared_examples "canceling an order" do
it "shows the link" do
expect(page).to have_link "Cancel Order",
href: spree.fire_admin_order_path(order, e: 'cancel')
end
it 'cancels the order' do
within ".ofn-drop-down .menu" do
expect(page).to have_selector("span", text: "Cancel Order")
page.find("span", text: "Cancel Order").click
end
within '.modal-content' do
expect {
find_button("OK").click
}.to change { order.reload.state }.from('complete').to('canceled')
end
end
end
it "shows the link" do
expect(page).to have_link "Cancel Order",
href: spree.fire_admin_order_path(order, e: 'cancel')
context "from order details page" do
before do
visit spree.edit_admin_order_path(order)
find("#links-dropdown .ofn-drop-down").click
end
it_behaves_like "canceling an order"
end
it "cancels the order" do
within ".ofn-drop-down .menu" do
expect(page).to have_selector("span", text: "Cancel Order")
page.find("span", text: "Cancel Order").click
context "from order's payments" do
before do
visit spree.admin_order_payments_path(order)
find("#links-dropdown .ofn-drop-down").click
end
within '.modal-content' do
expect {
find_button("OK").click
}.to change { order.reload.state }.from('complete').to('canceled')
it_behaves_like "canceling an order"
end
context "from order's adjustments" do
before do
visit spree.admin_order_adjustments_path(order)
find("#links-dropdown .ofn-drop-down").click
end
it_behaves_like "canceling an order"
end
end