user_access_permissions_test.rb 8.8 KB

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