Update specs to reflect order steps changes

This commit is contained in:
Jean-Baptiste Bellet
2022-05-20 09:16:39 +02:00
parent fa9c2b24f2
commit f087b7184c
3 changed files with 17 additions and 15 deletions

View File

@@ -239,12 +239,12 @@ describe Spree::Admin::OrdersController, type: :controller do
end
context "and no errors" do
it "updates distribution charges and redirects to customer details page" do
it "updates distribution charges and redirects to payments page" do
expect_any_instance_of(Spree::Order).to receive(:recreate_all_fees!)
spree_put :update, params
expect(response).to redirect_to spree.admin_order_customer_path(order)
expect(response).to redirect_to spree.admin_order_payments_path(order)
end
end

View File

@@ -64,6 +64,12 @@ describe '
expect(page).not_to have_selector '.flash.error'
expect(page).not_to have_content "Line items can't be blank"
expect(page).to have_selector 'h1', text: 'Customer Details'
o = Spree::Order.last
expect(o.distributor).to eq(distributor)
expect(o.order_cycle).to eq(order_cycle)
click_link "Order Details"
click_button "Update And Recalculate Fees"
expect(page).to have_selector '.flash.error'
expect(page).to have_content "Line items can't be blank"
@@ -77,11 +83,6 @@ describe '
expect(page).to have_selector 'td', text: product.name
click_button 'Update'
expect(page).to have_selector 'h1', text: 'Customer Details'
o = Spree::Order.last
expect(o.distributor).to eq(distributor)
expect(o.order_cycle).to eq(order_cycle)
end
it "can add a product to an existing order" do
@@ -372,12 +373,6 @@ describe '
# When I create a new order
login_as user
new_order_with_distribution(distributor, order_cycle)
select2_select product.name, from: 'add_variant_id', search: true
find('button.add_variant').click
page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS
click_button 'Update'
expect(page).to have_selector 'h1.js-admin-page-title', text: "Customer Details"
# The customer selection partial should be visible
expect(page).to have_selector '#select-customer'
@@ -385,7 +380,6 @@ describe '
# And I select that customer's email address and save the order
tomselect_search_and_select customer.email, from: 'customer_search_override'
click_button 'Update'
expect(page).to have_selector "h1.js-admin-page-title", text: "Customer Details"
# Then their addresses should be associated with the order
order = Spree::Order.last
@@ -395,6 +389,12 @@ describe '
expect(order.bill_address.zipcode).to eq customer.bill_address.zipcode
expect(order.ship_address.city).to eq customer.ship_address.city
expect(order.bill_address.city).to eq customer.bill_address.city
click_link "Order Details"
select2_select product.name, from: 'add_variant_id', search: true
find('button.add_variant').click
page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS
end
context "as an enterprise manager" do
@@ -686,6 +686,8 @@ describe '
it "creating an order with distributor and order cycle" do
new_order_with_distribution(distributor1, order_cycle1)
expect(page).to have_selector 'h1', text: 'Customer Details'
click_link "Order Details"
expect(page).to have_content 'ADD PRODUCT'
select2_select product.name, from: 'add_variant_id', search: true
@@ -704,7 +706,6 @@ describe '
click_button 'Update'
expect(page).to have_selector 'h1', text: 'Customer Details'
o = Spree::Order.last
expect(o.distributor).to eq distributor1
expect(o.order_cycle).to eq order_cycle1

View File

@@ -449,6 +449,7 @@ describe "
select2_select distributor.name, from: 'order_distributor_id'
select2_select order_cycle.name, from: 'order_order_cycle_id'
click_button 'Next'
click_link "Order Details"
end
# Reproducing a bug, issue #1446