From 4ec41572b1275caae5cffefa763c0014d61aa875 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 20 Jun 2023 17:06:07 +0200 Subject: [PATCH] Add spec on Canceling an order Strange that it doesn't exist, but anyway, let's create it! --- spec/system/admin/order_spec.rb | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 1a788d201b..e608b7ca19 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -585,8 +585,6 @@ describe ' within "#links-dropdown" do expect(page).to have_link "Resend Confirmation", href: spree.resend_admin_order_path(order) - expect(page).to have_link "Cancel Order", - href: spree.fire_admin_order_path(order, e: 'cancel') end end @@ -607,6 +605,29 @@ describe ' expect(page).to have_content "Order email has been resent" end end + + context "Canceling an order" do + before do + visit spree.edit_admin_order_path(order) + find("#links-dropdown .ofn-drop-down").click + end + + 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 context "Check send/print invoice links" do