agent_ticket_overview_level0_test.rb 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. require 'browser_test_helper'
  2. class AgentTicketOverviewLevel0Test < TestCase
  3. def test_bulk_close
  4. @browser = browser_instance
  5. login(
  6. username: 'master@example.com',
  7. password: 'test',
  8. url: browser_url,
  9. )
  10. tasks_close_all()
  11. # test bulk action
  12. # create new ticket
  13. ticket1 = ticket_create(
  14. data: {
  15. customer: 'nico',
  16. group: 'Users',
  17. title: 'overview count test #1',
  18. body: 'overview count test #1',
  19. }
  20. )
  21. ticket2 = ticket_create(
  22. data: {
  23. customer: 'nico',
  24. group: 'Users',
  25. title: 'overview count test #2',
  26. body: 'overview count test #2',
  27. }
  28. )
  29. click(text: 'Overviews')
  30. # enable full overviews
  31. execute(
  32. js: '$(".content.active .sidebar").css("display", "block")',
  33. )
  34. click(text: 'Unassigned & Open')
  35. watch_for(
  36. css: '.content.active',
  37. value: 'overview count test #2',
  38. )
  39. # select both via bulk action
  40. click(
  41. css: '.content.active table tr td input[value="' + ticket1[:id] + '"] + .icon-checkbox.icon-unchecked',
  42. fast: true,
  43. )
  44. # scroll to reply - needed for chrome
  45. scroll_to(
  46. position: 'top',
  47. css: '.content.active table tr td input[value="' + ticket2[:id] + '"] + .icon-checkbox.icon-unchecked',
  48. )
  49. click(
  50. css: '.content.active table tr td input[value="' + ticket2[:id] + '"] + .icon-checkbox.icon-unchecked',
  51. fast: true,
  52. )
  53. exists(
  54. css: '.content.active table tr td input[value="' + ticket1[:id] + '"][type="checkbox"]:checked',
  55. )
  56. exists(
  57. css: '.content.active table tr td input[value="' + ticket2[:id] + '"][type="checkbox"]:checked',
  58. )
  59. # select close state & submit
  60. select(
  61. css: '.content.active .bulkAction [name="state_id"]',
  62. value: 'closed',
  63. )
  64. click(
  65. css: '.content.active .bulkAction .js-confirm',
  66. )
  67. click(
  68. css: '.content.active .bulkAction .js-submit',
  69. )
  70. watch_for_disappear(
  71. css: '.content.active table tr td input[value="' + ticket2[:id] + '"]',
  72. timeout: 6,
  73. )
  74. exists_not(
  75. css: '.content.active table tr td input[value="' + ticket1[:id] + '"]',
  76. )
  77. exists_not(
  78. css: '.content.active table tr td input[value="' + ticket2[:id] + '"]',
  79. )
  80. # remember current overview count
  81. overview_counter_before = overview_counter()
  82. # click options and enable number and article count
  83. click(css: '.content.active [data-type="settings"]')
  84. modal_ready()
  85. check(
  86. css: '.modal input[value="number"]',
  87. )
  88. check(
  89. css: '.modal input[value="title"]',
  90. )
  91. check(
  92. css: '.modal input[value="customer"]',
  93. )
  94. check(
  95. css: '.modal input[value="group"]',
  96. )
  97. check(
  98. css: '.modal input[value="created_at"]',
  99. )
  100. check(
  101. css: '.modal input[value="article_count"]',
  102. )
  103. click(css: '.modal .js-submit')
  104. modal_disappear
  105. # check if number and article count is shown
  106. match(
  107. css: '.content.active table th:nth-child(3)',
  108. value: '#',
  109. )
  110. match(
  111. css: '.content.active table th:nth-child(4)',
  112. value: 'Title',
  113. )
  114. match(
  115. css: '.content.active table th:nth-child(7)',
  116. value: 'Article#',
  117. )
  118. # reload browser
  119. reload()
  120. sleep 4
  121. # check if number and article count is shown
  122. match(
  123. css: '.content.active table th:nth-child(3)',
  124. value: '#',
  125. )
  126. match(
  127. css: '.content.active table th:nth-child(4)',
  128. value: 'Title',
  129. )
  130. match(
  131. css: '.content.active table th:nth-child(7)',
  132. value: 'Article#',
  133. )
  134. # disable number and article count
  135. click(css: '.content.active [data-type="settings"]')
  136. modal_ready()
  137. uncheck(
  138. css: '.modal input[value="number"]',
  139. )
  140. uncheck(
  141. css: '.modal input[value="article_count"]',
  142. )
  143. click(css: '.modal .js-submit')
  144. modal_disappear
  145. # check if number and article count is gone
  146. match_not(
  147. css: '.content.active table th:nth-child(3)',
  148. value: '#',
  149. )
  150. match(
  151. css: '.content.active table th:nth-child(3)',
  152. value: 'Title',
  153. )
  154. exists_not(
  155. css: '.content.active table th:nth-child(8)',
  156. )
  157. # create new ticket
  158. ticket3 = ticket_create(
  159. data: {
  160. customer: 'nico',
  161. group: 'Users',
  162. title: 'overview count test #3',
  163. body: 'overview count test #3',
  164. }
  165. )
  166. sleep 6
  167. # get new overview count
  168. overview_counter_new = overview_counter()
  169. assert_equal(overview_counter_before['#ticket/view/all_unassigned'] + 1, overview_counter_new['#ticket/view/all_unassigned'])
  170. # open ticket by search
  171. ticket_open_by_search(
  172. number: ticket3[:number],
  173. )
  174. sleep 1
  175. # close ticket
  176. ticket_update(
  177. data: {
  178. state: 'closed',
  179. }
  180. )
  181. sleep 6
  182. # get current overview count
  183. overview_counter_after = overview_counter()
  184. assert_equal(overview_counter_before['#ticket/view/all_unassigned'], overview_counter_after['#ticket/view/all_unassigned'])
  185. # cleanup
  186. tasks_close_all()
  187. end
  188. def test_bulk_pending
  189. @browser = browser_instance
  190. login(
  191. username: 'master@example.com',
  192. password: 'test',
  193. url: browser_url,
  194. )
  195. tasks_close_all()
  196. # test bulk action
  197. # create new ticket
  198. ticket1 = ticket_create(
  199. data: {
  200. customer: 'nico',
  201. group: 'Users',
  202. title: 'overview count test #3',
  203. body: 'overview count test #3',
  204. }
  205. )
  206. ticket2 = ticket_create(
  207. data: {
  208. customer: 'nico',
  209. group: 'Users',
  210. title: 'overview count test #4',
  211. body: 'overview count test #4',
  212. }
  213. )
  214. click(text: 'Overviews')
  215. # enable full overviews
  216. execute(
  217. js: '$(".content.active .sidebar").css("display", "block")',
  218. )
  219. click(text: 'Unassigned & Open')
  220. watch_for(
  221. css: '.content.active',
  222. value: 'overview count test #4',
  223. timeout: 8,
  224. )
  225. # remember current overview count
  226. overview_counter_before = overview_counter()
  227. # select both via bulk action
  228. click(
  229. css: '.content.active table tr td input[value="' + ticket1[:id] + '"] + .icon-checkbox.icon-unchecked',
  230. fast: true,
  231. )
  232. # scroll to reply - needed for chrome
  233. scroll_to(
  234. position: 'top',
  235. css: '.content.active table tr td input[value="' + ticket2[:id] + '"] + .icon-checkbox.icon-unchecked',
  236. )
  237. click(
  238. css: '.content.active table tr td input[value="' + ticket2[:id] + '"] + .icon-checkbox.icon-unchecked',
  239. fast: true,
  240. )
  241. exists(
  242. css: '.content.active table tr td input[value="' + ticket1[:id] + '"][type="checkbox"]:checked',
  243. )
  244. exists(
  245. css: '.content.active table tr td input[value="' + ticket2[:id] + '"][type="checkbox"]:checked',
  246. )
  247. exists(
  248. displayed: false,
  249. css: '.content.active .bulkAction [data-name="pending_time"]',
  250. )
  251. select(
  252. css: '.content.active .bulkAction [name="state_id"]',
  253. value: 'pending close',
  254. )
  255. exists(
  256. displayed: true,
  257. css: '.content.active .bulkAction [data-name="pending_time"]',
  258. )
  259. set(
  260. css: '.content.active .bulkAction [data-item="date"]',
  261. value: '05/23/2037',
  262. )
  263. select(
  264. css: '.content.active .bulkAction [name="group_id"]',
  265. value: 'Users',
  266. )
  267. select(
  268. css: '.content.active .bulkAction [name="owner_id"]',
  269. value: 'Test Master Agent',
  270. )
  271. click(
  272. css: '.content.active .bulkAction .js-confirm',
  273. )
  274. click(
  275. css: '.content.active .bulkAction .js-submit',
  276. )
  277. watch_for_disappear(
  278. css: '.content.active table tr td input[value="' + ticket2[:id] + '"]',
  279. timeout: 12,
  280. )
  281. exists_not(
  282. css: '.content.active table tr td input[value="' + ticket1[:id] + '"]',
  283. )
  284. exists_not(
  285. css: '.content.active table tr td input[value="' + ticket2[:id] + '"]',
  286. )
  287. # get new overview count
  288. overview_counter_new = overview_counter()
  289. assert_equal(overview_counter_before['#ticket/view/all_unassigned'] - 2, overview_counter_new['#ticket/view/all_unassigned'])
  290. # open ticket by search
  291. ticket_open_by_search(
  292. number: ticket1[:number],
  293. )
  294. sleep 1
  295. # close ticket
  296. ticket_update(
  297. data: {
  298. state: 'closed',
  299. }
  300. )
  301. # open ticket by search
  302. ticket_open_by_search(
  303. number: ticket2[:number],
  304. )
  305. sleep 1
  306. # close ticket
  307. ticket_update(
  308. data: {
  309. state: 'closed',
  310. }
  311. )
  312. # cleanup
  313. tasks_close_all()
  314. end
  315. end