agent_ticket_email_signature_test.rb 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'browser_test_helper'
  3. class AgentTicketEmailSignatureTest < TestCase
  4. def test_agent_signature_check
  5. suffix = SecureRandom.uuid
  6. signature_name1 = "sig name 1 äöüß #{suffix}"
  7. signature_body1 = "--\nsig body 1 äöüß #{suffix}"
  8. signature_name2 = "sig name 2 äöüß #{suffix}"
  9. signature_body2 = "--\nsig body 2 äöüß #{suffix}"
  10. group_name1 = "group name 1 #{suffix}"
  11. group_name2 = "group name 2 #{suffix}"
  12. group_name3 = "group name 3 #{suffix}"
  13. @browser = browser_instance
  14. login(
  15. username: 'admin@example.com',
  16. password: 'test',
  17. url: browser_url,
  18. )
  19. tasks_close_all
  20. #
  21. # create groups and signatures
  22. #
  23. # create signatures
  24. signature_create(
  25. data: {
  26. name: signature_name1,
  27. body: signature_body1,
  28. },
  29. )
  30. signature_create(
  31. data: {
  32. name: signature_name2,
  33. body: signature_body2,
  34. },
  35. )
  36. # create groups
  37. group_create(
  38. data: {
  39. name: group_name1,
  40. signature: signature_name1,
  41. member: [
  42. {
  43. login: 'admin@example.com',
  44. access: 'full',
  45. },
  46. ],
  47. }
  48. )
  49. group_create(
  50. data: {
  51. name: group_name2,
  52. signature: signature_name2,
  53. member: [
  54. {
  55. login: 'admin@example.com',
  56. access: 'full',
  57. },
  58. ],
  59. }
  60. )
  61. group_create(
  62. data: {
  63. name: group_name3,
  64. member: [
  65. {
  66. login: 'admin@example.com',
  67. access: 'full',
  68. },
  69. ],
  70. }
  71. )
  72. sleep 10 # wait until background job is processed
  73. #
  74. # check signature in new ticket
  75. #
  76. # reload instances to get new group permissions
  77. reload
  78. # create ticket
  79. ticket_create(
  80. data: {
  81. customer: 'nicole',
  82. group: 'Users',
  83. title: 'some subject 5 - 123äöü',
  84. body: 'some body 5 - 123äöü',
  85. },
  86. do_not_submit: true,
  87. )
  88. # select group
  89. select(
  90. css: '.active [name="group_id"]',
  91. value: group_name1,
  92. )
  93. # check content
  94. match(
  95. css: '.active [data-name="body"]',
  96. value: 'some body 5',
  97. )
  98. # check signature
  99. match_not(
  100. css: '.active [data-name="body"]',
  101. value: signature_body1,
  102. no_quote: true,
  103. )
  104. match_not(
  105. css: '.active [data-name="body"]',
  106. value: signature_body2,
  107. no_quote: true,
  108. )
  109. # select create channel
  110. click(
  111. css: '.active [data-type="email-out"]',
  112. )
  113. # group 1 is still selected
  114. # check content
  115. match(
  116. css: '.active [data-name="body"]',
  117. value: 'some body 5',
  118. )
  119. # check signature
  120. match(
  121. css: '.active [data-name="body"]',
  122. value: signature_body1,
  123. no_quote: true,
  124. )
  125. match_not(
  126. css: '.active [data-name="body"]',
  127. value: signature_body2,
  128. no_quote: true,
  129. )
  130. # select group
  131. select(
  132. css: '.active [name="group_id"]',
  133. value: group_name2,
  134. )
  135. # check content
  136. match(
  137. css: '.active [data-name="body"]',
  138. value: 'some body 5',
  139. )
  140. # check signature
  141. match_not(
  142. css: '.active [data-name="body"]',
  143. value: signature_body1,
  144. no_quote: true,
  145. )
  146. match(
  147. css: '.active [data-name="body"]',
  148. value: signature_body2,
  149. no_quote: true,
  150. )
  151. # select group
  152. select(
  153. css: '.active [name="group_id"]',
  154. value: group_name3,
  155. )
  156. # check content
  157. match(
  158. css: '.active [data-name="body"]',
  159. value: 'some body 5',
  160. )
  161. # check signature
  162. match_not(
  163. css: '.active [data-name="body"]',
  164. value: signature_body1,
  165. no_quote: true,
  166. )
  167. match_not(
  168. css: '.active [data-name="body"]',
  169. value: signature_body2,
  170. no_quote: true,
  171. )
  172. # select group
  173. select(
  174. css: '.active [name="group_id"]',
  175. value: group_name1,
  176. )
  177. # check content
  178. match(
  179. css: '.active [data-name="body"]',
  180. value: 'some body 5',
  181. )
  182. # check signature
  183. match(
  184. css: '.active [data-name="body"]',
  185. value: signature_body1,
  186. no_quote: true,
  187. )
  188. match_not(
  189. css: '.active [data-name="body"]',
  190. value: signature_body2,
  191. no_quote: true,
  192. )
  193. # select create channel
  194. click(
  195. css: '.active [data-type="phone-out"]',
  196. )
  197. # check content
  198. match(
  199. css: '.active [data-name="body"]',
  200. value: 'some body 5',
  201. )
  202. # check signature
  203. match_not(
  204. css: '.active [data-name="body"]',
  205. value: signature_body1,
  206. no_quote: true,
  207. )
  208. match_not(
  209. css: '.active [data-name="body"]',
  210. value: signature_body2,
  211. no_quote: true,
  212. )
  213. #
  214. # check signature in zoom ticket
  215. #
  216. ticket_create(
  217. data: {
  218. customer: 'nicole',
  219. group: group_name1,
  220. title: 'some subject 5/2 - 123äöü',
  221. body: 'some body 5/2 - 123äöü',
  222. },
  223. )
  224. # execute reply
  225. click(
  226. css: '.active [data-type="emailReply"]',
  227. )
  228. # check if signature exists
  229. match(
  230. css: '.active [data-name="body"]',
  231. value: signature_body1,
  232. no_quote: true,
  233. )
  234. match_not(
  235. css: '.active [data-name="body"]',
  236. value: signature_body2,
  237. no_quote: true,
  238. )
  239. # update group2
  240. select(
  241. css: '.active [name="group_id"]',
  242. value: group_name2,
  243. )
  244. # execute reply
  245. sleep 5 # time to recognice form changes
  246. scroll_to(
  247. position: 'botton',
  248. css: '.active [data-type="emailReply"]',
  249. )
  250. click(
  251. css: '.active [data-type="emailReply"]',
  252. )
  253. # check if signature exists
  254. match_not(
  255. css: '.active [data-name="body"]',
  256. value: signature_body1,
  257. no_quote: true,
  258. )
  259. match(
  260. css: '.active [data-name="body"]',
  261. value: signature_body2,
  262. no_quote: true,
  263. )
  264. # discard changes
  265. sleep 2
  266. click(
  267. css: '.active .js-reset',
  268. )
  269. sleep 3
  270. # check if signature exists
  271. match_not(
  272. css: '.active [data-name="body"]',
  273. value: signature_body1,
  274. no_quote: true,
  275. )
  276. match_not(
  277. css: '.active [data-name="body"]',
  278. value: signature_body2,
  279. no_quote: true,
  280. )
  281. end
  282. end