Skip to content

Commit

Permalink
11987: add failing spec for product clone
Browse files Browse the repository at this point in the history
  • Loading branch information
chahmedejaz committed Jun 26, 2024
1 parent 4315a05 commit b1a3bff
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions spec/system/admin/products_v3/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1198,13 +1198,9 @@ def expect_other_columns_visible
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
Expand All @@ -1213,6 +1209,21 @@ def expect_other_columns_visible
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

Expand Down Expand Up @@ -1587,4 +1598,11 @@ def random_tax_category
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

0 comments on commit b1a3bff

Please sign in to comment.