user_access_permissions_test.rb 9.3 KB

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