agent_ticket_create_reset_customer_selection_test.rb 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. require 'browser_test_helper'
  2. class AgentTicketCreateResetCustomerSelectionTest < TestCase
  3. def test_clear_customer
  4. @browser = browser_instance
  5. login(
  6. username: 'master@example.com',
  7. password: 'test',
  8. url: browser_url,
  9. )
  10. tasks_close_all()
  11. click(css: 'a[href="#new"]', only_if_exists: true)
  12. click(css: 'a[href="#ticket/create"]')
  13. watch_for(
  14. css: '.content.active .newTicket',
  15. timeout: 3,
  16. )
  17. exists(css: '.content.active .newTicket')
  18. exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
  19. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
  20. exists_not(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
  21. exists_not(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  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( "$('.content.active .newTicket .js-recipientDropdown').addClass('open')" )
  25. set(
  26. css: '.content.active .newTicket input[name="customer_id_completion"]',
  27. value: 'nicole',
  28. )
  29. watch_for(
  30. css: '.content.active .newTicket .js-recipientDropdown .recipientList.is-shown',
  31. value: 'Nicole',
  32. timeout: 3,
  33. )
  34. sendkey(value: :enter)
  35. sleep 1
  36. exists(css: '.content.active .newTicket')
  37. exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
  38. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
  39. exists(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
  40. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  41. set(
  42. css: '.content.active .newTicket input[name="customer_id_completion"]',
  43. value: '',
  44. )
  45. sendkey(value: :backspace)
  46. sleep 1
  47. exists(css: '.content.active .newTicket')
  48. exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
  49. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
  50. exists_not(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
  51. exists_not(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  52. set(
  53. css: '.content.active .newTicket input[name="title"]',
  54. value: 'some title',
  55. )
  56. set(
  57. css: '.content.active .newTicket div[data-name="body"]',
  58. value: 'some body',
  59. )
  60. select(
  61. css: '.content.active .newTicket select[name="group_id"]',
  62. value: 'Users',
  63. )
  64. click(css: '.content.active .newTicket .js-submit')
  65. watch_for(
  66. css: '.content.active .newTicket .user_autocompletion.form-group.has-error',
  67. )
  68. # cleanup
  69. tasks_close_all()
  70. end
  71. def test_clear_customer_use_email
  72. @browser = browser_instance
  73. login(
  74. username: 'master@example.com',
  75. password: 'test',
  76. url: browser_url,
  77. )
  78. tasks_close_all()
  79. click(css: 'a[href="#new"]', only_if_exists: true)
  80. click(css: 'a[href="#ticket/create"]')
  81. sleep 2
  82. exists(css: '.content.active .newTicket')
  83. exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
  84. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
  85. exists_not(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
  86. exists_not(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  87. click(css: '.content.active .newTicket [name="customer_id_completion"]')
  88. # check if pulldown is open, it's not working stable via selenium
  89. @browser.execute_script( "$('.content.active .newTicket .js-recipientDropdown').addClass('open')" )
  90. set(
  91. css: '.content.active .newTicket input[name="customer_id_completion"]',
  92. value: 'nicole',
  93. )
  94. watch_for(
  95. css: '.content.active .newTicket .js-recipientDropdown .recipientList.is-shown',
  96. value: 'Nicole',
  97. timeout: 3,
  98. )
  99. sendkey(value: :enter)
  100. sleep 1
  101. exists(css: '.content.active .newTicket')
  102. exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
  103. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
  104. exists(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
  105. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  106. set(
  107. css: '.content.active .newTicket input[name="customer_id_completion"]',
  108. value: '',
  109. )
  110. sendkey(value: :backspace)
  111. sleep 1
  112. exists(css: '.content.active .newTicket')
  113. exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
  114. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab.active[data-tab="template"]')
  115. exists_not(css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]')
  116. exists_not(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  117. set(
  118. css: '.content.active .newTicket input[name="customer_id_completion"]',
  119. value: 'somecustomer_not_existing_right_now@example.com',
  120. )
  121. set(
  122. css: '.content.active .newTicket input[name="title"]',
  123. value: 'some title',
  124. )
  125. set(
  126. css: '.content.active .newTicket div[data-name="body"]',
  127. value: 'some body',
  128. )
  129. select(
  130. css: '.content.active .newTicket select[name="group_id"]',
  131. value: 'Users',
  132. )
  133. click(css: '.content.active .newTicket .js-submit')
  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: 'somecustomer_not_existing_right_now@example.com',
  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. exists_not(
  147. css: '.content.active .modal .user_autocompletion.form-group.has-error',
  148. )
  149. click(css: '.content.active .modal .js-submit')
  150. watch_for(
  151. css: '.content.active .modal .user_autocompletion.form-group.has-error',
  152. )
  153. set(
  154. css: '.content.active .modal input[name="customer_id_completion"]',
  155. value: 'master',
  156. )
  157. click(css: '.content.active .modal .js-submit')
  158. watch_for(
  159. css: '.content.active .modal .user_autocompletion.form-group.has-error',
  160. )
  161. set(
  162. css: '.content.active .modal input[name="customer_id_completion"]',
  163. value: 'master',
  164. )
  165. watch_for(
  166. css: '.content.active .modal .js-recipientDropdown .recipientList.is-shown',
  167. value: 'Master',
  168. timeout: 3,
  169. )
  170. sendkey(value: :enter)
  171. sleep 1
  172. set(
  173. css: '.content.active .modal input[name="customer_id_completion"]',
  174. value: '',
  175. )
  176. sendkey(value: :backspace)
  177. sleep 1
  178. click(css: '.content.active .modal .js-submit')
  179. watch_for(
  180. css: '.content.active .modal .user_autocompletion.form-group.has-error',
  181. )
  182. set(
  183. css: '.content.active .modal input[name="customer_id_completion"]',
  184. value: 'master',
  185. )
  186. watch_for(
  187. css: '.content.active .modal .js-recipientDropdown .recipientList.is-shown',
  188. value: 'Master',
  189. timeout: 3,
  190. )
  191. sendkey(value: :enter)
  192. sleep 1
  193. click(css: '.content.active .modal .js-submit')
  194. #click(css: '.content.active .tabsSidebar-tabs .tabsSidebar-tab[data-tab="customer"]')
  195. watch_for(
  196. css: '.content.active .tabsSidebar .sidebar[data-tab="customer"]',
  197. value: 'master@example.com',
  198. )
  199. # cleanup
  200. tasks_close_all()
  201. end
  202. end