groups_spec.rb 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'system/examples/core_workflow_examples'
  4. require 'system/examples/pagination_examples'
  5. RSpec.describe 'Manage > Groups', type: :system do
  6. context 'ajax pagination' do
  7. include_examples 'pagination', model: :group, klass: Group, path: 'manage/groups', create_params: { email_address_id: 1 }
  8. end
  9. describe 'with nested groups' do
  10. let(:group1) { create(:group) }
  11. let(:group2) { create(:group, parent: group1) }
  12. let(:group3) { create(:group, parent: group2) }
  13. before do
  14. group3 # cascade create
  15. visit '#manage/groups'
  16. end
  17. it 'displays complete group path using chevrons' do
  18. expect(page).to have_text(group3.name.gsub!(%r{::}, ' › '))
  19. end
  20. it 'sorts group paths in correct order' do
  21. expect(page).to have_text("#{group1.fullname}\n#{group2.fullname}\n#{group3.fullname}")
  22. end
  23. describe 'when creating a new group' do
  24. let(:group_name_last) { Faker::Lorem.unique.word.capitalize }
  25. before do
  26. click_on 'New Group'
  27. end
  28. it 'creates a nested group' do
  29. fill_in 'Name', with: group_name_last
  30. set_tree_select_value('parent_id', group3.fullname)
  31. # Needed for chrome, when element is outside viewport.
  32. scroll_into_view('button.js-submit', position: :bottom)
  33. click_on 'Submit'
  34. expect(Group.last.name).to eq("#{group3.name}::#{Group.last.name_last}")
  35. end
  36. end
  37. end
  38. # Fixes GitHub Issue#3129 - Deactivation of signature does not clear it from groups
  39. describe 'When active status of signature assigned to a group is changed', authenticated_as: -> { user } do
  40. let(:user) { create(:admin, groups: [group]) }
  41. let(:group) { create(:group, signature_id: signature.id) }
  42. let(:signature) { create(:signature) }
  43. it 'does not display warning, when signature is active' do
  44. visit '#manage/groups'
  45. click "tr[data-id='#{group.id}']"
  46. expect(page).to have_select('signature_id', selected: signature.name)
  47. .and have_no_css('.alert--warning')
  48. end
  49. context 'When signature is marked inactive' do
  50. let(:signature) { create(:signature, active: false) }
  51. it 'displays warning' do
  52. visit '#manage/groups'
  53. click "tr[data-id='#{group.id}']"
  54. expect(page).to have_select('signature_id', selected: signature.name)
  55. .and have_css('.alert--warning')
  56. end
  57. end
  58. end
  59. describe 'Core Workflow' do
  60. include_examples 'core workflow' do
  61. let(:object_name) { 'Group' }
  62. let(:before_it) do
  63. lambda {
  64. ensure_websocket(check_if_pinged: false) do
  65. visit 'manage/groups'
  66. click_on 'New Group'
  67. end
  68. }
  69. end
  70. end
  71. end
  72. context "Issue 2544 - Can't remove auto assignment timeout" do
  73. before do
  74. visit '/#manage/groups'
  75. end
  76. it 'is possible to reset the assignment timeout of a group' do
  77. find('td', text: 'Users').click
  78. in_modal do
  79. fill_in 'Assignment Timeout', with: '30'
  80. # Needed for chrome, when element is outside viewport.
  81. scroll_into_view('button.js-submit', position: :bottom)
  82. click_on 'Submit'
  83. end
  84. expect(Group.find_by(name: 'Users').assignment_timeout).to eq(30)
  85. find('td', text: 'Users').click
  86. in_modal do
  87. fill_in 'Assignment Timeout', with: ''
  88. # Needed for chrome, when element is outside viewport.
  89. scroll_into_view('button.js-submit', position: :bottom)
  90. click_on 'Submit'
  91. end
  92. expect(Group.find_by(name: 'Users').assignment_timeout).to be_nil
  93. end
  94. end
  95. context 'Issue 4129 - Tooltips are not displayed correctly' do
  96. before do
  97. visit '/#manage/groups'
  98. end
  99. it 'renders tooltips correctly' do
  100. find('td', text: 'Users').click
  101. in_modal do
  102. find('div.select[data-attribute-name="follow_up_possible"] .js-helpMessage').hover
  103. expect(page).to have_css('div.tooltip')
  104. end
  105. end
  106. end
  107. describe 'Issue #4475 - Group edit dialog shows ??? in email select box', authenticated_as: -> { user } do
  108. let(:user) { create(:admin, groups: [group]) }
  109. let(:email_address) { create(:email_address) }
  110. let(:group) { create(:group, email_address: email_address) }
  111. it 'shows correct email address display name' do
  112. visit '#manage/groups'
  113. click "tr[data-id='#{group.id}']"
  114. expect(page).to have_select('email_address_id', text: "#{email_address.name} <#{email_address.email}>")
  115. end
  116. end
  117. end