Skip to content

Commit

Permalink
Add test for order_details_spec
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
2 people authored and nvandoorn committed Aug 14, 2024
1 parent 4a761b8 commit 967b064
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions backend/spec/features/admin/orders/order_details_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 967b064

Please sign in to comment.