mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add spec for maximum quantities with multiple items in cart
This currently fails
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user