agent_ticket_overview_level0_test.rb 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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. # verify correct behaviour for issue #1864 - Bulk-Action: Not possible to change owner
  316. def test_bulk_owner_change
  317. @browser = browser_instance
  318. login(
  319. username: 'master@example.com',
  320. password: 'test',
  321. url: browser_url,
  322. )
  323. tasks_close_all()
  324. # test bulk action
  325. # create new ticket
  326. ticket1 = ticket_create(
  327. data: {
  328. customer: 'nico',
  329. group: 'Users',
  330. title: 'overview owner change test #1',
  331. body: 'overview owner change #1',
  332. }
  333. )
  334. ticket2 = ticket_create(
  335. data: {
  336. customer: 'nico',
  337. group: 'Users',
  338. title: 'overview owner change #2',
  339. body: 'overview owner change #2',
  340. }
  341. )
  342. overview_open(
  343. link: '#ticket/view/all_unassigned',
  344. )
  345. watch_for(
  346. css: '.content.active',
  347. value: 'overview owner change #2',
  348. timeout: 8,
  349. )
  350. # remember current overview count
  351. overview_counter_before = overview_counter()
  352. # select both via bulk action
  353. click(
  354. css: '.content.active table tr td input[value="' + ticket1[:id] + '"] + .icon-checkbox.icon-unchecked',
  355. fast: true,
  356. )
  357. # scroll to reply - needed for chrome
  358. scroll_to(
  359. position: 'top',
  360. css: '.content.active table tr td input[value="' + ticket2[:id] + '"] + .icon-checkbox.icon-unchecked',
  361. )
  362. click(
  363. css: '.content.active table tr td input[value="' + ticket2[:id] + '"] + .icon-checkbox.icon-unchecked',
  364. fast: true,
  365. )
  366. exists(
  367. css: '.content.active table tr td input[value="' + ticket1[:id] + '"][type="checkbox"]:checked',
  368. )
  369. exists(
  370. css: '.content.active table tr td input[value="' + ticket2[:id] + '"][type="checkbox"]:checked',
  371. )
  372. select(
  373. css: '.content.active .bulkAction [name="owner_id"]',
  374. value: 'Test Master Agent',
  375. )
  376. select(
  377. css: '.content.active .bulkAction [name="state_id"]',
  378. value: 'closed',
  379. )
  380. click(
  381. css: '.content.active .bulkAction .js-confirm',
  382. )
  383. click(
  384. css: '.content.active .bulkAction .js-submit',
  385. )
  386. watch_for_disappear(
  387. css: '.content.active table tr td input[value="' + ticket2[:id] + '"]',
  388. timeout: 12,
  389. )
  390. exists_not(
  391. css: '.content.active table tr td input[value="' + ticket1[:id] + '"]',
  392. )
  393. exists_not(
  394. css: '.content.active table tr td input[value="' + ticket2[:id] + '"]',
  395. )
  396. # get new overview count
  397. overview_counter_new = overview_counter()
  398. assert_equal(overview_counter_before['#ticket/view/all_unassigned'] - 2, overview_counter_new['#ticket/view/all_unassigned'])
  399. # cleanup
  400. tasks_close_all()
  401. end
  402. # verify fix for issue #2026 - Bulk action should not be shown if user has no change permissions
  403. def test_no_bulk_action_when_missing_change_permission
  404. @browser = browser_instance
  405. login(
  406. username: 'master@example.com',
  407. password: 'test',
  408. url: browser_url,
  409. )
  410. tasks_close_all()
  411. # create new group
  412. group_create(
  413. data: {
  414. name: 'some group2',
  415. },
  416. )
  417. role_edit(
  418. data: {
  419. name: 'Agent',
  420. group_permissions: { 2 => ['full'],
  421. 3 => ['full'], }
  422. },
  423. )
  424. user_edit(
  425. data: {
  426. login: 'master@example.com',
  427. permissions: { 1 => ['full'],
  428. 2 => ['full'],
  429. 3 => ['full'], }
  430. },
  431. )
  432. user_create(
  433. data: {
  434. firstname: 'Tester',
  435. lastname: 'Agent 2',
  436. email: 'agent2@example.com',
  437. password: 'test',
  438. role: 'Agent',
  439. permissions: { 1 => %w[read create overview] }
  440. },
  441. )
  442. # create new tickets
  443. can_change_ticket = ticket_create(
  444. data: {
  445. customer: 'nico',
  446. group: 'some group2',
  447. title: 'overview test #5',
  448. body: 'overview test #5',
  449. }
  450. )
  451. cannot_change_ticket = ticket_create(
  452. data: {
  453. customer: 'nico',
  454. group: 'Users',
  455. title: 'overview test #6',
  456. body: 'overview test #6',
  457. }
  458. )
  459. logout() # logout as master@example.com then login as agent2@example.com
  460. login(
  461. username: 'agent2@example.com',
  462. password: 'test',
  463. url: browser_url,
  464. )
  465. tasks_close_all()
  466. # open Overview menu tab
  467. click(
  468. css: '.js-menu .js-overviewsMenuItem',
  469. )
  470. # enable full overviews
  471. execute(
  472. js: '$(".content.active .sidebar").css("display", "block")',
  473. )
  474. # click Unassigned & Open tab
  475. click(
  476. css: '.content.active [href="#ticket/view/all_unassigned"]',
  477. )
  478. watch_for(
  479. css: '.content.active',
  480. value: 'overview test #6',
  481. timeout: 8,
  482. )
  483. # first select the ticket that we have change rights to
  484. check(
  485. css: '.content.active table tr td input[value="' + can_change_ticket[:id] + '"]',
  486. )
  487. # check that the bulk action form appears
  488. exists(
  489. displayed: true,
  490. css: '.content.active .bulkAction',
  491. )
  492. # then select the ticket that we do not have change rights to
  493. scroll_to(
  494. position: 'top',
  495. css: '.content.active table tr td input[value="' + cannot_change_ticket[:id] + '"] + .icon-checkbox.icon-unchecked',
  496. )
  497. check(
  498. css: '.content.active table tr td input[value="' + cannot_change_ticket[:id] + '"]',
  499. )
  500. # check that the bulk action form disappears
  501. exists(
  502. displayed: false,
  503. css: '.content.active .bulkAction',
  504. )
  505. # de-select the ticket that we do not have change rights to
  506. uncheck(
  507. css: '.content.active table tr td input[value="' + cannot_change_ticket[:id] + '"]',
  508. fast: true,
  509. )
  510. # check that the bulk action form appears again
  511. exists(
  512. displayed: true,
  513. css: '.content.active .bulkAction',
  514. )
  515. # de-select the ticket that we have change rights to
  516. uncheck(
  517. css: '.content.active table tr td input[value="' + can_change_ticket[:id] + '"]',
  518. fast: true,
  519. )
  520. # check that the bulk action form disappears again
  521. exists(
  522. displayed: false,
  523. css: '.content.active .bulkAction',
  524. )
  525. # cleanup
  526. tasks_close_all()
  527. logout() # logout as agent2@example.com and then login as master@example.com to clean up tickets
  528. login(
  529. username: 'master@example.com',
  530. password: 'test',
  531. url: browser_url,
  532. )
  533. tasks_close_all()
  534. # open ticket by search
  535. ticket_open_by_search(
  536. number: cannot_change_ticket[:number],
  537. )
  538. sleep 1
  539. # close ticket
  540. ticket_update(
  541. data: {
  542. state: 'closed',
  543. }
  544. )
  545. # open ticket by search
  546. ticket_open_by_search(
  547. number: can_change_ticket[:number],
  548. )
  549. sleep 1
  550. # close ticket
  551. ticket_update(
  552. data: {
  553. state: 'closed',
  554. }
  555. )
  556. end
  557. end