customer_ticket_create_test.rb 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'browser_test_helper'
  3. class CustomerTicketCreateTest < TestCase
  4. def test_customer_ticket_create_and_verify_state_after_update
  5. @browser = browser_instance
  6. login(
  7. username: 'nicole.braun@zammad.org',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. # customer ticket create
  12. click(css: 'a[href="#new"]', only_if_exists: true)
  13. click(css: 'a[href="#customer_ticket_new"]')
  14. sleep 2
  15. select(
  16. css: '.newTicket select[name="group_id"]',
  17. value: 'Users',
  18. )
  19. set(
  20. css: '.newTicket input[name="title"]',
  21. value: 'some subject 123äöü',
  22. )
  23. set(
  24. css: '.newTicket [data-name="body"]',
  25. value: 'some body 123äöü',
  26. )
  27. exists_not(
  28. css: '.newTicket input[name="customer_id"]',
  29. )
  30. exists_not(
  31. css: '.newTicket input[name="priority_id"]',
  32. )
  33. click(css: '.newTicket button.js-submit')
  34. sleep 5
  35. # check if ticket is shown
  36. location_check(url: '#ticket/zoom/')
  37. match(
  38. css: '.active div.ticket-article',
  39. value: 'some body 123äöü',
  40. no_quote: true,
  41. )
  42. # verify if the state has changed to open
  43. match(
  44. css: '.content.active .sidebar [name="state_id"]',
  45. value: 'new',
  46. )
  47. # update ticket
  48. set(
  49. css: '.content.active [data-name="body"]',
  50. value: 'some body 1234 äöüß',
  51. no_click: true,
  52. )
  53. task_type(
  54. type: 'stayOnTab',
  55. )
  56. click(css: '.content.active .js-submit')
  57. watch_for(
  58. css: '.content.active div.ticket-article',
  59. value: 'some body 1234 äöüß',
  60. )
  61. # check if the ticket state is new after update by customer
  62. match(
  63. css: '.content.active .sidebar [name="state_id"]',
  64. value: 'new',
  65. )
  66. # now we want to verify the default followup state
  67. # for this case we close the ticket first and then
  68. # write a new article. If the content is written
  69. # then the state should change initially to open
  70. # close the ticket
  71. select(
  72. css: '.content.active [name="state_id"]',
  73. value: 'closed',
  74. )
  75. set(
  76. css: '.content.active [data-name="body"]',
  77. value: 'close #1',
  78. no_click: true,
  79. )
  80. click(css: '.content.active .js-submit')
  81. watch_for(
  82. css: '.content.active div.ticket-article',
  83. value: 'close #1',
  84. )
  85. # check if the ticket is closed
  86. match(
  87. css: '.content.active .sidebar [name="state_id"]',
  88. value: 'closed',
  89. )
  90. # type in new content into rte to trigger the default follow-up state
  91. set(
  92. css: '.content.active [data-name="body"]',
  93. value: 'some body blublub default followup for reopen check',
  94. no_click: true,
  95. )
  96. # verify if the state has changed to open
  97. watch_for(
  98. css: '.content.active .sidebar [name="state_id"]',
  99. value: 'open',
  100. )
  101. # no we verify the reverse way:
  102. # if the body get changed to empty again then
  103. # the default follow-up state should get unset and
  104. # will change to the the default ticket state.
  105. # remove content from rte
  106. set(
  107. css: '.content.active [data-name="body"]',
  108. value: '',
  109. no_click: true,
  110. )
  111. # check if state changed to closed again
  112. watch_for(
  113. css: '.content.active .sidebar [name="state_id"]',
  114. value: 'closed',
  115. )
  116. # type in new content into rte to trigger the default follow-up state
  117. set(
  118. css: '.content.active [data-name="body"]',
  119. value: 'some body blublub default followup for reopen check',
  120. no_click: true,
  121. )
  122. # verify if the state has changed to open
  123. watch_for(
  124. css: '.content.active .sidebar [name="state_id"]',
  125. value: 'open',
  126. )
  127. # submit and reload to check if the new state is set
  128. click(css: '.content.active .js-submit')
  129. watch_for(
  130. css: '.content.active div.ticket-article',
  131. value: 'some body blublub default followup for reopen check',
  132. )
  133. # verify if the state has changed to open
  134. match(
  135. css: '.content.active .sidebar [name="state_id"]',
  136. value: 'open',
  137. )
  138. end
  139. def test_customer_ticket_create_relogin_with_agent_ticket_create
  140. @browser = browser_instance
  141. login(
  142. username: 'nicole.braun@zammad.org',
  143. password: 'test',
  144. url: browser_url,
  145. )
  146. # customer ticket create
  147. click(css: 'a[href="#new"]', only_if_exists: true)
  148. click(css: 'a[href="#customer_ticket_new"]')
  149. sleep 2
  150. select(
  151. css: '.newTicket select[name="group_id"]',
  152. value: 'Users',
  153. )
  154. set(
  155. css: '.newTicket input[name="title"]',
  156. value: 'relogin - customer - agent - test 1',
  157. )
  158. set(
  159. css: '.newTicket [data-name="body"]',
  160. value: 'relogin - customer - agent - test 1',
  161. )
  162. click(css: '.newTicket button.js-submit')
  163. sleep 5
  164. # check if ticket is shown
  165. location_check(url: '#ticket/zoom/')
  166. match(
  167. css: '.active div.ticket-article',
  168. value: 'relogin - customer - agent - test 1',
  169. no_quote: true,
  170. )
  171. logout
  172. # verify if we still can create new tickets as agent
  173. login(
  174. username: 'admin@example.com',
  175. password: 'test',
  176. url: browser_url,
  177. )
  178. tasks_close_all
  179. ticket_create(
  180. data: {
  181. customer: 'nico',
  182. group: 'Users',
  183. title: 'relogin - customer - agent - test 2',
  184. body: 'relogin - customer - agent - test 2',
  185. state: 'closed',
  186. },
  187. )
  188. end
  189. def test_customer_disable_ticket_creation
  190. @browser = browser_instance
  191. # disable ticket creation
  192. login(
  193. username: 'admin@example.com',
  194. password: 'test',
  195. url: browser_url,
  196. )
  197. click(css: 'a[href="#manage"]')
  198. click(css: 'a[href="#channels/web"]')
  199. @browser.find_element(css: 'select[name=customer_ticket_create]').find_element(css: 'option[value=false]').click
  200. click(css: '#customer_ticket_create .btn')
  201. sleep(1)
  202. logout
  203. # check if new ticket button is not visible
  204. login(
  205. username: 'nicole.braun@zammad.org',
  206. password: 'test',
  207. url: browser_url,
  208. )
  209. assert(exists_not(css: 'a[href="#customer_ticket_new"]'))
  210. logout
  211. # enable ticket creation
  212. login(
  213. username: 'admin@example.com',
  214. password: 'test',
  215. url: browser_url,
  216. )
  217. click(css: 'a[href="#manage"]')
  218. click(css: 'a[href="#channels/web"]')
  219. @browser.find_element(css: 'select[name=customer_ticket_create]').find_element(css: 'option[value=true]').click
  220. click(css: '#customer_ticket_create .btn')
  221. sleep(1)
  222. logout
  223. # check if new ticket button is visible
  224. login(
  225. username: 'nicole.braun@zammad.org',
  226. password: 'test',
  227. url: browser_url,
  228. )
  229. assert(exists(css: 'a[href="#customer_ticket_new"]'))
  230. end
  231. end