agent_ticket_create_reset_customer_selection_test.rb 7.8 KB

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