merge_spec.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Ticket zoom > Merge action', type: :system do
  4. describe 'ticket merge action' do
  5. context 'when source ticket is merged to target ticket' do
  6. let(:source_ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
  7. let(:target_ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
  8. let(:search_term) { target_ticket.number }
  9. before do
  10. visit "#ticket/zoom/#{source_ticket.id}"
  11. end
  12. shared_examples 'merges to target ticket' do
  13. it 'merges to target ticket' do
  14. find('[data-tab="ticket"] .js-actions').click
  15. click('[data-type="ticket-merge"]')
  16. in_modal do
  17. find('input[name="target_ticket_number"]').fill_in with: search_term
  18. # trigger the paste event to replace the ticket hook, if present
  19. execute_script('$("input[name=\"target_ticket_number\"]").trigger("paste")')
  20. click('.js-submit')
  21. end
  22. await_empty_ajax_queue
  23. meta_ticket_number = find('.active .ticketZoom-header .ticket-number')
  24. expect(meta_ticket_number.text).to eq(target_ticket.number)
  25. end
  26. end
  27. context 'when input field is used without ticket hook' do
  28. include_examples 'merges to target ticket'
  29. end
  30. context 'when input field is used with ticket hook' do
  31. let(:search_term) { Setting.get('ticket_hook') + target_ticket.number }
  32. include_examples 'merges to target ticket'
  33. end
  34. end
  35. end
  36. end