profile_spec.rb 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'system/examples/core_workflow_examples'
  4. require 'system/examples/text_modules_examples'
  5. RSpec.describe 'User Profile', type: :system do
  6. let(:organizations) { create_list(:organization, 20) }
  7. let(:customer) { create(:customer, organization: organizations[0], organizations: organizations[1..]) }
  8. it 'does show the edit link' do
  9. visit "#user/profile/#{customer.id}"
  10. click '#userAction label'
  11. click_link 'Edit'
  12. modal_ready
  13. end
  14. describe 'object manager attributes maxlength', authenticated_as: :authenticate, db_strategy: :reset do
  15. def authenticate
  16. customer
  17. create(:object_manager_attribute_text, object_name: 'User', name: 'maxtest', display: 'maxtest', screens: attributes_for(:required_screen), data_option: {
  18. 'type' => 'text',
  19. 'maxlength' => 3,
  20. 'null' => true,
  21. 'translate' => false,
  22. 'default' => '',
  23. 'options' => {},
  24. 'relation' => '',
  25. })
  26. ObjectManager::Attribute.migration_execute
  27. true
  28. end
  29. it 'checks ticket create' do
  30. visit "#user/profile/#{customer.id}"
  31. within(:active_content) do
  32. page.find('.profile .js-action').click
  33. page.find('.profile li[data-type=edit]').click
  34. fill_in 'maxtest', with: 'hellu'
  35. expect(page.find_field('maxtest').value).to eq('hel')
  36. end
  37. end
  38. end
  39. describe 'Core Workflow' do
  40. include_examples 'core workflow' do
  41. let(:object_name) { 'User' }
  42. let(:before_it) do
  43. lambda {
  44. ensure_websocket(check_if_pinged: false) do
  45. visit "#user/profile/#{customer.id}"
  46. within(:active_content) do
  47. page.find('.profile .js-action').click
  48. page.find('.profile li[data-type=edit]').click
  49. end
  50. end
  51. }
  52. end
  53. end
  54. end
  55. it 'check that ignored attributes for user popover are not visible' do
  56. visit '/'
  57. fill_in id: 'global-search', with: customer.email
  58. popover_on_hover(find('.nav-tab--search.user'))
  59. expect(page).to have_css('.popover label', count: 2)
  60. end
  61. context 'Assign user to multiple organizations #1573', authenticated_as: :authenticate do
  62. def authenticate
  63. customer
  64. true
  65. end
  66. before do
  67. visit "#user/profile/#{customer.id}"
  68. end
  69. it 'shows only first 3 organizations and loads more on demand' do
  70. expect(page).to have_text(organizations[1].name)
  71. expect(page).to have_text(organizations[2].name)
  72. expect(page).to have_no_text(organizations[10].name)
  73. click '.js-showMoreOrganizations a'
  74. expect(page).to have_text(organizations[10].name)
  75. end
  76. end
  77. context 'when ticket changes in user profile', authenticated_as: :authenticate do
  78. let(:ticket) { create(:ticket, title: SecureRandom.uuid, customer: create(:customer, :with_org), group: Group.first) }
  79. def authenticate
  80. ticket
  81. true
  82. end
  83. before do
  84. visit "#user/profile/#{ticket.customer.id}"
  85. end
  86. it 'does update when ticket changes' do
  87. expect(page).to have_text(ticket.title)
  88. ticket.update(title: SecureRandom.uuid)
  89. expect(page).to have_text(ticket.title)
  90. end
  91. end
  92. describe 'Missing secondary organizations in user profile after refreshing with many secondary organizations. #4331' do
  93. before do
  94. visit "#user/profile/#{customer.id}"
  95. page.find('.profile .js-action').click
  96. page.find('.profile li[data-type=edit]').click
  97. end
  98. it 'does show all secondary organizations on edit' do
  99. tokens = page.all('div[data-attribute-name="organization_ids"] .token')
  100. expect(tokens.count).to eq(19)
  101. end
  102. end
  103. end