agent_ticket_actions_level0_test.rb 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class AgentTicketActionLevel0Test < TestCase
  4. def test_text_modules
  5. random = 'text_module_test_' + rand(99_999_999).to_s
  6. random2 = 'text_module_test_' + rand(99_999_999).to_s
  7. @browser = browser_instance
  8. login(
  9. username: 'master@example.com',
  10. password: 'test',
  11. url: browser_url,
  12. )
  13. tasks_close_all()
  14. # create new text modules
  15. text_module_create(
  16. data: {
  17. name: 'some name' + random,
  18. keywords: random,
  19. content: 'some content' + random,
  20. },
  21. )
  22. text_module_create(
  23. data: {
  24. name: 'some name' + random2,
  25. keywords: random2,
  26. content: 'some content' + random2,
  27. },
  28. )
  29. # try to use them
  30. click( css: 'a[href="#new"]' )
  31. click( css: 'a[href="#ticket/create"]' )
  32. sleep 2
  33. set(
  34. css: '.active div[data-name=body]',
  35. value: 'test ::' + random
  36. )
  37. watch_for(
  38. css: '.active .shortcut',
  39. value: random,
  40. )
  41. sendkey(
  42. value: :arrow_down,
  43. )
  44. click( css: '.active .shortcut > ul> li > a' )
  45. watch_for(
  46. css: '.active div[data-name=body]',
  47. value: 'some content' + random,
  48. )
  49. tasks_close_all( discard_changes: true )
  50. # test with two browser windows
  51. random = 'text_II_module_test_' + rand(99_999_999).to_s
  52. user_rand = rand(99_999_999).to_s
  53. login = 'agent-text-module-' + user_rand
  54. firstname = 'Text' + user_rand
  55. lastname = 'Module' + user_rand
  56. email = 'agent-text-module-' + user_rand + '@example.com'
  57. password = 'agentpw'
  58. # use current session
  59. browser1 = @browser
  60. browser2 = browser_instance
  61. login(
  62. browser: browser2,
  63. username: 'agent1@example.com',
  64. password: 'test',
  65. url: browser_url,
  66. )
  67. tasks_close_all(
  68. browser: browser2,
  69. )
  70. # create new ticket
  71. ticket_create(
  72. browser: browser2,
  73. data: {
  74. title: 'A',
  75. },
  76. do_not_submit: true,
  77. )
  78. ticket_create(
  79. browser: browser2,
  80. data: {
  81. title: 'B',
  82. },
  83. do_not_submit: true,
  84. )
  85. # create new text module
  86. text_module_create(
  87. browser: browser1,
  88. data: {
  89. name: 'some name' + random,
  90. keywords: random,
  91. content: 'some content <%= @ticket.customer.lastname %>' + random,
  92. },
  93. )
  94. # create user to test placeholder
  95. user_create(
  96. browser: browser1,
  97. data: {
  98. login: login,
  99. firstname: firstname,
  100. lastname: lastname,
  101. email: email,
  102. password: password,
  103. },
  104. )
  105. # check if text module exists in instance2, for ready to use
  106. set(
  107. browser: browser2,
  108. css: '.active div[data-name=body]',
  109. value: 'test ::' + random
  110. )
  111. watch_for(
  112. browser: browser2,
  113. css: '.active .shortcut',
  114. value: random,
  115. )
  116. sendkey(
  117. browser: browser2,
  118. value: :arrow_down,
  119. )
  120. click(
  121. browser: browser2,
  122. css: '.active .shortcut > ul> li > a',
  123. )
  124. watch_for(
  125. browser: browser2,
  126. css: '.active div[data-name=body]',
  127. value: 'some content ' + random,
  128. )
  129. sleep 2
  130. set(
  131. browser: browser2,
  132. css: '.active .newTicket input[name="customer_id_completion"]',
  133. value: 'nicole',
  134. )
  135. sleep 4
  136. sendkey(
  137. browser: browser2,
  138. value: :arrow_down,
  139. )
  140. click(
  141. browser: browser2,
  142. css: '.active .newTicket .recipientList-entry.js-user.is-active',
  143. )
  144. set(
  145. browser: browser2,
  146. css: '.active div[data-name=body]',
  147. value: '::' + random,
  148. )
  149. sendkey(
  150. browser: browser2,
  151. value: :arrow_down,
  152. )
  153. click(
  154. browser: browser2,
  155. css: '.active .shortcut > ul> li > a',
  156. )
  157. watch_for(
  158. browser: browser2,
  159. css: '.active div[data-name=body]',
  160. value: 'some content Braun' + random,
  161. )
  162. # verify zoom
  163. click(
  164. browser: browser1,
  165. css: 'a[href="#manage"]',
  166. )
  167. # create ticket
  168. ticket_create(
  169. browser: browser2,
  170. data: {
  171. customer: 'nico',
  172. group: 'Users',
  173. title: 'some subject 123äöü',
  174. body: 'some body 123äöü',
  175. },
  176. )
  177. set(
  178. browser: browser2,
  179. css: '.active div[data-name=body]',
  180. value: 'test',
  181. )
  182. set(
  183. browser: browser2,
  184. css: '.active div[data-name=body]',
  185. value: '::' + random,
  186. )
  187. sendkey(
  188. browser: browser2,
  189. value: :arrow_down,
  190. )
  191. click(
  192. browser: browser2,
  193. css: '.active .shortcut > ul> li > a',
  194. )
  195. watch_for(
  196. browser: browser2,
  197. css: '.active div[data-name=body]',
  198. value: 'some content Braun' + random,
  199. )
  200. # change customer
  201. click(
  202. browser: browser1,
  203. css: 'a[href="#manage"]',
  204. )
  205. click(
  206. browser: browser2,
  207. css: '.active div[data-tab="ticket"] .js-actions .icon-arrow-down',
  208. )
  209. click(
  210. browser: browser2,
  211. css: '.active div[data-tab="ticket"] .js-actions a[data-type="customer-change"]',
  212. )
  213. sleep 1
  214. set(
  215. browser: browser2,
  216. css: '.modal [name="customer_id_completion"]',
  217. value: firstname,
  218. )
  219. sleep 4
  220. sendkey(
  221. browser: browser2,
  222. value: :arrow_down,
  223. )
  224. click(
  225. browser: browser2,
  226. css: '.modal .recipientList-entry.js-user.is-active',
  227. )
  228. click(
  229. browser: browser2,
  230. css: '.modal-content .js-submit',
  231. )
  232. watch_for_disappear(
  233. browser: browser2,
  234. css: '.modal',
  235. )
  236. set(
  237. browser: browser2,
  238. css: '.active div[data-name=body]',
  239. value: '::' + random,
  240. )
  241. sendkey(
  242. browser: browser2,
  243. value: :arrow_down,
  244. )
  245. click(
  246. browser: browser2,
  247. css: '.active .shortcut > ul> li > a',
  248. )
  249. watch_for(
  250. browser: browser2,
  251. css: '.active div[data-name=body]',
  252. value: 'some content ' + lastname,
  253. )
  254. end
  255. end