mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Adjust specs for new cart display
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
\:
|
||||
{{ Cart.total() | localizeCurrency }}
|
||||
|
||||
%a.button.large.dark.left{href: main_app.cart_path, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }"}
|
||||
%a.edit-cart.button.large.dark.left{href: main_app.cart_path, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }"}
|
||||
= "{{ Cart.dirty ? '#{t(:cart_updating)}' : (Cart.empty() ? '#{t(:cart_empty)}' : '#{t('.edit_cart')}' ) }}"
|
||||
%a.button.large.bright.right{href: main_app.checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
|
||||
%a.checkout.button.large.bright.right{href: main_app.checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
|
||||
= t '.checkout'
|
||||
|
||||
@@ -105,8 +105,9 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
|
||||
# -- Cart shows correct price
|
||||
fill_in "variants[#{variant.id}]", with: 1
|
||||
show_cart
|
||||
within("li.cart") { expect(page).to have_content with_currency(1020.99) }
|
||||
toggle_cart
|
||||
within(".cart-sidebar") { expect(page).to have_content with_currency(1020.99) }
|
||||
toggle_cart
|
||||
|
||||
# -- Changing order cycle
|
||||
accept_alert do
|
||||
@@ -119,8 +120,9 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
# that we are not filling in the quantity on the outgoing row
|
||||
expect(page).not_to have_selector "tr.product-cart"
|
||||
within('product:not(.ng-leave)') { fill_in "variants[#{variant.id}]", with: 1 }
|
||||
show_cart
|
||||
within("li.cart") { expect(page).to have_content with_currency(19.99) }
|
||||
|
||||
toggle_cart
|
||||
within(".cart-sidebar") { expect(page).to have_content with_currency(19.99) }
|
||||
end
|
||||
|
||||
describe "declining to clear the cart" do
|
||||
@@ -136,9 +138,9 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
it "leaves the cart untouched when the user declines" do
|
||||
handle_js_confirm(false) do
|
||||
select "frogs", from: "order_cycle_id"
|
||||
show_cart
|
||||
toggle_cart
|
||||
expect(page).to have_selector "tr.product-cart"
|
||||
expect(page).to have_selector 'li.cart', text: '1'
|
||||
expect(page).to have_selector '.cart-sidebar', text: '1'
|
||||
|
||||
# The order cycle choice should not have changed
|
||||
expect(page).to have_select 'order_cycle_id', selected: 'turtles'
|
||||
@@ -294,7 +296,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
expect(li.quantity).to eq(1)
|
||||
|
||||
fill_in "variants[#{variant.id}]", with: '0'
|
||||
within('li.cart') { expect(page).not_to have_content product.name }
|
||||
within('.cart-sidebar') { expect(page).not_to have_content product.name }
|
||||
wait_until { !cart_dirty }
|
||||
|
||||
expect(Spree::LineItem.where(id: li)).to be_empty
|
||||
|
||||
@@ -67,8 +67,8 @@ feature "shopping with variant overrides defined", js: true do
|
||||
|
||||
it "shows the correct prices when products are in the cart" do
|
||||
fill_in "variants[#{product1_variant1.id}]", with: "2"
|
||||
show_cart
|
||||
wait_until_enabled 'li.cart a.button'
|
||||
toggle_cart
|
||||
wait_until_enabled '.cart-sidebar a.edit-cart'
|
||||
visit shop_path
|
||||
expect(page).to have_price with_currency(61.11)
|
||||
end
|
||||
@@ -78,9 +78,8 @@ feature "shopping with variant overrides defined", js: true do
|
||||
|
||||
it "shows the overridden price with fees in the quick cart" do
|
||||
fill_in "variants[#{product1_variant1.id}]", with: "2"
|
||||
show_cart
|
||||
toggle_cart
|
||||
expect(page).to have_selector "#cart-variant-#{product1_variant1.id} .quantity", text: '2'
|
||||
expect(page).to have_selector "#cart-variant-#{product1_variant1.id} .price", text: with_currency(61.11)
|
||||
expect(page).to have_selector "#cart-variant-#{product1_variant1.id} .total-price", text: with_currency(122.22)
|
||||
end
|
||||
|
||||
@@ -202,8 +201,8 @@ feature "shopping with variant overrides defined", js: true do
|
||||
end
|
||||
|
||||
def click_checkout
|
||||
show_cart
|
||||
wait_until_enabled 'li.cart a.button'
|
||||
first(:link, 'Checkout now').click
|
||||
toggle_cart
|
||||
wait_until_enabled '.cart-sidebar a.edit-cart'
|
||||
first(:link, I18n.t('shared.menu.cart_sidebar.checkout')).click
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,25 +49,9 @@ describe 'Variants service', ->
|
||||
variant = {product_name: 'product_name', name_to_display: 'product_name'}
|
||||
expect(Variants.extendedVariantName(variant)).toEqual "product_name"
|
||||
|
||||
it "includes the options text even if variant name is same as product", ->
|
||||
variant =
|
||||
product_name: 'product_name'
|
||||
name_to_display: 'product_name'
|
||||
options_text: 'options_text'
|
||||
|
||||
expect(Variants.extendedVariantName(variant)).toEqual "product_name (options_text)"
|
||||
|
||||
describe "when the product name and the variant name differ", ->
|
||||
it "returns a combined name when there is no options text", ->
|
||||
variant =
|
||||
product_name: 'product_name'
|
||||
name_to_display: 'name_to_display'
|
||||
expect(Variants.extendedVariantName(variant)).toEqual "product_name - name_to_display"
|
||||
|
||||
it "returns a combined name when there is some options text", ->
|
||||
variant =
|
||||
product_name: 'product_name'
|
||||
name_to_display: 'name_to_display'
|
||||
options_text: 'options_text'
|
||||
|
||||
expect(Variants.extendedVariantName(variant)).toEqual "product_name - name_to_display (options_text)"
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
module ShopWorkflow
|
||||
def wait_for_cart
|
||||
first("#cart").click
|
||||
within '.cart-dropdown' do
|
||||
within '.cart-sidebar' do
|
||||
expect(page).to_not have_link "Updating cart..."
|
||||
end
|
||||
end
|
||||
|
||||
def edit_cart
|
||||
wait_for_cart
|
||||
within '.cart-dropdown' do
|
||||
expect(page).to have_link "Edit your cart"
|
||||
within '.cart-sidebar' do
|
||||
expect(page).to have_link I18n.t('shared.menu.cart_sidebar.edit_cart')
|
||||
end
|
||||
first("a.add_to_cart").click
|
||||
first("a.edit-cart").click
|
||||
end
|
||||
|
||||
def have_price(price)
|
||||
|
||||
@@ -59,13 +59,13 @@ module UIComponentHelper
|
||||
end
|
||||
|
||||
def have_in_cart(name)
|
||||
show_cart
|
||||
within "li.cart" do
|
||||
toggle_cart
|
||||
within ".cart-sidebar" do
|
||||
have_content name
|
||||
end
|
||||
end
|
||||
|
||||
def show_cart
|
||||
def toggle_cart
|
||||
page.find("#cart").click
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user