ticket_information_customer_spec.rb 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Mobile > Ticket > Customer > Preview customer information', 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(:ticket) { create(:ticket, customer: user, group: group) }
  7. let(:group) { create(:group) }
  8. let(:agent) { create(:agent, groups: [group]) }
  9. def open_user
  10. visit "/tickets/#{ticket.id}/information/customer"
  11. wait_for_gql('shared/entities/object-attributes/graphql/queries/objectManagerFrontendAttributes.graphql')
  12. wait_for_gql('apps/mobile/entities/user/graphql/queries/user.graphql')
  13. wait_for_gql('apps/mobile/pages/ticket/graphql/queries/ticket.graphql')
  14. end
  15. context 'when visiting as agent', authenticated_as: :agent do
  16. it 'shows general information' do
  17. open_user
  18. expect(page).to have_text(ticket.title)
  19. expect(page).to have_text(user.fullname)
  20. expect(find('section', text: %r{Address})).to have_text(user.address)
  21. expect(page).to have_text('Edit Customer')
  22. user.update!(firstname: 'Rose', lastname: 'Nylund')
  23. wait_for_gql('shared/graphql/subscriptions/userUpdates.graphql')
  24. expect(page).to have_text('Rose Nylund')
  25. end
  26. it 'can load all secondary organizations' do
  27. organizations = create_list(:organization, 5)
  28. user.update(organizations: organizations)
  29. open_user
  30. expect(page).to have_text(organizations[0].name)
  31. expect(page).to have_text(organizations[1].name)
  32. expect(page).to have_text(organizations[2].name)
  33. expect(page).to have_no_text(organizations[3].name)
  34. click('button', text: 'Show 2 more')
  35. wait_for_gql('apps/mobile/entities/user/graphql/queries/user.graphql', number: 2)
  36. expect(page).to have_text(organizations[3].name)
  37. expect(page).to have_text(organizations[4].name)
  38. end
  39. end
  40. context 'when visiting as customer', authenticated_as: :user do
  41. it 'see the same content, but can\'t edit' do
  42. open_user
  43. expect(page).to have_text(ticket.title)
  44. expect(page).to have_text(user.fullname)
  45. expect(page).to have_no_text('Edit Customer')
  46. expect(find('section', text: %r{Address})).to have_text(user.address)
  47. user.update!(firstname: 'Rose')
  48. wait_for_gql('shared/graphql/subscriptions/userUpdates.graphql')
  49. expect(page).to have_text('Rose Devereaux')
  50. end
  51. end
  52. end