diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index 6a02206e1d..d28764475e 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -159,6 +159,7 @@ feature "full-page cart", js: true do describe "updating quantities" do let(:li) { order.line_items(true).last } let(:variant) { product_with_tax.variants.first } + let(:variant2) { product_with_fee.variants.first } before do add_product_to_cart order, product_with_tax @@ -175,15 +176,26 @@ feature "full-page cart", js: true do end describe "with insufficient stock available" do - it "prevents user from entering an invalid value" do - # Given we have 2 on hand, and we've loaded the page after that fact + xit "prevents user from entering invalid values" do + add_product_to_cart order, product_with_fee + variant.update_attributes!(on_hand: 2, on_demand: false) + variant2.update_attributes!(on_hand: 3, on_demand: false) visit main_app.cart_path accept_alert 'Insufficient stock available, only 2 remaining' do - fill_in "order_line_items_attributes_0_quantity", with: '4' + within "tr.variant-#{variant.id}" do + fill_in "order_line_items_attributes_0_quantity", with: '4' + end end expect(page).to have_field "order_line_items_attributes_0_quantity", with: '2' + + accept_alert 'Insufficient stock available, only 3 remaining' do + within "tr.variant-#{variant2.id}" do + fill_in "order_line_items_attributes_1_quantity", with: '4' + end + end + expect(page).to have_field "order_line_items_attributes_1_quantity", with: '3' end it "shows the quantities saved, not those submitted" do