admin_overview_test.rb 4.1 KB

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