Files
openfoodnetwork/spec/system/admin/bulk_order_cancellation_spec.rb
Maikel Linke 5c6d9a092e Simplify login spec helpers, avoid long lines
The `login_as_admin_and_visit` helper was used a lot but isn't really
shorter than:

    login_as_admin
    visit path_visit

Calling those methods separately reduces line length. It also removes
the potential impression that it may be more efficient to use the
helper. Now we have less indirection if one of the calls fails and see
the failing spec line straight away.
2023-04-17 11:08:32 +10:00

50 lines
1.4 KiB
Ruby

# frozen_string_literal: true
require 'system_helper'
describe '
As an Administrator
I want to be able to delete orders in bulk
' do
include AdminHelper
include AuthenticationHelper
include WebHelper
context "deleting orders" do
let!(:o1) {
create(:order_with_distributor, state: 'complete', shipment_state: 'ready',
completed_at: Time.zone.now )
}
let!(:o2) {
create(:order_with_distributor, state: 'complete', shipment_state: 'ready',
completed_at: Time.zone.now )
}
before :each do
login_as_admin
visit spree.admin_orders_path
end
it "deletes orders" do
# Verify that the orders have a STATE of COMPLETE
expect(page).to have_selector('span', text: 'COMPLETE', count: 2)
page.check('selectAll')
page.find("span.icon-reorder", text: "ACTIONS").click
within ".ofn-drop-down-with-prepend .menu" do
page.find("span", text: "Cancel Orders").click
end
within '.reveal-modal' do
expect {
find_button("Confirm").click
}.to change { o1.reload.state }.from('complete').to('canceled')
.and change { o2.reload.state }.from('complete').to('canceled')
end
# Verify that the orders have a STATE of CANCELLED
expect(page).to have_selector('span.canceled', text: 'CANCELLED', count: 2)
end
end
end