mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add feature specs for full cart page stock correction process
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
.row.links{'data-hook' => "cart_buttons"}
|
||||
%a.button.large.secondary{href: current_shop_products_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true}
|
||||
%a.continue-shopping.button.large.secondary{href: current_shop_products_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true}
|
||||
= t :orders_edit_continue
|
||||
%a#checkout-link.button.large.primary.right{href: main_app.checkout_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true}
|
||||
= t :orders_edit_checkout
|
||||
|
||||
@@ -201,6 +201,40 @@ feature "full-page cart", js: true do
|
||||
expect(page).to have_content "Insufficient stock available, only 2 remaining"
|
||||
expect(page).to have_field "order_line_items_attributes_0_quantity", with: '1'
|
||||
end
|
||||
|
||||
describe "full UX for correcting selected quantities with insufficient stock" do
|
||||
before do
|
||||
add_product_to_cart order, product_with_tax, quantity: 5
|
||||
variant.update_attributes! on_hand: 4, on_demand: false
|
||||
end
|
||||
|
||||
it "gives clear user feedback during the correcting process" do
|
||||
visit main_app.cart_path
|
||||
|
||||
# shows a relevant Flash message
|
||||
expect(page).to have_selector ".alert-box", text: I18n.t('spree.orders.error_flash_for_unavailable_items')
|
||||
|
||||
# "Continue Shopping" and "Checkout" buttons are disabled
|
||||
expect(page).to have_selector "a.continue-shopping[disabled=disabled]"
|
||||
expect(page).to have_selector "a#checkout-link[disabled=disabled]"
|
||||
|
||||
# Quantity field clearly marked as invalid and "Update" button is not highlighted
|
||||
expect(page).to have_selector "#order_line_items_attributes_0_quantity.ng-invalid-stock"
|
||||
expect(page).to_not have_selector "#update-button.alert"
|
||||
|
||||
fill_in "order_line_items_attributes_0_quantity", with: 4
|
||||
|
||||
# Quantity field not marked as invalid and "Update" button is highlighted after correction
|
||||
expect(page).to_not have_selector "#order_line_items_attributes_0_quantity.ng-invalid-stock"
|
||||
expect(page).to have_selector "#update-button.alert"
|
||||
|
||||
click_button I18n.t("update")
|
||||
|
||||
# "Continue Shopping" and "Checkout" buttons are not disabled after cart is updated
|
||||
expect(page).to_not have_selector "a.continue-shopping[disabled=disabled]"
|
||||
expect(page).to_not have_selector "a#checkout-link[disabled=disabled]"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user