Skip to content

Commit

Permalink
Fix failing specs due to Spree 2's new order admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
HugsDaniel committed Jan 31, 2019
1 parent 097c950 commit acc6fbd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
8 changes: 8 additions & 0 deletions app/views/spree/admin/orders/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
%legend= Spree.t(:order_total)
%span.order-total= order.display_total
= render partial: 'spree/admin/orders/_form/distribution_fields'
.filter-actions.actions{"ng-show" => "distributionChosen()"}
= button t(:update_and_recalculate_fees), 'icon-refresh'
%span.or
= t(:or)
= link_to_with_icon 'button icon-arrow-left', t(:back), admin_orders_url
= javascript_tag do
var order_number = '#{@order.number}';
var shipments = [];
Expand Down
32 changes: 13 additions & 19 deletions spec/features/admin/orders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ def new_order_with_distribution(distributor, order_cycle)
expect(page).not_to have_selector '#errorExplanation'
expect(page).to have_content 'ADD PRODUCT'
targetted_select2_search @product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'
click_link 'Add'
find('button.add_variant').click
page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS
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
Expand All @@ -92,7 +89,7 @@ def new_order_with_distribution(distributor, order_cycle)

targetted_select2_search @product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'

click_link 'Add'
find('button.add_variant').click

expect(page).to have_selector 'td', text: @product.name
expect(@order.line_items(true).map(&:product)).to include @product
Expand All @@ -112,7 +109,6 @@ def new_order_with_distribution(distributor, order_cycle)
page.find('a.icon-search').click

click_icon :edit

select2_select d.name, from: 'order_distributor_id'
select2_select oc.name, from: 'order_order_cycle_id'

Expand Down Expand Up @@ -157,14 +153,14 @@ def new_order_with_distribution(distributor, order_cycle)
quick_login_as @user
new_order_with_distribution(@distributor, @order_cycle)
targetted_select2_search @product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'
click_link 'Add'
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.page-title', text: "Customer Details"

# And I select that customer's email address and save the order
targetted_select2_search @customer.email, from: '#customer_search_override', dropdown_css: '.select2-drop'
click_button 'Continue'
click_button 'Update'
expect(page).to have_selector "h1.page-title", text: "Shipments"

# Then their addresses should be associated with the order
Expand Down Expand Up @@ -230,16 +226,16 @@ def new_order_with_distribution(distributor, order_cycle)
within('table.index tbody', match: :first) do
@order.line_items.each do |item|
expect(page).to have_selector "td", match: :first, text: item.full_name
expect(page).to have_selector "td.price", text: item.single_display_amount
expect(page).to have_selector "input.qty[value='#{item.quantity}']"
expect(page).to have_selector "td.total", text: item.display_amount
expect(page).to have_selector "td.item-price", text: item.single_display_amount
expect(page).to have_selector "input#quantity[value='#{item.quantity}']", visible: false
expect(page).to have_selector "td.item-total", text: item.display_amount
end
end
end

scenario "shows the order subtotal" do
within('table.index tbody#subtotal') do
expect(page).to have_selector "td.total", text: @order.display_item_total
scenario "shows the order items total" do
within('fieldset#order-total') do
expect(page).to have_selector "span.order-total", text: @order.display_item_total
end
end

Expand All @@ -254,13 +250,11 @@ def new_order_with_distribution(distributor, order_cycle)
end

scenario "shows the order total" do
within('table.index tbody#order-total') do
expect(page).to have_selector "td.total", text: @order.display_total
end
expect(page).to have_selector "fieldset#order-total", text: @order.display_total
end

scenario "shows the order taxes" do
within('table.index tbody#price-adjustments') do
within('tbody#order-charges') do
expect(page).to have_selector "td", match: :first, text: "Tax 1"
expect(page).to have_selector "td.total", text: Spree::Money.new(10)
end
Expand Down Expand Up @@ -324,7 +318,7 @@ def new_order_with_distribution(distributor, order_cycle)
expect(page).to have_content 'ADD PRODUCT'
targetted_select2_search product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'

click_link 'Add'
find('button.add_variant').click
page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS
expect(page).to have_selector 'td', text: product.name

Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/variant_overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
# Reproducing a bug, issue #1446
it "shows the overridden price" do
targetted_select2_search product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'
click_link 'Add'
find('button.add_variant').click
expect(page).to have_selector("table.index tbody tr") # Wait for JS
expect(page).to have_content(product.variants.first.variant_overrides.first.price)
end
Expand Down

0 comments on commit acc6fbd

Please sign in to comment.