agent_ticket_email_reply_keep_body_test.rb 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. require 'browser_test_helper'
  2. class AgentTicketEmailReplyKeepBodyTest < TestCase
  3. def test_reply_message_keep_body
  4. # merge ticket with closed tab
  5. @browser = browser_instance
  6. login(
  7. username: 'agent1@example.com',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. tasks_close_all()
  12. # create new ticket
  13. ticket_create(
  14. data: {
  15. customer: 'nico',
  16. group: 'Users',
  17. title: 'some subject 123äöü - reply test',
  18. body: 'some body 123äöü - reply test',
  19. },
  20. )
  21. sleep 1
  22. # fill body
  23. ticket_update(
  24. data: {
  25. body: 'keep me',
  26. },
  27. do_not_submit: true,
  28. )
  29. # scroll to reply - needed for chrome
  30. scroll_to(
  31. position: 'botton',
  32. css: '.content.active [data-type="emailReply"]',
  33. )
  34. # click reply
  35. click(css: '.content.active [data-type="emailReply"]')
  36. # check body
  37. watch_for(
  38. css: '.content.active .js-reset',
  39. value: '(Discard your unsaved changes.|Verwerfen der)',
  40. no_quote: true,
  41. )
  42. # check body
  43. ticket_verify(
  44. data: {
  45. body: 'keep me',
  46. },
  47. )
  48. # scroll to reply - needed for chrome
  49. sleep 5
  50. scroll_to(
  51. position: 'botton',
  52. css: '.content.active [data-type="emailReply"]',
  53. )
  54. # click reply
  55. click(css: '.content.active [data-type="emailReply"]')
  56. # check body
  57. watch_for(
  58. css: '.content.active .js-reset',
  59. value: '(Discard your unsaved changes.|Verwerfen der)',
  60. no_quote: true,
  61. )
  62. # check body
  63. ticket_verify(
  64. data: {
  65. body: 'keep me',
  66. },
  67. )
  68. end
  69. def change_quote_config(params = {})
  70. scroll_to(
  71. position: 'botton',
  72. css: '.content.active .js-settingContainer .js-setting',
  73. )
  74. click(css: '.content.active .js-settingContainer .js-setting')
  75. modal_ready()
  76. select(
  77. css: params[:css],
  78. value: params[:value]
  79. )
  80. click(
  81. css: params[:submit_css],
  82. )
  83. modal_close()
  84. modal_disappear()
  85. end
  86. def test_full_quote
  87. @browser = browser_instance
  88. login(
  89. username: 'master@example.com',
  90. password: 'test',
  91. url: browser_url,
  92. )
  93. tasks_close_all()
  94. ticket_open_by_title(
  95. title: 'Welcome to Zammad',
  96. )
  97. watch_for(
  98. css: '.content.active .js-settingContainer .js-setting .dropdown-icon',
  99. )
  100. # enable email full quote in the ticket zoom config page
  101. change_quote_config(
  102. css: '.modal #ui_ticket_zoom_article_email_full_quote select[name="ui_ticket_zoom_article_email_full_quote"]',
  103. value: 'yes',
  104. submit_css: '.modal #ui_ticket_zoom_article_email_full_quote .btn[type="submit"]',
  105. )
  106. change_quote_config(
  107. css: '.modal #ui_ticket_zoom_article_email_full_quote_header select[name="ui_ticket_zoom_article_email_full_quote_header"]',
  108. value: 'yes',
  109. submit_css: '.modal #ui_ticket_zoom_article_email_full_quote_header .btn[type="submit"]',
  110. )
  111. scroll_to(
  112. position: 'botton',
  113. css: '.content.active .ticket-article [data-type="emailReply"]',
  114. )
  115. click(css: '.content.active .ticket-article [data-type="emailReply"]')
  116. full_text = @browser.find_element(css: '.content.active .article-new .articleNewEdit-body').text
  117. match = full_text.match(/\nOn (.*?) Nicole Braun wrote:/)
  118. assert match
  119. assert match[1]
  120. assert Time.zone.parse(match[1])
  121. # try again, but with the full quote header disabled
  122. tasks_close_all()
  123. ticket_open_by_title(
  124. title: 'Welcome to Zammad',
  125. )
  126. change_quote_config(
  127. css: '.modal #ui_ticket_zoom_article_email_full_quote_header select[name="ui_ticket_zoom_article_email_full_quote_header"]',
  128. value: 'no',
  129. submit_css: '.modal #ui_ticket_zoom_article_email_full_quote_header .btn[type="submit"]',
  130. )
  131. scroll_to(
  132. position: 'botton',
  133. css: '.content.active .ticket-article [data-type="emailReply"]',
  134. )
  135. click(css: '.content.active .ticket-article [data-type="emailReply"]')
  136. full_text = @browser.find_element(css: '.content.active .article-new .articleNewEdit-body').text
  137. match = full_text.match(/\nOn (.*?) Nicole Braun wrote:/)
  138. assert_nil match
  139. # after test, turn full quote header back on again
  140. tasks_close_all()
  141. ticket_open_by_title(
  142. title: 'Welcome to Zammad',
  143. )
  144. change_quote_config(
  145. css: '.modal #ui_ticket_zoom_article_email_full_quote_header select[name="ui_ticket_zoom_article_email_full_quote_header"]',
  146. value: 'yes',
  147. submit_css: '.modal #ui_ticket_zoom_article_email_full_quote_header .btn[type="submit"]',
  148. )
  149. end
  150. # Regression test for issue #2344 - Missing translation for Full-Quote-Text "on xy wrote"
  151. def test_full_quote_german_locale
  152. @browser = browser_instance
  153. login(
  154. username: 'master@example.com',
  155. password: 'test',
  156. url: browser_url,
  157. )
  158. tasks_close_all()
  159. ticket_open_by_title(
  160. title: 'Welcome to Zammad',
  161. )
  162. watch_for(
  163. css: '.content.active .js-settingContainer .js-setting .dropdown-icon',
  164. )
  165. # enable email full quote in the ticket zoom config page
  166. change_quote_config(
  167. css: '.modal #ui_ticket_zoom_article_email_full_quote select[name="ui_ticket_zoom_article_email_full_quote"]',
  168. value: 'yes',
  169. submit_css: '.modal #ui_ticket_zoom_article_email_full_quote .btn[type="submit"]',
  170. )
  171. # switch user profile language to German
  172. switch_language(
  173. data: {
  174. language: 'Deutsch'
  175. },
  176. )
  177. ticket_open_by_title(
  178. title: 'Welcome to Zammad',
  179. )
  180. scroll_to(
  181. position: 'botton',
  182. css: '.content.active .ticket-article [data-type="emailReply"]',
  183. )
  184. click(css: '.content.active .ticket-article [data-type="emailReply"]')
  185. full_text = @browser.find_element(css: '.content.active .article-new .articleNewEdit-body').text
  186. match = full_text.match(/\nAm (.*?), schrieb Nicole Braun:/)
  187. assert match
  188. datestamp = match[1]
  189. assert datestamp
  190. assert Time.zone.parse(datestamp)
  191. day_of_week = datestamp.split(',').first
  192. assert %w[Montag Dienstag Mittwoch Donnerstag Freitag Samstag Sonntag].include? day_of_week
  193. # switch user profile language to English again for other tests
  194. switch_language(
  195. data: {
  196. language: 'English (United States)'
  197. },
  198. )
  199. end
  200. end