agent_user_manage_test.rb 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'browser_test_helper'
  3. class AgentUserManageTest < TestCase
  4. def test_agent_customer_ticket_create
  5. random_number = SecureRandom.uuid
  6. customer_user_email = "customer-test-#{random_number}@example.com"
  7. firstname = "Customer Firstname #{random_number}"
  8. lastname = 'Customer Lastname'
  9. fullname = "\"#{firstname} #{lastname}\" <#{customer_user_email}>"
  10. @browser = browser_instance
  11. login(
  12. username: 'agent1@example.com',
  13. password: 'test',
  14. url: browser_url,
  15. )
  16. tasks_close_all
  17. # create customer
  18. click(css: 'a[href="#new"]', only_if_exists: true)
  19. click(css: 'a[href="#ticket/create"]')
  20. await_text(text: 'New Ticket')
  21. # Rumors say there is a modal reaper which will kill your modals if you dont sleep before a new ticket create
  22. sleep 3
  23. click(css: '.content.active .newTicket [name="customer_id_completion"]')
  24. # check if pulldown is open, it's not working stable via selenium
  25. @browser.execute_script("$('.active .newTicket .js-recipientDropdown').addClass('open')")
  26. sleep 1
  27. sendkey(value: :arrow_down)
  28. sleep 0.5
  29. click(css: '.content.active .newTicket .recipientList-entry.js-objectNew')
  30. modal_ready
  31. set(
  32. css: '.content.active .modal input[name="firstname"]',
  33. value: firstname,
  34. )
  35. set(
  36. css: '.content.active .modal input[name="lastname"]',
  37. value: lastname,
  38. )
  39. set(
  40. css: '.content.active .modal input[name="email"]',
  41. value: customer_user_email,
  42. )
  43. click(css: '.content.active .modal button.js-submit')
  44. modal_disappear
  45. sleep 4
  46. # check is used to check selected
  47. match(
  48. css: '.content.active .newTicket input[name="customer_id"]',
  49. value: '^\d+$',
  50. no_quote: true,
  51. )
  52. match(
  53. css: '.content.active .newTicket input[name="customer_id_completion"]',
  54. value: firstname,
  55. )
  56. match(
  57. css: '.content.active .newTicket input[name="customer_id_completion"]',
  58. value: lastname,
  59. )
  60. match(
  61. css: '.content.active .newTicket input[name="customer_id_completion"]',
  62. value: customer_user_email,
  63. )
  64. match(
  65. css: '.content.active .newTicket input[name="customer_id_completion"]',
  66. value: fullname,
  67. )
  68. # call new ticket screen again
  69. tasks_close_all
  70. # wait for user get indexed in elastic search
  71. await_global_search(query: random_number)
  72. click(css: 'a[href="#new"]', only_if_exists: true)
  73. click(css: 'a[href="#ticket/create"]')
  74. watch_for(
  75. css: '.content.active .newTicket',
  76. timeout: 1,
  77. )
  78. match(
  79. css: '.content.active .newTicket input[name="customer_id"]',
  80. value: '',
  81. )
  82. match(
  83. css: '.content.active .newTicket input[name="customer_id_completion"]',
  84. value: '',
  85. )
  86. set(
  87. css: '.content.active .newTicket input[name="customer_id_completion"]',
  88. value: customer_user_email,
  89. )
  90. sleep 3
  91. click(css: '.content.active .newTicket .recipientList-entry.js-object.is-active')
  92. sleep 1
  93. # check is used to check selected
  94. match(
  95. css: '.content.active .newTicket input[name="customer_id"]',
  96. value: '^\d+$',
  97. no_quote: true,
  98. )
  99. match(
  100. css: '.content.active .newTicket input[name="customer_id_completion"]',
  101. value: firstname,
  102. )
  103. match(
  104. css: '.content.active .newTicket input[name="customer_id_completion"]',
  105. value: lastname,
  106. )
  107. match(
  108. css: '.content.active .newTicket input[name="customer_id_completion"]',
  109. value: customer_user_email,
  110. )
  111. match(
  112. css: '.content.active .newTicket input[name="customer_id_completion"]',
  113. value: fullname,
  114. )
  115. end
  116. def test_agent_customer_ticket_zoom
  117. customer_user_email = "customer-test-#{SecureRandom.uuid}@example.com"
  118. firstname = 'Customer Firstname'
  119. lastname = 'Customer Lastname'
  120. fullname = "#{firstname} #{lastname} <#{customer_user_email}>"
  121. @browser = browser_instance
  122. login(
  123. username: 'agent1@example.com',
  124. password: 'test',
  125. url: browser_url,
  126. )
  127. tasks_close_all
  128. ticket_create(
  129. data: {
  130. customer: 'nico',
  131. group: 'Users',
  132. title: 'some changes',
  133. body: 'some body',
  134. },
  135. )
  136. watch_for(
  137. css: '.content.active .ticketZoom-header .ticket-number',
  138. value: '\d',
  139. )
  140. click(css: '.content.active .tabsSidebar-tabs .tabsSidebar-tab[data-tab="customer"]')
  141. match(
  142. css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]',
  143. value: 'Nicole Braun',
  144. )
  145. click(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"] .js-actions')
  146. click(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"] .js-actions li[data-type="customer-change"]')
  147. modal_ready
  148. click(css: '.content.active .modal [name="customer_id_completion"]')
  149. # check if pulldown is open, it's not working stable via selenium
  150. @browser.execute_script("$('.active .modal .js-recipientDropdown').addClass('open')")
  151. sleep 1
  152. sendkey(value: :arrow_down)
  153. sleep 0.5
  154. click(css: '.content.active .modal .recipientList-entry.js-objectNew')
  155. watch_for(
  156. css: '.content.active .modal input[name="firstname"]',
  157. timeout: 1,
  158. )
  159. set(
  160. css: '.content.active .modal input[name="firstname"]',
  161. value: firstname,
  162. )
  163. set(
  164. css: '.content.active .modal input[name="lastname"]',
  165. value: lastname,
  166. )
  167. set(
  168. css: '.content.active .modal input[name="email"]',
  169. value: customer_user_email,
  170. )
  171. # there are 2 models, take the correct one
  172. # click(css: '.content.active .modal button.js-submit')
  173. @browser.execute_script("$('.content.active .modal input[name=\"firstname\"]').closest('form').find('button.js-submit').trigger('click')")
  174. # check is used to check selected
  175. watch_for(
  176. css: '.content.active .modal input[name="customer_id"]',
  177. value: '^\d+$',
  178. no_quote: true,
  179. )
  180. match(
  181. css: '.content.active .modal input[name="customer_id_completion"]',
  182. value: firstname,
  183. )
  184. match(
  185. css: '.content.active .modal input[name="customer_id_completion"]',
  186. value: lastname,
  187. )
  188. match(
  189. css: '.content.active .modal input[name="customer_id_completion"]',
  190. value: customer_user_email,
  191. )
  192. match(
  193. css: '.content.active .modal input[name="customer_id_completion"]',
  194. value: fullname,
  195. )
  196. click(css: '.content.active .modal button.js-submit')
  197. modal_disappear
  198. watch_for(
  199. css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]',
  200. value: customer_user_email,
  201. timeout: 4,
  202. )
  203. end
  204. end