From d8eaee2f3d713db26e9b6410ff7f014c90fa1ed0 Mon Sep 17 00:00:00 2001 From: Augusto Xavier Date: Tue, 16 Jun 2026 11:44:01 -0300 Subject: [PATCH] Reorder and relabel transfer action buttons to Undo (5560) --- app/views/transfers/_transfer_row.html.erb | 2 +- spec/requests/transfers_request_spec.rb | 35 ++++++++++++++++++++++ spec/system/transfer_system_spec.rb | 4 +-- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 spec/requests/transfers_request_spec.rb diff --git a/app/views/transfers/_transfer_row.html.erb b/app/views/transfers/_transfer_row.html.erb index 46517e21df..6cad21d0cd 100644 --- a/app/views/transfers/_transfer_row.html.erb +++ b/app/views/transfers/_transfer_row.html.erb @@ -5,7 +5,7 @@ <%= transfer_row.comment || "none" %> <%= transfer_row.line_items.total %> - <%= delete_button_to transfer_path(transfer_row.id), { confirm: "Are you sure you want to permanently remove this transfer?" } %> <%= view_button_to transfer_row %> + <%= delete_button_to transfer_path(transfer_row.id), { text: "Undo", icon: "undo", confirm: "Are you sure you want to undo this transfer?" } %> diff --git a/spec/requests/transfers_request_spec.rb b/spec/requests/transfers_request_spec.rb new file mode 100644 index 0000000000..82a397d2f2 --- /dev/null +++ b/spec/requests/transfers_request_spec.rb @@ -0,0 +1,35 @@ +RSpec.describe "Transfers", type: :request do + let(:organization) { create(:organization) } + let(:user) { create(:user, organization: organization) } + + before { sign_in(user) } + + describe "GET #index" do + let!(:transfer) { create(:transfer, organization: organization) } + + it "renders the View button before the Undo button" do + get transfers_path + + view_position = response.body.index("fa-search") + undo_position = response.body.index("fa-undo") + + expect(view_position).to be_present + expect(undo_position).to be_present + expect(view_position).to be < undo_position + end + + it "labels the destructive action as Undo with the undo icon" do + get transfers_path + + expect(response.body).to include("Undo") + expect(response.body).to include("fa-undo") + expect(response.body).not_to include("fa-trash") + end + + it "asks for confirmation worded as an undo" do + get transfers_path + + expect(response.body).to include("Are you sure you want to undo this transfer?") + end + end +end diff --git a/spec/system/transfer_system_spec.rb b/spec/system/transfer_system_spec.rb index cb56b31337..4b15b83eb1 100644 --- a/spec/system/transfer_system_spec.rb +++ b/spec/system/transfer_system_spec.rb @@ -80,7 +80,7 @@ def create_transfer(amount, from_name, to_name, click_save: true, click_confirm: expect(inventory.quantity_for(storage_location: to_storage_location.id, item_id: item.id)).to eq(transfer_amount) accept_confirm do - click_button 'Delete' + click_button 'Undo' end expect(page).to have_content(/Successfully deleted Transfer/) @@ -109,7 +109,7 @@ def create_transfer(amount, from_name, to_name, click_save: true, click_confirm: allow(TransferDestroyEvent).to receive(:publish).and_raise('OH NOES') accept_confirm do - click_button 'Delete' + click_button 'Undo' end expect(page).to have_content(/OH NOES/)