customer_spec.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Mobile > Ticket > Update Customer', app: :mobile, authenticated_as: :agent, type: :system do
  4. let(:group) { create(:group) }
  5. let(:agent) { create(:agent, groups: [group]) }
  6. let(:ticket) { create(:ticket, group: group) }
  7. before do
  8. visit "/tickets/#{ticket.id}"
  9. click_on 'Show ticket actions'
  10. click_on 'Change customer'
  11. end
  12. context 'with a single-organization customer' do
  13. let(:organization) { create(:organization) }
  14. let(:customer) { create(:customer, organization: organization) }
  15. it 'allows selecting customer' do
  16. find_autocomplete('Customer').search_for_option(customer.email, label: customer.fullname)
  17. click_on 'Save'
  18. wait.until do
  19. ticket.reload.customer == customer && ticket.organization = organization
  20. end
  21. end
  22. end
  23. context 'with a multi-organization customer' do
  24. let(:organization) { create(:organization) }
  25. let(:secondary_orgs) { create_list(:organization, 2) }
  26. let(:customer) { create(:customer, organization: organization, organizations: secondary_orgs) }
  27. it 'allows selecting customer' do
  28. find_autocomplete('Customer').search_for_option(customer.email, label: customer.fullname)
  29. find_autocomplete('Organization').search_for_option(secondary_orgs.last.name)
  30. click_on 'Save'
  31. wait.until do
  32. ticket.reload.customer == customer && ticket.organization == secondary_orgs.last
  33. end
  34. end
  35. end
  36. end