<commit_before>require 'spec_helper'

describe "Shipments" do
  stub_authorization!

  let!(:order) { create(:order_ready_to_ship, :number => "R100", :state => "complete") }

  context "shipping an order", js: true do
    before(:each) do
      visit spree.admin_path
      click_link "Orders"
      within_row(1) do
        click_link "R100"
      end
    end

    it "can ship a completed order" do
      click_link "ship"
      sleep 1

      page.should have_content("shipped package")
      order.reload.shipment_state.should == "shipped"
    end
  end

  context "moving variants between shipments", js: true do
    let!(:la) { create(:stock_location, name: "LA") }
    before(:each) do
      create(:stock_location, name: "LA")
      visit spree.admin_path
      click_link "Orders"
      within_row(1) do
        click_link "R100"
      end
    end

    it "can move a variant to a new and to an existing shipment" do
      order.shipments.count.should == 1

      within_row(1) { click_icon 'resize-horizontal' }
      targetted_select2 'LA', from: '#s2id_item_stock_location'
      click_icon :ok
      page.should have_selector("table.stock-contents:eq(2)")

      within_row(2) { click_icon 'resize-horizontal' }
      targetted_select2 "LA(#{order.reload.shipments.last.number})", from: '#s2id_item_stock_location'
      click_icon :ok
      page.should have_selector("table.stock-contents:eq(2)")
    end
  end<commit_msg>Sleep inside orders/shipments_spec to also wait for an API response<commit_after>require 'spec_helper'

describe "Shipments" do
  stub_authorization!

  let!(:order) { create(:order_ready_to_ship, :number => "R100", :state => "complete") }

  context "shipping an order", js: true do
    before(:each) do
      visit spree.admin_path
      click_link "Orders"
      within_row(1) do
        click_link "R100"
      end
    end

    it "can ship a completed order" do
      click_link "ship"
      sleep 1

      page.should have_content("shipped package")
      order.reload.shipment_state.should == "shipped"
    end
  end

  context "moving variants between shipments", js: true do
    let!(:la) { create(:stock_location, name: "LA") }
    before(:each) do
      create(:stock_location, name: "LA")
      visit spree.admin_path
      click_link "Orders"
      within_row(1) do
        click_link "R100"
      end
    end

    it "can move a variant to a new and to an existing shipment" do
      order.shipments.count.should == 1

      within_row(1) { click_icon 'resize-horizontal' }
      targetted_select2 'LA', from: '#s2id_item_stock_location'
      click_icon :ok
      sleep(1)
      page.should have_selector("table.stock-contents:eq(2)")

      within_row(2) { click_icon 'resize-horizontal' }
      targetted_select2 "LA(#{order.reload.shipments.last.number})", from: '#s2id_item_stock_location'
      click_icon :ok
      page.should have_selector("table.stock-contents:eq(2)")
    end
  end
{'fraction_non_alphanumeric': 0.10914654879292758, 'fraction_numerical': 0.014620877252635158, 'mean_word_length': 3.06353591160221, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5445967', 'n_tokens_mistral': 988, 'n_tokens_neox': 948, 'n_words': 241}