admin_overview_test.rb 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'browser_test_helper'
  3. class AdminOverviewTest < TestCase
  4. def test_account_add
  5. name = "some overview #{SecureRandom.uuid}"
  6. @browser = browser_instance
  7. login(
  8. username: 'admin@example.com',
  9. password: 'test',
  10. url: browser_url,
  11. )
  12. tasks_close_all
  13. # add new overview
  14. overview_create(
  15. data: {
  16. name: name,
  17. roles: ['Agent'],
  18. selector: {
  19. 'Priority' => '1 low',
  20. },
  21. 'order::direction' => 'descending',
  22. }
  23. )
  24. # edit overview
  25. overview_update(
  26. data: {
  27. name: name,
  28. roles: ['Agent'],
  29. selector: {
  30. 'State' => 'new',
  31. },
  32. 'order::direction' => 'ascending',
  33. }
  34. )
  35. end
  36. def test_overview_group_by_direction
  37. name = "overview_#{SecureRandom.uuid}"
  38. ticket_titles = (1..3).map { |i| "Priority #{i} ticket" }
  39. @browser = browser_instance
  40. login(
  41. username: 'admin@example.com',
  42. password: 'test',
  43. url: browser_url,
  44. )
  45. tasks_close_all
  46. ticket_create(
  47. data: {
  48. customer: 'nico',
  49. group: 'Users',
  50. title: 'Priority 1 ticket',
  51. body: 'some body 123äöü',
  52. priority: '1 low',
  53. },
  54. )
  55. ticket_create(
  56. data: {
  57. customer: 'nico',
  58. group: 'Users',
  59. title: 'Priority 2 ticket',
  60. body: 'some body 123äöü',
  61. priority: '2 normal',
  62. },
  63. )
  64. ticket_create(
  65. data: {
  66. customer: 'nico',
  67. group: 'Users',
  68. title: 'Priority 3 ticket',
  69. body: 'some body 123äöü',
  70. priority: '3 high',
  71. },
  72. )
  73. # Add new overview to sort groups from high to low
  74. overview_create(
  75. data: {
  76. name: name,
  77. roles: ['Agent'],
  78. selector: {
  79. 'State' => 'open',
  80. },
  81. 'order::direction' => 'descending',
  82. group_by: 'Priority',
  83. group_direction: 'descending',
  84. }
  85. )
  86. overview_open(
  87. name: name
  88. )
  89. assert_equal(ticket_titles.reverse, ordered_ticket_titles(ticket_titles))
  90. # Update overview to sort groups from low to high
  91. overview_update(
  92. data: {
  93. name: name,
  94. group_direction: 'ascending',
  95. }
  96. )
  97. overview_open(
  98. name: name
  99. )
  100. # wait till the scheduler pushed
  101. # the changes to the FE
  102. sleep 5
  103. assert_equal(ticket_titles, ordered_ticket_titles(ticket_titles))
  104. end
  105. def ordered_ticket_titles(ticket_titles)
  106. ticket_titles.map do |title|
  107. [title,
  108. get_location(css: "td[title='#{title}']").y]
  109. end.sort_by { |x| x[1] }.pluck(0)
  110. end
  111. # verify fix for issue #2235 - Overview setting isn't applied on submit
  112. def test_overview_toggle_out_of_office_setting
  113. @browser = browser_instance
  114. login(
  115. username: 'admin@example.com',
  116. password: 'test',
  117. url: browser_url,
  118. )
  119. tasks_close_all
  120. out_of_office_css = '.content.active .modal select[name="out_of_office"]'
  121. first_overview_css = '.content.active tr[data-id="1"] td'
  122. click(css: 'a[href="#manage"]')
  123. click(css: '.content.active a[href="#manage/overviews"]')
  124. # round 1, open the overview and set out_of_office to true
  125. click(css: first_overview_css)
  126. modal_ready
  127. watch_for(
  128. css: out_of_office_css,
  129. value: 'no',
  130. )
  131. select(
  132. css: out_of_office_css,
  133. value: 'yes',
  134. )
  135. click(css: '.content.active .modal .js-submit')
  136. modal_disappear
  137. # round 2, open the overview and set out_of_office back to false
  138. click(css: first_overview_css)
  139. modal_ready
  140. watch_for(
  141. css: out_of_office_css,
  142. value: 'yes',
  143. )
  144. select(
  145. css: out_of_office_css,
  146. value: 'no',
  147. )
  148. click(css: '.content.active .modal .js-submit')
  149. modal_disappear
  150. # round 3, open the overview and confirm that it's still false
  151. click(css: first_overview_css)
  152. modal_ready
  153. watch_for(
  154. css: out_of_office_css,
  155. value: 'no',
  156. )
  157. click(css: '.content.active .modal .js-submit')
  158. modal_disappear
  159. end
  160. end