agent_user_manage_test.rb 6.5 KB

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