maintenance_mode_test.rb 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class MaintenanceModeTest < TestCase
  4. def test_mode
  5. browser1 = browser_instance
  6. login(
  7. browser: browser1,
  8. username: 'master@example.com',
  9. password: 'test',
  10. url: browser_url,
  11. )
  12. browser2 = browser_instance
  13. location(
  14. browser: browser2,
  15. url: browser_url,
  16. )
  17. click(
  18. browser: browser1,
  19. css: 'a[href="#manage"]',
  20. )
  21. click(
  22. browser: browser1,
  23. css: 'a[href="#system/maintenance"]',
  24. )
  25. exists_not(
  26. browser: browser2,
  27. css: '.js-maintenanceMode',
  28. )
  29. switch(
  30. browser: browser1,
  31. css: '.content.active .js-modeSetting',
  32. type: 'on',
  33. no_check: true,
  34. )
  35. # check warning
  36. watch_for(
  37. browser: browser1,
  38. css: '.content.active .modal .modal-header',
  39. value: 'confirm',
  40. )
  41. click(
  42. browser: browser1,
  43. css: '.content.active .modal .js-submit',
  44. )
  45. watch_for(
  46. browser: browser2,
  47. css: '.js-maintenanceMode',
  48. )
  49. # try to logon with normal agent, should not work
  50. login(
  51. browser: browser2,
  52. username: 'agent1@example.com',
  53. password: 'test',
  54. url: browser_url,
  55. success: false,
  56. )
  57. login(
  58. browser: browser2,
  59. username: 'nicole.braun@zammad.org',
  60. password: 'test',
  61. url: browser_url,
  62. success: false,
  63. )
  64. # logout with admin and logon again
  65. logout(
  66. browser: browser1,
  67. )
  68. sleep 4
  69. login(
  70. browser: browser1,
  71. username: 'master@example.com',
  72. password: 'test',
  73. url: browser_url,
  74. )
  75. click(
  76. browser: browser1,
  77. css: 'a[href="#manage"]',
  78. )
  79. click(
  80. browser: browser1,
  81. css: 'a[href="#system/maintenance"]',
  82. )
  83. switch(
  84. browser: browser1,
  85. css: '.content.active .js-modeSetting',
  86. type: 'off',
  87. )
  88. watch_for_disappear(
  89. browser: browser2,
  90. css: '.js-maintenanceMode',
  91. )
  92. # try to logon with normal agent, should work again
  93. login(
  94. browser: browser2,
  95. username: 'agent1@example.com',
  96. password: 'test',
  97. url: browser_url,
  98. )
  99. logout(
  100. browser: browser2,
  101. )
  102. sleep 4
  103. login(
  104. browser: browser2,
  105. username: 'nicole.braun@zammad.org',
  106. password: 'test',
  107. url: browser_url,
  108. )
  109. switch(
  110. browser: browser1,
  111. css: '.content.active .js-modeSetting',
  112. type: 'on',
  113. no_check: true,
  114. )
  115. # check warning
  116. watch_for(
  117. browser: browser1,
  118. css: '.content.active .modal .modal-header',
  119. value: 'confirm',
  120. )
  121. click(
  122. browser: browser1,
  123. css: '.content.active .modal .js-submit',
  124. )
  125. watch_for(
  126. browser: browser2,
  127. css: '#login',
  128. )
  129. watch_for(
  130. browser: browser2,
  131. css: '.js-maintenanceMode',
  132. )
  133. switch(
  134. browser: browser1,
  135. css: '.content.active .js-modeSetting',
  136. type: 'off',
  137. )
  138. watch_for_disappear(
  139. browser: browser2,
  140. css: '.js-maintenanceMode',
  141. )
  142. end
  143. end