maintenance_mode_test.rb 3.0 KB

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