agent_ticket_online_notification_test.rb 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. require 'browser_test_helper'
  2. class AgentTicketOnlineNotificationTest < TestCase
  3. def test_online_notifications
  4. @browser = browser_instance
  5. login(
  6. username: 'master@example.com',
  7. password: 'test',
  8. url: browser_url,
  9. )
  10. tasks_close_all()
  11. # create new ticket
  12. ticket_create(
  13. data: {
  14. customer: 'nico',
  15. group: 'Users',
  16. title: 'online notification #1',
  17. body: 'online notification #1',
  18. },
  19. )
  20. browser2 = browser_instance
  21. login(
  22. browser: browser2,
  23. username: 'agent1@example.com',
  24. password: 'test',
  25. url: browser_url,
  26. )
  27. tasks_close_all(browser: browser2)
  28. click(
  29. browser: browser2,
  30. css: '.js-toggleNotifications',
  31. )
  32. click(
  33. browser: browser2,
  34. css: '.js-mark',
  35. )
  36. sleep 2
  37. # remove all notificatons
  38. online_notitifcation_close_all(
  39. browser: browser2,
  40. )
  41. exists_not(
  42. browser: browser2,
  43. css: '.js-noNotifications.hide',
  44. )
  45. match(
  46. browser: browser2,
  47. css: '.js-noNotifications',
  48. value: 'No unread Notifications',
  49. )
  50. exists(
  51. browser: browser2,
  52. css: '.js-mark.hide',
  53. )
  54. match_not(
  55. browser: browser2,
  56. css: '.js-notificationsCounter',
  57. value: '\d',
  58. no_quote: true,
  59. )
  60. ticket_create(
  61. data: {
  62. customer: 'nico',
  63. group: 'Users',
  64. title: 'online notification #2',
  65. body: 'online notification #2',
  66. },
  67. )
  68. watch_for(
  69. browser: browser2,
  70. css: '.js-notificationsContainer .js-item',
  71. value: 'online notification #2',
  72. timeout: 10,
  73. )
  74. match(
  75. browser: browser2,
  76. css: '.js-notificationsCounter',
  77. value: '1',
  78. )
  79. exists_not(
  80. browser: browser2,
  81. css: '.js-mark.hide',
  82. )
  83. ticket_create(
  84. data: {
  85. customer: 'nico',
  86. group: 'Users',
  87. title: 'online notification #3',
  88. body: 'online notification #3',
  89. },
  90. )
  91. watch_for(
  92. browser: browser2,
  93. css: '.js-notificationsContainer .js-item',
  94. value: 'online notification #3',
  95. timeout: 6,
  96. )
  97. # flanky
  98. watch_for(
  99. browser: browser2,
  100. css: '.js-notificationsCounter',
  101. value: '2',
  102. )
  103. items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
  104. count = items.count
  105. assert_equal(2, count)
  106. items[1].click
  107. click(
  108. browser: browser2,
  109. css: '.js-toggleNotifications',
  110. )
  111. watch_for(
  112. browser: browser2,
  113. css: '.js-notificationsCounter',
  114. value: '1',
  115. )
  116. items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
  117. assert_equal(2, items.count)
  118. items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
  119. assert_equal(1, items.count)
  120. ticket_create(
  121. data: {
  122. customer: 'nico',
  123. group: 'Users',
  124. title: 'online notification #4',
  125. body: 'online notification #4',
  126. },
  127. )
  128. watch_for(
  129. browser: browser2,
  130. css: '.js-notificationsCounter',
  131. value: '2',
  132. )
  133. items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
  134. assert_equal(3, items.count)
  135. items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
  136. assert_equal(1, items.count)
  137. click(
  138. browser: browser2,
  139. css: '.js-mark',
  140. )
  141. sleep 3
  142. items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
  143. assert_equal(3, items.count)
  144. # flanky
  145. items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
  146. assert_equal(3, items.count)
  147. match_not(
  148. browser: browser2,
  149. css: '.js-notificationsCounter',
  150. value: '\d',
  151. no_quote: true,
  152. )
  153. ticket_create(
  154. data: {
  155. customer: 'nico',
  156. group: 'Users',
  157. title: 'online notification #5',
  158. body: 'online notification #5',
  159. },
  160. )
  161. watch_for(
  162. browser: browser2,
  163. css: '.js-notificationsCounter',
  164. value: '1',
  165. )
  166. items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
  167. assert_equal(4, items.count)
  168. items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
  169. assert_equal(3, items.count)
  170. # NOTE: title update will generate extra notification - so we will have 5
  171. ticket_update(
  172. data: {
  173. title: 'online notification #5/5',
  174. state: 'closed',
  175. },
  176. )
  177. watch_for(
  178. browser: browser2,
  179. css: '.js-notificationsContainer .js-item',
  180. value: 'online notification #5/5',
  181. timeout: 20,
  182. )
  183. watch_for(
  184. browser: browser2,
  185. css: '.js-notificationsContainer .js-item.is-inactive',
  186. value: 'online notification #5/5',
  187. timeout: 20,
  188. )
  189. match_not(
  190. browser: browser2,
  191. css: '.js-notificationsCounter',
  192. value: '\d',
  193. no_quote: true,
  194. )
  195. items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
  196. assert_equal(6, items.count)
  197. items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
  198. assert_equal(6, items.count)
  199. end
  200. def test_online_notifications_render
  201. @browser = browser_instance
  202. login(
  203. username: 'master@example.com',
  204. password: 'test',
  205. url: browser_url,
  206. )
  207. tasks_close_all()
  208. browser2 = browser_instance
  209. login(
  210. browser: browser2,
  211. username: 'agent1@example.com',
  212. password: 'test',
  213. url: browser_url,
  214. )
  215. tasks_close_all(browser: browser2)
  216. click(
  217. browser: browser2,
  218. css: '.js-toggleNotifications',
  219. )
  220. online_notitifcation_close_all(browser: browser2)
  221. ticket_create(
  222. data: {
  223. customer: 'nico',
  224. group: 'Users',
  225. title: 'online notification render #1',
  226. body: 'online notification render #1',
  227. },
  228. )
  229. ticket_create(
  230. data: {
  231. customer: 'nico',
  232. group: 'Users',
  233. title: 'online notification render #2',
  234. body: 'online notification render #2',
  235. },
  236. )
  237. watch_for(
  238. browser: browser2,
  239. css: '.js-notificationsCounter',
  240. value: '2',
  241. )
  242. execute(
  243. browser: browser2,
  244. js: '$(".js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text").text("render test 2")',
  245. )
  246. execute(
  247. browser: browser2,
  248. js: '$(".js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text").text("render test 1")',
  249. )
  250. match(
  251. browser: browser2,
  252. css: '.js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text',
  253. value: 'render test 2',
  254. )
  255. match(
  256. browser: browser2,
  257. css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
  258. value: 'render test 1',
  259. )
  260. ticket_create(
  261. data: {
  262. customer: 'nico',
  263. group: 'Users',
  264. title: 'online notification render #3',
  265. body: 'online notification render #3',
  266. },
  267. )
  268. watch_for(
  269. browser: browser2,
  270. css: '.js-notificationsCounter',
  271. value: '3',
  272. )
  273. match(
  274. browser: browser2,
  275. css: '.js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text',
  276. value: 'online notification render #3',
  277. )
  278. match(
  279. browser: browser2,
  280. css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
  281. value: 'render test 2',
  282. )
  283. match(
  284. browser: browser2,
  285. css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
  286. value: 'render test 1',
  287. )
  288. ticket_update(
  289. data: {
  290. state: 'closed',
  291. },
  292. )
  293. watch_for(
  294. browser: browser2,
  295. css: '.js-notificationsCounter',
  296. value: '2',
  297. )
  298. match(
  299. browser: browser2,
  300. css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(1) .activity-text',
  301. value: 'online notification render #3',
  302. )
  303. match(
  304. browser: browser2,
  305. css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(2) .activity-text',
  306. value: 'online notification render #3',
  307. )
  308. match(
  309. browser: browser2,
  310. css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
  311. value: 'render test 2',
  312. )
  313. match(
  314. browser: browser2,
  315. css: '.js-notificationsContainer .js-items .js-item:nth-child(4) .activity-text',
  316. value: 'render test 1',
  317. )
  318. execute(
  319. browser: browser2,
  320. js: '$(".js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text").text("render test 3")',
  321. )
  322. close_online_notitifcation(
  323. browser: browser2,
  324. data: {
  325. position: 3,
  326. },
  327. )
  328. match(
  329. browser: browser2,
  330. css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(1) .activity-text',
  331. value: 'online notification render #3',
  332. )
  333. match(
  334. browser: browser2,
  335. css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
  336. value: 'render test 3',
  337. )
  338. match(
  339. browser: browser2,
  340. css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
  341. value: 'render test 1',
  342. )
  343. end
  344. end