agent_ticket_email_signature_test.rb 6.5 KB

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