agent_ticket_attachment_test.rb 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class AgentTicketAttachmentTest < TestCase
  4. def test_ticket
  5. @browser = browser_instance
  6. login(
  7. username: 'agent1@example.com',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. tasks_close_all()
  12. #
  13. # attachment checks - new ticket
  14. #
  15. # create new ticket with no attachment, attachment check should pop up
  16. ticket_create(
  17. data: {
  18. customer: 'nico',
  19. group: 'Users',
  20. title: 'test 6 - ticket 1',
  21. body: 'test 6 - ticket 1 - with the word attachment, but not attachment atteched it should give an warning on submit',
  22. },
  23. do_not_submit: true,
  24. )
  25. sleep 1
  26. # submit form
  27. click(css: '.content.active .js-submit')
  28. sleep 2
  29. # check warning
  30. alert = @browser.switch_to.alert
  31. alert.dismiss()
  32. #alert.accept()
  33. #alert = alert.text
  34. # add attachment, attachment check should quiet
  35. file_upload(
  36. css: '.content.active .attachmentPlaceholder-inputHolder input',
  37. files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
  38. )
  39. # submit form
  40. click(css: '.content.active .js-submit')
  41. sleep 5
  42. # no warning
  43. #alert = @browser.switch_to.alert
  44. # check if ticket is shown and attachment exists
  45. location_check(url: '#ticket/zoom/')
  46. sleep 2
  47. ticket_number = @browser.find_elements({ css: '.content.active .ticketZoom-header .ticket-number' })[0].text
  48. match(
  49. css: '.content.active .ticket-article-item:nth-child(1) .attachments',
  50. value: 'upload2.jpg',
  51. )
  52. match(
  53. css: '.content.active .ticket-article-item:nth-child(1) .attachments',
  54. value: 'upload1.txt',
  55. )
  56. #
  57. # attachment checks - update ticket
  58. #
  59. # update ticket with no attachment, attachment check should pop up
  60. ticket_update(
  61. data: {
  62. body: 'test 6 - ticket 1-1 - with the word attachment, but not attachment atteched it should give an warning on submit',
  63. },
  64. do_not_submit: true,
  65. )
  66. # submit form
  67. click(css: '.content.active .js-submit')
  68. sleep 2
  69. # check warning
  70. alert = @browser.switch_to.alert
  71. alert.dismiss()
  72. # add attachment, attachment check should quiet
  73. file_upload(
  74. css: '.content.active .attachmentPlaceholder-inputHolder input',
  75. files: ['test/fixtures/upload1.txt'],
  76. )
  77. # submit form
  78. click(css: '.content.active .js-submit')
  79. sleep 2
  80. # no warning
  81. #alert = @browser.switch_to.alert
  82. # check if article exists
  83. # discard changes should gone away
  84. watch_for_disappear(
  85. css: '.content.active .js-reset',
  86. value: '(Discard your unsaved changes.|Verwerfen der)',
  87. no_quote: true,
  88. )
  89. ticket_verify(
  90. data: {
  91. body: '',
  92. },
  93. )
  94. # check content and edit screen in instance 1
  95. match(
  96. css: '.content.active div.ticket-article',
  97. value: 'test 6 - ticket 1-1',
  98. )
  99. match_not(
  100. css: '.content.active .ticket-article-item:nth-child(3) .attachments',
  101. value: 'upload2.jpg',
  102. )
  103. match(
  104. css: '.content.active .ticket-article-item:nth-child(3) .attachments',
  105. value: 'upload1.txt',
  106. )
  107. # add attachment without body
  108. file_upload(
  109. css: '.content.active .attachmentPlaceholder-inputHolder input',
  110. files: ['test/fixtures/upload2.jpg', 'test/fixtures/upload1.txt'],
  111. )
  112. # submit form
  113. click(css: '.content.active .js-submit')
  114. sleep 2
  115. # check warning
  116. match(
  117. css: '.content.active .modal',
  118. value: 'missing',
  119. )
  120. click(css: '.content.active .modal .js-cancel')
  121. sleep 2
  122. ticket_update(
  123. data: {
  124. body: 'now submit should work',
  125. },
  126. do_not_submit: true,
  127. )
  128. # submit form
  129. click(css: '.content.active .js-submit')
  130. sleep 2
  131. # discard changes should gone away
  132. watch_for_disappear(
  133. css: '.content.active .js-reset',
  134. value: '(Discard your unsaved changes.|Verwerfen der)',
  135. no_quote: true,
  136. )
  137. ticket_verify(
  138. data: {
  139. body: '',
  140. },
  141. )
  142. match(
  143. css: '.content.active .ticket-article-item:nth-child(4) .attachments',
  144. value: 'upload2.jpg',
  145. )
  146. match(
  147. css: '.content.active .ticket-article-item:nth-child(4) .attachments',
  148. value: 'upload1.txt',
  149. )
  150. #
  151. # ticket customer change checks
  152. #
  153. # use current session
  154. browser1 = @browser
  155. browser2 = browser_instance
  156. login(
  157. browser: browser2,
  158. username: 'master@example.com',
  159. password: 'test',
  160. url: browser_url,
  161. )
  162. tasks_close_all(
  163. browser: browser2,
  164. )
  165. random = 'ticket-actions-6-test-' + rand(999_999).to_s
  166. user_email = random + '@example.com'
  167. user_create(
  168. browser: browser2,
  169. data: {
  170. firstname: 'Action6 Firstname' + random,
  171. lastname: 'Action6 Lastname' + random,
  172. email: user_email,
  173. password: 'some-pass',
  174. },
  175. )
  176. # update customer, check if new customer is shown in side bar
  177. ticket_open_by_search(
  178. browser: browser2,
  179. number: ticket_number,
  180. )
  181. ticket_update(
  182. browser: browser2,
  183. data: {
  184. customer: user_email,
  185. },
  186. do_not_submit: true,
  187. )
  188. # check if customer has changed in second browser
  189. click(browser: browser1, css: '.content.active .tabsSidebar-tab[data-tab="customer"]')
  190. watch_for(
  191. browser: browser1,
  192. css: '.content.active .tabsSidebar',
  193. value: user_email,
  194. )
  195. #
  196. # modify customer
  197. #
  198. # modify customer
  199. click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
  200. click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
  201. sleep 2
  202. set(browser: browser1, css: '.modal [name="address"]', value: 'some new address')
  203. click(browser: browser1, css: '.modal .js-submit')
  204. # verify is customer has chnaged other browser too
  205. click(browser: browser2, css: '.content.active .tabsSidebar-tab[data-tab="customer"]')
  206. watch_for(
  207. browser: browser2,
  208. css: '.content.active .sidebar[data-tab="customer"]',
  209. value: 'some new address',
  210. )
  211. #
  212. # ticket customer organization change checks
  213. #
  214. # change org of customer, check if org is shown in sidebar
  215. click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
  216. click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
  217. sleep 2
  218. set(browser: browser1, css: '.modal .js-input', value: 'zammad')
  219. click(browser: browser1, css: '.modal .js-input')
  220. click(browser: browser1, css: '.modal .js-option')
  221. click(browser: browser1, css: '.modal .js-submit')
  222. # check if org has changed in second browser
  223. sleep 3
  224. click(browser: browser2, css: '.content.active .tabsSidebar-tab[data-tab="organization"]')
  225. watch_for(
  226. browser: browser2,
  227. css: '.content.active .sidebar[data-tab="organization"]',
  228. value: 'Zammad Foundation',
  229. )
  230. #
  231. # form change/reset checks
  232. #
  233. # some form reset checks
  234. end
  235. end