detail_view_spec.rb 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Mobile > User > Preview detailed information about user', app: :mobile, type: :system do
  4. let(:organization) { create(:organization) }
  5. let(:user) { create(:customer, firstname: 'Blanche', lastname: 'Devereaux', organization: organization, address: 'Berlin') }
  6. let(:group) { create(:group) }
  7. let(:agent) { create(:agent, groups: [group]) }
  8. def open_user
  9. visit "/users/#{user.id}"
  10. wait_for_query('user')
  11. wait_for_subscription_start('userUpdates')
  12. end
  13. context 'when visiting as agent', authenticated_as: :agent do
  14. it 'shows general information' do
  15. open_user
  16. expect(page).to have_text(user.fullname)
  17. expect(find('section', text: %r{Address})).to have_text(user.address)
  18. user.update!(firstname: 'Rose', lastname: 'Nylund', address: 'Hamburg')
  19. expect(page).to have_text('Rose Nylund')
  20. expect(find('section', text: %r{Address})).to have_text('Hamburg')
  21. end
  22. it 'can load all secondary organizations' do
  23. organizations = create_list(:organization, 5)
  24. user.update(organizations: organizations)
  25. open_user
  26. expect(page).to have_text(organizations[0].name)
  27. expect(page).to have_text(organizations[1].name)
  28. expect(page).to have_text(organizations[2].name)
  29. expect(page).to have_no_text(organizations[3].name)
  30. click('button', text: 'Show 2 more')
  31. wait_for_query('user', number: 2)
  32. expect(page).to have_text(organizations[3].name)
  33. expect(page).to have_text(organizations[4].name)
  34. end
  35. end
  36. context 'when visiting as customer', authenticated_as: :user do
  37. it 'redirects to error' do
  38. visit '/users/1'
  39. expect_current_route('/error')
  40. end
  41. end
  42. it 'can open ticket create form' do
  43. open_user
  44. click_on 'Create new ticket for this user'
  45. expect_current_route("/tickets/create?customer_id=#{user.id}")
  46. within_form(form_updater_gql_number: 1) do
  47. find_input('Title').type(Faker::Name.unique.name_with_middle)
  48. # open "additional information" step
  49. find_button('Continue').click
  50. find_button('Continue').click
  51. expect(find_autocomplete('Customer')).to have_selected_option(user.fullname)
  52. end
  53. end
  54. end