agent_ticket_macro_test.rb 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'browser_test_helper'
  3. class AgentTicketMacroTest < TestCase
  4. def test_close_and_tag_as_spam_default
  5. @browser = browser_instance
  6. login(
  7. username: 'agent1@example.com',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. tasks_close_all
  12. ticket = ticket_create(
  13. data: {
  14. customer: 'nico',
  15. group: 'Users',
  16. title: 'macro "Close & Tag as Spam" default',
  17. body: 'some body - macro "Close & Tag as Spam" default',
  18. },
  19. )
  20. perform_macro(name: 'Close & Tag as Spam')
  21. # check redirect after perfoming macro
  22. location_check(
  23. url: "#{browser_url}/#dashboard",
  24. )
  25. # reopen ticket and verify tags
  26. ticket_open_by_search(
  27. number: ticket[:number],
  28. )
  29. tags_verify(
  30. tags: {
  31. 'spam' => true,
  32. 'tag1' => false,
  33. }
  34. )
  35. end
  36. def test_ux_flow_next_up_stay_on_tab
  37. @browser = browser_instance
  38. login(
  39. username: 'admin@example.com',
  40. password: 'test',
  41. url: browser_url,
  42. )
  43. tasks_close_all
  44. ux_flow_next_up = 'Stay on tab'
  45. macro_name = "Test #{ux_flow_next_up}"
  46. macro_create(
  47. name: macro_name,
  48. ux_flow_next_up: ux_flow_next_up,
  49. actions: {
  50. 'Tags' => {
  51. operator: 'add',
  52. value: 'spam',
  53. }
  54. }
  55. )
  56. ticket = ticket_create(
  57. data: {
  58. customer: 'nico',
  59. group: 'Users',
  60. title: "macro #{macro_name}",
  61. body: "some body - macro #{macro_name}",
  62. },
  63. )
  64. perform_macro(name: macro_name)
  65. location_check(
  66. url: "#{browser_url}/#ticket/zoom/#{ticket[:id]}",
  67. )
  68. tags_verify(
  69. tags: {
  70. 'spam' => true,
  71. 'tag1' => false,
  72. }
  73. )
  74. end
  75. def test_ux_flow_next_up_close_tab
  76. @browser = browser_instance
  77. login(
  78. username: 'admin@example.com',
  79. password: 'test',
  80. url: browser_url,
  81. )
  82. tasks_close_all
  83. ux_flow_next_up = 'Close tab'
  84. macro_name = "Test #{ux_flow_next_up}"
  85. macro_create(
  86. name: macro_name,
  87. ux_flow_next_up: ux_flow_next_up,
  88. )
  89. ticket_create(
  90. data: {
  91. customer: 'nico',
  92. group: 'Users',
  93. title: "macro #{macro_name}",
  94. body: "some body - macro #{macro_name}",
  95. },
  96. )
  97. perform_macro(name: macro_name)
  98. watch_for_disappear(
  99. css: '.tasks > a',
  100. timeout: 5,
  101. )
  102. end
  103. def test_ux_flow_next_up_advance_to_next_ticket_from_overview
  104. @browser = browser_instance
  105. login(
  106. username: 'admin@example.com',
  107. password: 'test',
  108. url: browser_url,
  109. )
  110. tasks_close_all
  111. ux_flow_next_up = 'Advance to next ticket from overview'
  112. macro_name = "Test #{ux_flow_next_up}"
  113. macro_create(
  114. name: macro_name,
  115. ux_flow_next_up: ux_flow_next_up,
  116. )
  117. title_prefix = "macro #{macro_name}"
  118. ticket1 = ticket_create(
  119. data: {
  120. customer: 'nico',
  121. group: 'Users',
  122. title: "#{title_prefix} - 1",
  123. body: "some body - macro #{macro_name}",
  124. },
  125. )
  126. ticket2 = ticket_create(
  127. data: {
  128. customer: 'nico',
  129. group: 'Users',
  130. title: "#{title_prefix} - 2",
  131. body: "some body - macro #{macro_name}",
  132. },
  133. )
  134. # we need to close all open ticket tasks because
  135. # otherwise the Zoom view won't change in "Overview"-mode
  136. # when we re-enter the Zoom view for a ticket via the overview
  137. tasks_close_all
  138. overview_open(
  139. link: '#ticket/view/all_unassigned',
  140. )
  141. await_text(text: ticket1[:title])
  142. await_text(text: ticket2[:title])
  143. ticket_open_by_overview(
  144. title: ticket1[:title],
  145. link: '#ticket/view/all_unassigned',
  146. )
  147. verify_task(
  148. data: {
  149. title: ticket1[:title],
  150. }
  151. )
  152. perform_macro(name: macro_name)
  153. verify_task(
  154. data: {
  155. title: ticket2[:title],
  156. }
  157. )
  158. end
  159. end