maintenance_message_test.rb 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class MaintenanceMessageTest < TestCase
  4. def test_websocket
  5. message = 'message 1äöüß ' + rand(99999999999999999).to_s
  6. tests = [
  7. {
  8. :name => 'check #1',
  9. :instance1 => browser_instance,
  10. :instance2 => browser_instance,
  11. :instance1_username => 'master@example.com',
  12. :instance1_password => 'test',
  13. :instance2_username => 'agent1@example.com',
  14. :instance2_password => 'test',
  15. :url => browser_url,
  16. :action => [
  17. {
  18. :execute => 'wait',
  19. :value => 1,
  20. },
  21. {
  22. :where => :instance1,
  23. :execute => 'click',
  24. :css => 'a[href="#manage"]',
  25. },
  26. {
  27. :where => :instance1,
  28. :execute => 'click',
  29. :css => 'a[href="#system/maintenance"]',
  30. },
  31. {
  32. :where => :instance1,
  33. :execute => 'set',
  34. :css => '#content input[name="title"]',
  35. :value => message,
  36. },
  37. {
  38. :where => :instance1,
  39. :execute => 'set',
  40. :css => '#content textarea[name="message"]',
  41. :value => message,
  42. },
  43. {
  44. :where => :instance1,
  45. :execute => 'click',
  46. :css => '#content button[type="submit"]',
  47. },
  48. {
  49. :execute => 'wait',
  50. :value => 5,
  51. },
  52. {
  53. :where => :instance1,
  54. :execute => 'match',
  55. :css => 'body',
  56. :value => message,
  57. :match_result => false,
  58. },
  59. {
  60. :where => :instance2,
  61. :execute => 'check',
  62. :css => '.modal-header',
  63. :result => true,
  64. },
  65. {
  66. :where => :instance2,
  67. :execute => 'watch_for',
  68. :area => 'body',
  69. :value => message,
  70. },
  71. {
  72. :where => :instance2,
  73. :execute => 'click',
  74. :css => 'div.modal-header .close',
  75. },
  76. {
  77. :execute => 'wait',
  78. :value => 2,
  79. },
  80. ],
  81. },
  82. {
  83. :name => 'check #2',
  84. :action => [
  85. {
  86. :where => :instance1,
  87. :execute => 'click',
  88. :css => 'a[href="#manage"]',
  89. },
  90. {
  91. :where => :instance1,
  92. :execute => 'click',
  93. :css => 'a[href="#system/maintenance"]',
  94. },
  95. {
  96. :where => :instance1,
  97. :execute => 'set',
  98. :css => '#content input[name="title"]',
  99. :value => message + ' #2',
  100. },
  101. {
  102. :where => :instance1,
  103. :execute => 'set',
  104. :css => '#content textarea[name="message"]',
  105. :value => message + ' #2',
  106. },
  107. {
  108. :where => :instance1,
  109. :execute => 'click',
  110. :css => '#content button[type="submit"]',
  111. },
  112. {
  113. :execute => 'wait',
  114. :value => 5,
  115. },
  116. {
  117. :where => :instance1,
  118. :execute => 'match',
  119. :css => 'body',
  120. :value => message + ' #2',
  121. :match_result => false,
  122. },
  123. {
  124. :where => :instance1,
  125. :execute => 'check',
  126. :css => 'div.modal-backdrop.fade.in',
  127. :result => false,
  128. },
  129. {
  130. :where => :instance2,
  131. :execute => 'watch_for',
  132. :area => 'body',
  133. :value => message + ' #2',
  134. },
  135. {
  136. :where => :instance2,
  137. :execute => 'click',
  138. :css => 'div.modal-header .close',
  139. },
  140. {
  141. :execute => 'wait',
  142. :value => 2,
  143. },
  144. ],
  145. },
  146. {
  147. :name => 'check #3',
  148. :action => [
  149. {
  150. :where => :instance1,
  151. :execute => 'click',
  152. :css => 'a[href="#manage"]',
  153. },
  154. {
  155. :where => :instance1,
  156. :execute => 'click',
  157. :css => 'a[href="#system/maintenance"]',
  158. },
  159. {
  160. :where => :instance1,
  161. :execute => 'set',
  162. :css => '#content input[name="title"]',
  163. :value => message + ' #3' ,
  164. },
  165. {
  166. :where => :instance1,
  167. :execute => 'set',
  168. :css => '#content textarea[name="message"]',
  169. :value => message + ' #3',
  170. },
  171. {
  172. :where => :instance1,
  173. :execute => 'setCheck',
  174. :css => '#content input[name="reload"][value="1"]',
  175. },
  176. {
  177. :where => :instance1,
  178. :execute => 'click',
  179. :css => '#content button[type="submit"]',
  180. },
  181. {
  182. :execute => 'wait',
  183. :value => 5,
  184. },
  185. {
  186. :where => :instance1,
  187. :execute => 'check',
  188. :css => 'div.modal-backdrop.fade.in',
  189. :result => false,
  190. },
  191. {
  192. :where => :instance1,
  193. :execute => 'match',
  194. :css => 'body',
  195. :value => message + ' #3',
  196. :match_result => false,
  197. },
  198. {
  199. :where => :instance2,
  200. :execute => 'match',
  201. :css => 'body',
  202. :value => message + ' #3',
  203. :match_result => true,
  204. },
  205. {
  206. :where => :instance2,
  207. :execute => 'match',
  208. :css => 'body',
  209. :value => 'Reload application',
  210. :match_result => true,
  211. },
  212. ],
  213. },
  214. ]
  215. browser_double_test(tests)
  216. end
  217. end