From 81cc951ed4a0ac49f4e87fb74e6412d8d6c15962 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 1 Jul 2020 11:27:27 +1000 Subject: [PATCH] Name symbols on quantity buttons in specs --- spec/features/consumer/shopping/shopping_spec.rb | 4 ++-- spec/support/request/shop_workflow.rb | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 6cdc2bccb3..0a9dec3a17 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -311,7 +311,7 @@ feature "As a consumer I want to shop with a distributor", js: true do within_variant(variant) do expect(page).to have_content "5 in cart" - expect(page).to have_button "+", disabled: true + expect(page).to have_button increase_quantity_symbol, disabled: true end end @@ -364,7 +364,7 @@ feature "As a consumer I want to shop with a distributor", js: true do # -- Messaging within(".reveal-modal") do - page.all("button", text: "+").last.click + page.all("button", text: increase_quantity_symbol).last.click end close_modal wait_for_cart diff --git a/spec/support/request/shop_workflow.rb b/spec/support/request/shop_workflow.rb index 11a79832a5..b1ede3ae8c 100644 --- a/spec/support/request/shop_workflow.rb +++ b/spec/support/request/shop_workflow.rb @@ -47,14 +47,14 @@ module ShopWorkflow def click_add_to_cart(variant = nil, quantity = 1) within_variant(variant) do click_button "Add" - (quantity - 1).times { click_button "+" } + (quantity - 1).times { click_button increase_quantity_symbol } end wait_for_cart end def click_remove_from_cart(variant = nil, quantity = 1) within_variant(variant) do - quantity.times { click_button "-" } + quantity.times { click_button decrease_quantity_symbol } end wait_for_cart end @@ -65,7 +65,7 @@ module ShopWorkflow end within(".reveal-modal") do (quantity - 1).times do - first(:button, "+").click + first(:button, increase_quantity_symbol).click end end wait_for_cart @@ -74,7 +74,7 @@ module ShopWorkflow def click_add_bulk_max_to_cart(variant = nil, quantity = 1) within(".reveal-modal") do quantity.times do - page.all("button", text: "+").last.click + page.all("button", text: increase_quantity_symbol).last.click end end wait_for_cart @@ -94,6 +94,14 @@ module ShopWorkflow end end + def increase_quantity_symbol + "+" + end + + def decrease_quantity_symbol + "-" + end + def toggle_accordion(name) find("dd a", text: name).click end