maintenance_session_message_test.rb 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. require 'browser_test_helper'
  2. class MaintenanceSessionMessageTest < TestCase
  3. def test_message
  4. string = rand(99_999_999_999_999_999).to_s
  5. title_html = "test <b>#{string}</b>"
  6. title_text = "test <b>#{string}<\/b>"
  7. message_html = "message <b>1äöüß</b> #{string}\n\n\nhttps://zammad.org"
  8. message_text = "message <b>1äöüß</b> #{string}\n\n\nhttps://zammad.org"
  9. # check #1
  10. browser1 = browser_instance
  11. login(
  12. browser: browser1,
  13. username: 'master@example.com',
  14. password: 'test',
  15. url: browser_url,
  16. )
  17. browser2 = browser_instance
  18. login(
  19. browser: browser2,
  20. username: 'agent1@example.com',
  21. password: 'test',
  22. url: browser_url,
  23. )
  24. click(
  25. browser: browser1,
  26. css: 'a[href="#manage"]',
  27. )
  28. click(
  29. browser: browser1,
  30. css: 'a[href="#system/maintenance"]',
  31. )
  32. set(
  33. browser: browser1,
  34. css: '.content.active .js-Message input[name="head"]',
  35. value: title_html,
  36. )
  37. set(
  38. browser: browser1,
  39. css: '.content.active .js-Message .js-textarea[data-name="message"]',
  40. value: message_html,
  41. )
  42. click(
  43. browser: browser1,
  44. css: '.content.active .js-Message button.js-submit',
  45. )
  46. modal_ready(browser: browser2)
  47. watch_for(
  48. browser: browser2,
  49. css: '.modal',
  50. value: title_text,
  51. )
  52. watch_for(
  53. browser: browser2,
  54. css: '.modal',
  55. value: message_text,
  56. )
  57. match_not(
  58. browser: browser1,
  59. css: 'body',
  60. value: message_text,
  61. )
  62. click(
  63. browser: browser2,
  64. css: 'div.modal-header .js-close',
  65. )
  66. modal_disappear(browser: browser2)
  67. # check #2
  68. click(
  69. browser: browser1,
  70. css: 'a[href="#manage"]',
  71. )
  72. click(
  73. browser: browser1,
  74. css: 'a[href="#system/maintenance"]',
  75. )
  76. set(
  77. browser: browser1,
  78. css: '.content.active .js-Message input[name="head"]',
  79. value: "#{title_html} #2",
  80. )
  81. set(
  82. browser: browser1,
  83. css: '.content.active .js-Message .js-textarea[data-name="message"]',
  84. value: "#{message_html} #2",
  85. )
  86. click(
  87. browser: browser1,
  88. css: '.content.active .js-Message button.js-submit',
  89. )
  90. modal_ready(browser: browser2)
  91. watch_for(
  92. browser: browser2,
  93. css: '.modal',
  94. value: "#{title_text} #2",
  95. )
  96. watch_for(
  97. browser: browser2,
  98. css: '.modal',
  99. value: "#{message_text} #2",
  100. )
  101. match_not(
  102. browser: browser1,
  103. css: 'body',
  104. value: message_text,
  105. )
  106. click(
  107. browser: browser2,
  108. css: 'div.modal-header .js-close',
  109. )
  110. modal_disappear(browser: browser2)
  111. # check #3
  112. click(
  113. browser: browser1,
  114. css: 'a[href="#manage"]',
  115. )
  116. click(
  117. browser: browser1,
  118. css: 'a[href="#system/maintenance"]',
  119. )
  120. set(
  121. browser: browser1,
  122. css: '.content.active .js-Message input[name="head"]',
  123. value: "#{title_html} #3",
  124. )
  125. set(
  126. browser: browser1,
  127. css: '.content.active .js-Message .js-textarea[data-name="message"]',
  128. value: "#{message_html} #3",
  129. )
  130. click(
  131. browser: browser1,
  132. css: '.content.active .js-Message input[name="reload"]',
  133. )
  134. click(
  135. browser: browser1,
  136. css: '.content.active .js-Message button.js-submit',
  137. )
  138. modal_ready(browser: browser2)
  139. watch_for(
  140. browser: browser2,
  141. css: '.modal',
  142. value: "#{title_text} #3",
  143. )
  144. watch_for(
  145. browser: browser2,
  146. css: '.modal',
  147. value: "#{message_text} #3",
  148. )
  149. watch_for(
  150. browser: browser2,
  151. css: '.modal',
  152. value: 'Continue session',
  153. )
  154. match_not(
  155. browser: browser1,
  156. css: 'body',
  157. value: message_text,
  158. )
  159. end
  160. end