agent_ticket_email_reply_keep_body_test.rb 6.7 KB

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