user_access_permissions_test.rb 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. require 'browser_test_helper'
  2. class AgentProfilePermissionsTest < TestCase
  3. def test_agent_to_edit_customer_profile
  4. @browser = browser_instance
  5. login(
  6. username: 'agent1@example.com',
  7. password: 'test',
  8. url: browser_url,
  9. )
  10. tasks_close_all()
  11. user_open_by_search(value: 'Braun')
  12. verify_task(
  13. data: {
  14. title: 'Nicole Braun',
  15. }
  16. )
  17. watch_for(
  18. css: '.content.active .profile-window',
  19. value: 'note',
  20. )
  21. watch_for(
  22. css: '.content.active .profile-window',
  23. value: 'email',
  24. )
  25. set(
  26. css: '.content.active [data-name="note"]',
  27. value: 'some note 123',
  28. )
  29. empty_search()
  30. # check and change note again in edit screen
  31. click(css: '.content.active .js-action .icon-arrow-down', fast: true)
  32. click(css: '.content.active .js-action [data-type="edit"]')
  33. watch_for(
  34. css: '.content.active .modal',
  35. value: 'note',
  36. )
  37. watch_for(
  38. css: '.content.active .modal',
  39. value: 'some note 123',
  40. )
  41. set(
  42. css: '.modal [name="lastname"]',
  43. value: 'B2',
  44. )
  45. set(
  46. css: '.modal [data-name="note"]',
  47. value: 'some note abc',
  48. )
  49. click(css: '.content.active .modal button.js-submit')
  50. watch_for(
  51. css: '.content.active .profile-window',
  52. value: 'some note abc',
  53. )
  54. verify_task(
  55. data: {
  56. title: 'Nicole B2',
  57. }
  58. )
  59. # change lastname back
  60. click(css: '.content.active .js-action .icon-arrow-down', fast: true)
  61. click(css: '.content.active .js-action [data-type="edit"]')
  62. watch_for(
  63. css: '.content.active .modal',
  64. value: 'note',
  65. )
  66. set(
  67. css: '.modal [name="lastname"]',
  68. value: 'Braun',
  69. )
  70. click(css: '.content.active .modal button.js-submit')
  71. verify_task(
  72. data: {
  73. title: 'Nicole Braun',
  74. }
  75. )
  76. end
  77. def test_agent_edit_admin_profile
  78. @browser = browser_instance
  79. login(
  80. username: 'agent1@example.com',
  81. password: 'test',
  82. url: browser_url,
  83. )
  84. tasks_close_all()
  85. user_open_by_search(value: 'Test Master')
  86. verify_task(
  87. data: {
  88. title: 'Test Master Agent',
  89. }
  90. )
  91. watch_for(
  92. css: '.content.active .profile-window',
  93. value: 'note',
  94. )
  95. watch_for(
  96. css: '.content.active .profile-window',
  97. value: 'email',
  98. )
  99. empty_search()
  100. sleep 2
  101. click(css: '.content.active .js-action .icon-arrow-down', fast: true)
  102. exists_not(css: '.content.active .js-action [data-type="edit"]')
  103. end
  104. def test_agent_to_edit_admin_ticket_user_details
  105. @browser = browser_instance
  106. login(
  107. username: 'master@example.com',
  108. password: 'test',
  109. url: browser_url,
  110. )
  111. tasks_close_all()
  112. ticket1 = ticket_create(
  113. data: {
  114. customer: 'master',
  115. group: 'Users',
  116. title: 'test_user_access_permissions - ticket 1',
  117. body: 'test_user_access_permissions - ticket 1',
  118. },
  119. )
  120. tasks_close_all()
  121. logout()
  122. login(
  123. username: 'agent1@example.com',
  124. password: 'test',
  125. url: browser_url,
  126. )
  127. tasks_close_all()
  128. ticket_open_by_search(
  129. number: ticket1[:number],
  130. )
  131. watch_for(
  132. css: '.content.active .tabsSidebar-holder',
  133. value: ticket1[:title],
  134. )
  135. click(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  136. click(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
  137. exists_not(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
  138. end
  139. def test_agent_to_edit_customer_ticket
  140. @browser = browser_instance
  141. login(
  142. username: 'agent1@example.com',
  143. password: 'test',
  144. url: browser_url,
  145. )
  146. tasks_close_all()
  147. ticket1 = ticket_create(
  148. data: {
  149. customer: 'nico',
  150. group: 'Users',
  151. title: 'test_user_access_permissions - ticket 2',
  152. body: 'test_user_access_permissions - ticket 2',
  153. },
  154. )
  155. ticket_open_by_search(
  156. number: ticket1[:number],
  157. )
  158. click(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  159. click(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
  160. click(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
  161. set(
  162. css: '.modal [name="lastname"]',
  163. value: 'B2',
  164. )
  165. set(
  166. css: '.modal [data-name="note"]',
  167. value: 'some note abc',
  168. )
  169. click(css: '.content.active .modal button.js-submit')
  170. watch_for(
  171. css: '.content.active .sidebar[data-tab="customer"] .sidebar-block [data-name="note"]',
  172. value: 'some note abc',
  173. )
  174. watch_for(
  175. css: '.content.active .sidebar[data-tab="customer"] .sidebar-block h3[title="Name"]',
  176. value: 'Nicole B2',
  177. )
  178. sleep 2
  179. # change lastname back
  180. click(css: '.content.active .sidebar[data-tab="customer"] .js-actions')
  181. click(css: 'li[data-type="customer-edit"]')
  182. watch_for(
  183. css: '.content.active .modal',
  184. value: 'note',
  185. )
  186. set(
  187. css: '.modal [name="lastname"]',
  188. value: 'Braun',
  189. )
  190. set(
  191. css: '.modal [data-name="note"]',
  192. value: 'some note abc',
  193. )
  194. click(css: '.content.active .modal button.js-submit')
  195. watch_for(
  196. css: '.content.active .sidebar[data-tab="customer"] .sidebar-block [data-name="note"]',
  197. value: 'some note abc',
  198. )
  199. watch_for(
  200. css: '.content.active .sidebar[data-tab="customer"] .sidebar-block [title="Name"]',
  201. value: 'Nicole Braun',
  202. )
  203. end
  204. def test_agent_to_edit_customer_ticket_details
  205. @browser = browser_instance
  206. login(
  207. username: 'agent1@example.com',
  208. password: 'test',
  209. url: browser_url,
  210. )
  211. tasks_close_all()
  212. ticket1 = ticket_create(
  213. data: {
  214. customer: 'nico',
  215. group: 'Users',
  216. title: 'test_user_access_permissions - ticket 3',
  217. body: 'test_user_access_permissions - ticket 3',
  218. },
  219. )
  220. ticket_open_by_search(
  221. number: ticket1[:number],
  222. )
  223. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  224. exists(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
  225. exists(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
  226. # scroll to the Avatar at the top of the zoom view and click it
  227. # scrolling is needed because the browser might have scrolled down
  228. # caused by a undeliverable email (of the created ticket)
  229. zoom_top_avatar_selector = '.content.active .tabsSidebar-holder .js-avatar'
  230. scroll_to(
  231. position: 'botton',
  232. css: zoom_top_avatar_selector,
  233. )
  234. click(css: zoom_top_avatar_selector)
  235. # check and change note again in edit screen
  236. click(css: '.content.active .js-action .dropdown-toggle')
  237. click(css: '.content.active .js-action [data-type="edit"]')
  238. watch_for(
  239. css: '.content.active .modal',
  240. value: 'note',
  241. )
  242. set(
  243. css: '.modal [name="lastname"]',
  244. value: 'B2',
  245. )
  246. set(
  247. css: '.modal [data-name="note"]',
  248. value: 'some note abc',
  249. )
  250. click(css: '.content.active .modal button.js-submit')
  251. watch_for(
  252. css: '.content.active .profile-window',
  253. value: 'some note abc',
  254. )
  255. verify_task(
  256. data: {
  257. title: 'Nicole B2',
  258. }
  259. )
  260. # change lastname back
  261. click(css: '.content.active .js-action .dropdown-toggle')
  262. click(css: '.content.active .js-action [data-type="edit"]')
  263. watch_for(
  264. css: '.content.active .modal',
  265. value: 'note',
  266. )
  267. set(
  268. css: '.modal [name="lastname"]',
  269. value: 'Braun',
  270. )
  271. set(
  272. css: '.modal [data-name="note"]',
  273. value: 'note',
  274. )
  275. click(css: '.content.active .modal button.js-submit')
  276. verify_task(
  277. data: {
  278. title: 'Nicole Braun',
  279. }
  280. )
  281. end
  282. def test_agent_to_edit_admin_ticket_details
  283. @browser = browser_instance
  284. login(
  285. username: 'agent1@example.com',
  286. password: 'test',
  287. url: browser_url,
  288. )
  289. tasks_close_all()
  290. ticket1 = ticket_create(
  291. data: {
  292. customer: 'master',
  293. group: 'Users',
  294. title: 'test_user_access_permissions - ticket 4',
  295. body: 'test_user_access_permissions - ticket 4',
  296. },
  297. )
  298. ticket_open_by_search(
  299. number: ticket1[:number],
  300. )
  301. exists(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
  302. exists(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
  303. exists_not(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
  304. # scroll to the Avatar at the top of the zoom view and click it
  305. # scrolling is needed because the browser might have scrolled down
  306. # caused by a undeliverable email (of the created ticket)
  307. zoom_top_avatar_selector = '.content.active .tabsSidebar-holder .js-avatar'
  308. scroll_to(
  309. position: 'botton',
  310. css: zoom_top_avatar_selector,
  311. )
  312. click(css: zoom_top_avatar_selector)
  313. click(css: '.content.active .js-action .icon-arrow-down', fast: true)
  314. exists_not(css: '.content.active .js-action [data-type="edit"]')
  315. end
  316. end