user_access_permissions_test.rb 9.2 KB

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