agent_ticket_text_module_test.rb 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. require 'browser_test_helper'
  2. class AgentTicketTextModuleTest < TestCase
  3. def test_text_modules
  4. random = "text_module_test_#{rand(99_999_999)}"
  5. random2 = "text_module_test_#{rand(99_999_999)}"
  6. @browser = browser_instance
  7. login(
  8. username: 'master@example.com',
  9. password: 'test',
  10. url: browser_url,
  11. )
  12. tasks_close_all()
  13. # create new text modules
  14. text_module_create(
  15. data: {
  16. name: "some name#{random}",
  17. keywords: random,
  18. content: "some content#{random}",
  19. },
  20. )
  21. text_module_create(
  22. data: {
  23. name: "some name#{random2}",
  24. keywords: random2,
  25. content: "some content#{random2}",
  26. },
  27. )
  28. # try to use them
  29. click(css: 'a[href="#new"]', only_if_exists: true)
  30. click(css: 'a[href="#ticket/create"]')
  31. sleep 2
  32. set(
  33. css: '.active div[data-name=body]',
  34. value: "test ::#{random}",
  35. )
  36. watch_for(
  37. css: '.active .shortcut',
  38. value: random,
  39. )
  40. sendkey(
  41. value: :arrow_down,
  42. slow: true,
  43. )
  44. click(css: '.active .shortcut > ul> li')
  45. watch_for(
  46. css: '.active div[data-name=body]',
  47. value: "some content#{random}",
  48. )
  49. tasks_close_all()
  50. # test with two browser windows
  51. random = "text_II_module_test_#{rand(99_999_999)}"
  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',
  123. )
  124. watch_for(
  125. browser: browser2,
  126. css: '.active div[data-name=body]',
  127. value: "some content -#{random}",
  128. )
  129. ticket_customer_select(
  130. browser: browser2,
  131. css: '.active .newTicket',
  132. customer: 'nicole',
  133. )
  134. set(
  135. browser: browser2,
  136. css: '.active div[data-name=body]',
  137. value: "::#{random}",
  138. )
  139. sendkey(
  140. browser: browser2,
  141. value: :arrow_down,
  142. slow: true,
  143. )
  144. click(
  145. browser: browser2,
  146. css: '.active .shortcut > ul> li',
  147. )
  148. watch_for(
  149. browser: browser2,
  150. css: '.active div[data-name=body]',
  151. value: "some content Braun#{random}",
  152. )
  153. # verify zoom
  154. click(
  155. browser: browser1,
  156. css: 'a[href="#manage"]',
  157. )
  158. # create ticket
  159. ticket_create(
  160. browser: browser2,
  161. data: {
  162. customer: 'nico',
  163. group: 'Users',
  164. title: 'some subject 123äöü',
  165. body: 'some body 123äöü',
  166. },
  167. )
  168. set(
  169. browser: browser2,
  170. css: '.active div[data-name=body]',
  171. value: 'test',
  172. no_click: true,
  173. )
  174. set(
  175. browser: browser2,
  176. css: '.active div[data-name=body]',
  177. value: "::#{random}",
  178. no_click: true,
  179. )
  180. sendkey(
  181. browser: browser2,
  182. value: :arrow_down,
  183. )
  184. sleep 1
  185. click(
  186. browser: browser2,
  187. css: '.active .shortcut > ul> li',
  188. )
  189. watch_for(
  190. browser: browser2,
  191. css: '.active div[data-name=body]',
  192. value: "some content Braun#{random}",
  193. )
  194. # change customer
  195. click(
  196. browser: browser1,
  197. css: 'a[href="#manage"]',
  198. )
  199. click(
  200. browser: browser2,
  201. css: '.active div[data-tab="ticket"] .js-actions .icon-arrow-down',
  202. )
  203. click(
  204. browser: browser2,
  205. css: '.active div[data-tab="ticket"] .js-actions [data-type="customer-change"]',
  206. )
  207. modal_ready(browser: browser2)
  208. ticket_customer_select(
  209. browser: browser2,
  210. css: '.modal',
  211. customer: firstname,
  212. )
  213. click(
  214. browser: browser2,
  215. css: '.modal-content .js-submit',
  216. )
  217. modal_disappear(browser: browser2)
  218. set(
  219. browser: browser2,
  220. css: '.active div[data-name=body]',
  221. value: "::#{random}",
  222. no_click: true,
  223. )
  224. sendkey(
  225. browser: browser2,
  226. value: :arrow_down,
  227. )
  228. sendkey(
  229. browser: browser2,
  230. value: :enter,
  231. )
  232. watch_for(
  233. browser: browser2,
  234. css: '.active div[data-name=body]',
  235. value: "some content #{lastname}",
  236. )
  237. end
  238. end