mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
11987: add failing spec for product clone
This commit is contained in:
@@ -1198,13 +1198,9 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi
|
||||
expect(input_content).not_to match /COPY OF Apples/
|
||||
end
|
||||
|
||||
within row_containing_name("Apples") do
|
||||
page.find(".vertical-ellipsis-menu").click
|
||||
click_link('Clone')
|
||||
end
|
||||
click_product_clone "Apples"
|
||||
|
||||
expect(page).to have_content "Successfully cloned the product"
|
||||
|
||||
within "table.products" do
|
||||
# Gather input values, because page.content doesn't include them.
|
||||
input_content = page.find_all('input[type=text]').map(&:value).join
|
||||
@@ -1213,6 +1209,21 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi
|
||||
expect(input_content).to match /COPY OF Apples/
|
||||
end
|
||||
end
|
||||
|
||||
it "fails to clone the product on page when clicked on the cloned option" do
|
||||
# Mock the +save+ method to return fail. That's the only expected fail case
|
||||
allow_any_instance_of(Spree::Product).to receive(:save).and_return(false)
|
||||
|
||||
click_product_clone "Apples"
|
||||
|
||||
expect(page).to have_content "Unable to clone the product"
|
||||
within "table.products" do
|
||||
# Gather input values, because page.content doesn't include them.
|
||||
input_content = page.find_all('input[type=text]').map(&:value).join
|
||||
# Products does not include the cloned product.
|
||||
expect(input_content).not_to match /COPY OF Apples/
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1587,4 +1598,11 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi
|
||||
def all_input_values
|
||||
page.find_all('input[type=text]').map(&:value).join
|
||||
end
|
||||
|
||||
def click_product_clone(product_name)
|
||||
within row_containing_name(product_name) do
|
||||
page.find(".vertical-ellipsis-menu").click
|
||||
click_link('Clone')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user