app_maintenance_spec.rb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Mobile > App Update Check', app: :mobile, type: :system do
  4. context 'when app is not configured yet', authenticated_as: false, set_up: false do
  5. before do
  6. visit '/mobile/login', skip_waiting: true
  7. end
  8. it 'redirects to desktop app for system set-up' do
  9. expect_current_route('getting_started', app: :desktop)
  10. end
  11. end
  12. context 'when checking application rebuild notification', authenticated_as: false do
  13. before do
  14. visit '/login?ApplicationRebuildCheckInterval=500', skip_waiting: true
  15. wait_for_test_flag('useApplicationBuildChecksumQuery.firstResult')
  16. wait_for_test_flag('useAppMaintenanceSubscription.subscribed')
  17. end
  18. it 'shows app rebuild dialog' do
  19. # Append a newline to the manifest file to trigger a reload notification.
  20. Rails.public_path.join('assets/frontend/vite/.vite/manifest.json').open('a') do |file|
  21. file.write("\n")
  22. end
  23. expect(page).to have_text('A newer version of the app is available. Please reload at your earliest.')
  24. end
  25. end
  26. context 'when maintenance mode is activated', authenticated_as: :user do
  27. before do
  28. visit '/', skip_waiting: true
  29. wait_for_test_flag('applicationLoaded.loaded')
  30. wait_for_test_flag('useConfigUpdatesSubscription.subscribed')
  31. Setting.set('maintenance_mode', true)
  32. end
  33. context 'with admin user' do
  34. let(:user) { create(:admin) }
  35. it 'does not log out' do
  36. expect_current_route '/'
  37. end
  38. end
  39. end
  40. context 'when maintenance message is sent', authenticated_as: false do
  41. before do
  42. visit '/', skip_waiting: true
  43. wait_for_test_flag('applicationLoaded.loaded')
  44. wait_for_test_flag('usePushMessagesSubscription.subscribed')
  45. end
  46. it 'reacts to maintenance broadcast message' do
  47. Gql::Subscriptions::PushMessages.trigger({ title: 'Attention', text: 'Maintenance test message.' })
  48. expect(page).to have_text('Attention: Maintenance test message.')
  49. end
  50. end
  51. end