customer_ticket_create_test.rb 6.8 KB

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