diff --git a/app/views/admin/products_v3/_table.html.haml b/app/views/admin/products_v3/_table.html.haml index 4d31694077..95dbf74398 100644 --- a/app/views/admin/products_v3/_table.html.haml +++ b/app/views/admin/products_v3/_table.html.haml @@ -9,7 +9,7 @@ .error = error_msg .form-buttons.six.columns - = form.submit t('.reset'), type: :reset, class: "medium" + = form.submit t('.reset'), type: :reset, class: "medium", 'data-reflex': 'click->products#fetch' = form.submit t('.save'), class: "medium" %table.products %col{ width:"15%" } diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 0a0c83cbe4..80f2bc19f0 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -205,6 +205,25 @@ describe 'As an admin, I can see the new product page' do pending expect(page).to have_content "Changes saved" end + + it "can discard changes and reload latest data" do + within row_containing_name("Apples") do + fill_in "Name", with: "Pommes" + end + + # Meanwhile, the SKU was updated + product_a.update! sku: "APL-10" + + expect { + click_button "Discard changes" + product_a.reload + }.to_not change { product_a.name } + + within row_containing_name("Apples") do + expect(page).to have_field "Name", with: "Apples" # Changed value wasn't saved + expect(page).to have_field "SKU", with: "APL-10" # Updated value shown + end + end end def expect_page_to_be(page_number)