Sha256: 5bfa5da1ccb09aa8145fd22da92e48c52170d53ce65b948fdc7b16e880195a68

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

# Tests for #3958's features
describe "Order Line Items", type: :feature, js: true do
  stub_authorization!

  before do
    # Removing the delivery step causes the order page to render a different
    # partial, called _line_items, which shows line items rather than shipments
    allow(Spree::Order).to receive_messages checkout_step_names: [:address, :payment, :confirm, :complete]
  end

  let!(:order) do
    order = create(:order_with_line_items, line_items_count: 1)
    order.shipments.destroy_all
    order
  end

  it "can edit a line item's quantity" do
    visit spree.edit_admin_order_path(order)
    within(".line-items") do
      within_row(1) do
        find(".edit-line-item").click
        fill_in "quantity", with: 10
        find(".save-line-item").click
        within '.line-item-qty-show' do
          expect(page).to have_content("10")
        end
        within '.line-item-total' do
          expect(page).to have_content("$199.90")
        end
      end
    end
  end

  it "can delete a line item" do
    visit spree.edit_admin_order_path(order)

    product_name = find(".line-items tr:nth-child(1) .line-item-name").text

    within(".line-items") do
      within_row(1) do
        accept_alert do
          find(".delete-line-item").click
        end
      end
    end

    expect(page).not_to have_content(product_name)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree_backend-3.3.0.rc1 spec/features/admin/orders/line_items_spec.rb
spree_backend-3.2.1 spec/features/admin/orders/line_items_spec.rb
spree_backend-3.2.0 spec/features/admin/orders/line_items_spec.rb
spree_backend-3.2.0.rc3 spec/features/admin/orders/line_items_spec.rb
spree_backend-3.2.0.rc2 spec/features/admin/orders/line_items_spec.rb
spree_backend-3.2.0.rc1 spec/features/admin/orders/line_items_spec.rb