agent_ticket_text_module_test.rb 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'browser_test_helper'
  3. class AgentTicketTextModuleTest < TestCase
  4. def test_text_modules
  5. random = "text_module_test_#{SecureRandom.uuid}"
  6. random2 = "text_module_test_#{SecureRandom.uuid}"
  7. @browser = browser_instance
  8. login(
  9. username: 'admin@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"]', only_if_exists: true)
  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. slow: true,
  44. )
  45. click(css: '.active .shortcut > ul> li')
  46. watch_for(
  47. css: '.active div[data-name=body]',
  48. value: "some content#{random}",
  49. )
  50. tasks_close_all
  51. # test with two browser windows
  52. random = "text_II_module_test_#{SecureRandom.uuid}"
  53. user_rand = SecureRandom.uuid
  54. login = "agent-text-module-#{user_rand}"
  55. firstname = "Text#{user_rand}"
  56. lastname = "Module#{user_rand}"
  57. email = "agent-text-module-#{user_rand}@example.com"
  58. password = 'agentpw'
  59. # use current session
  60. browser1 = @browser
  61. browser2 = browser_instance
  62. login(
  63. browser: browser2,
  64. username: 'agent1@example.com',
  65. password: 'test',
  66. url: browser_url,
  67. )
  68. tasks_close_all(
  69. browser: browser2,
  70. )
  71. # create new ticket
  72. ticket_create(
  73. browser: browser2,
  74. data: {
  75. title: 'A',
  76. },
  77. do_not_submit: true,
  78. )
  79. ticket_create(
  80. browser: browser2,
  81. data: {
  82. title: 'B',
  83. },
  84. do_not_submit: true,
  85. )
  86. # create new text module
  87. text_module_create(
  88. browser: browser1,
  89. data: {
  90. name: "some name#{random}",
  91. keywords: random,
  92. content: "some content \#{ticket.customer.lastname}#{random}",
  93. },
  94. )
  95. # create user to test placeholder
  96. user_create(
  97. browser: browser1,
  98. data: {
  99. login: login,
  100. firstname: firstname,
  101. lastname: lastname,
  102. email: email,
  103. password: password,
  104. },
  105. )
  106. # check if text module exists in instance2, for ready to use
  107. set(
  108. browser: browser2,
  109. css: '.active div[data-name=body]',
  110. value: "test ::#{random}",
  111. )
  112. watch_for(
  113. browser: browser2,
  114. css: '.active .shortcut',
  115. value: random,
  116. )
  117. sendkey(
  118. browser: browser2,
  119. value: :arrow_down,
  120. )
  121. click(
  122. browser: browser2,
  123. css: '.active .shortcut > ul> li',
  124. )
  125. watch_for(
  126. browser: browser2,
  127. css: '.active div[data-name=body]',
  128. value: "some content -#{random}",
  129. )
  130. ticket_customer_select(
  131. browser: browser2,
  132. css: '.active .newTicket',
  133. customer: 'nicole',
  134. )
  135. set(
  136. browser: browser2,
  137. css: '.active div[data-name=body]',
  138. value: "::#{random}",
  139. )
  140. sendkey(
  141. browser: browser2,
  142. value: :arrow_down,
  143. slow: true,
  144. )
  145. click(
  146. browser: browser2,
  147. css: '.active .shortcut > ul> li',
  148. )
  149. watch_for(
  150. browser: browser2,
  151. css: '.active div[data-name=body]',
  152. value: "some content Braun#{random}",
  153. )
  154. # verify zoom
  155. click(
  156. browser: browser1,
  157. css: 'a[href="#manage"]',
  158. )
  159. # create ticket
  160. ticket_create(
  161. browser: browser2,
  162. data: {
  163. customer: 'nico',
  164. group: 'Users',
  165. title: 'some subject 123äöü',
  166. body: 'some body 123äöü',
  167. },
  168. )
  169. set(
  170. browser: browser2,
  171. css: '.active div[data-name=body]',
  172. value: 'test',
  173. no_click: true,
  174. )
  175. set(
  176. browser: browser2,
  177. css: '.active div[data-name=body]',
  178. value: "::#{random}",
  179. no_click: true,
  180. )
  181. sendkey(
  182. browser: browser2,
  183. value: :arrow_down,
  184. )
  185. sleep 1
  186. click(
  187. browser: browser2,
  188. css: '.active .shortcut > ul> li',
  189. )
  190. watch_for(
  191. browser: browser2,
  192. css: '.active div[data-name=body]',
  193. value: "some content Braun#{random}",
  194. )
  195. # change customer
  196. click(
  197. browser: browser1,
  198. css: 'a[href="#manage"]',
  199. )
  200. click(
  201. browser: browser2,
  202. css: '.active div[data-tab="ticket"] .js-actions .icon-arrow-down',
  203. )
  204. click(
  205. browser: browser2,
  206. css: '.active div[data-tab="ticket"] .js-actions [data-type="customer-change"]',
  207. )
  208. modal_ready(browser: browser2)
  209. ticket_customer_select(
  210. browser: browser2,
  211. css: '.modal',
  212. customer: firstname,
  213. )
  214. click(
  215. browser: browser2,
  216. css: '.modal-content .js-submit',
  217. )
  218. modal_disappear(browser: browser2)
  219. set(
  220. browser: browser2,
  221. css: '.active div[data-name=body]',
  222. value: "::#{random}",
  223. no_click: true,
  224. )
  225. sendkey(
  226. browser: browser2,
  227. value: :arrow_down,
  228. )
  229. sendkey(
  230. browser: browser2,
  231. value: :enter,
  232. )
  233. watch_for(
  234. browser: browser2,
  235. css: '.active div[data-name=body]',
  236. value: "some content #{lastname}",
  237. )
  238. end
  239. end