agent_ticket_email_signature_test.rb 6.0 KB

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