From 5849ae57de2064c7b62a6eac633c3ac972ba8f50 Mon Sep 17 00:00:00 2001 From: piyush828-design Date: Wed, 16 Apr 2025 12:11:52 +0530 Subject: [PATCH 1/2] Added tests for edit and delete --- .../configuration/shipping_categories_spec.rb | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/spec/system/admin/configuration/shipping_categories_spec.rb b/spec/system/admin/configuration/shipping_categories_spec.rb index ea2fc73142..a890508486 100644 --- a/spec/system/admin/configuration/shipping_categories_spec.rb +++ b/spec/system/admin/configuration/shipping_categories_spec.rb @@ -36,4 +36,43 @@ RSpec.describe "Shipping Categories" do end end end + + context 'user edits an existing shipping category' do + it 'updates the shipping category properties' do + category = create(:shipping_category, name: "Regular", temperature_controlled: false) + + login_as_admin + visit spree.edit_admin_shipping_category_path(category) + + fill_in "shipping_category_name", with: "Express" + check "shipping_category_temperature_controlled" + click_button "Update" + + expect(page).to have_content("successfully updated!") + expect(page).to have_content("Express") + row = find('tr', text: 'Express') + within row do + expect(page).to have_content "Yes" + end + + expect(page).not_to have_content("Regular") + end + end + + context 'user deletes a shipping category' do + it 'removes the shipping category from the list' do + create(:shipping_category, name: "To Be Deleted") + + login_as_admin + visit spree.admin_shipping_categories_path + + accept_confirm do + within find('tr', text: 'To Be Deleted') do + find('.icon-trash').click + end + end + + expect(page).not_to have_content("To Be Deleted") + end + end end From ed0b7f88a4578a42ad1cb38f0e569e67be964e48 Mon Sep 17 00:00:00 2001 From: piyush828-design Date: Tue, 22 Apr 2025 11:26:56 +0530 Subject: [PATCH 2/2] updated specs --- spec/system/admin/configuration/shipping_categories_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/system/admin/configuration/shipping_categories_spec.rb b/spec/system/admin/configuration/shipping_categories_spec.rb index a890508486..3cd42e211b 100644 --- a/spec/system/admin/configuration/shipping_categories_spec.rb +++ b/spec/system/admin/configuration/shipping_categories_spec.rb @@ -54,8 +54,10 @@ RSpec.describe "Shipping Categories" do within row do expect(page).to have_content "Yes" end + category.reload expect(page).not_to have_content("Regular") + expect(category.name).to eq("Express") end end @@ -73,6 +75,7 @@ RSpec.describe "Shipping Categories" do end expect(page).not_to have_content("To Be Deleted") + expect(Spree::ShippingCategory.count).to eq(0) end end end