app_maintenance_spec.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Gql::Subscriptions::AppMaintenance, type: :graphql do
  4. let(:subscription) do
  5. <<~QUERY
  6. subscription appMaintenance {
  7. appMaintenance {
  8. type
  9. }
  10. }
  11. QUERY
  12. end
  13. let(:mock_channel) { build_mock_channel }
  14. let(:expected_type) { 'app_version' }
  15. let(:expected_msg) do
  16. {
  17. result: {
  18. 'data' => {
  19. 'appMaintenance' => {
  20. 'type' => expected_type
  21. }
  22. }
  23. },
  24. more: true,
  25. }
  26. end
  27. shared_examples 'app maintenance subscription' do
  28. it 'correct app maintenance update/change event' do
  29. expect(mock_channel.mock_broadcasted_messages).to eq([expected_msg])
  30. end
  31. end
  32. context 'when app maintenance update/change events (trigger actions in the frontend) are triggered' do
  33. before do
  34. gql.execute(subscription, context: { channel: mock_channel })
  35. AppVersion.set(true, app_version_set)
  36. end
  37. context 'when app version event is triggered' do
  38. let(:app_version_set) { AppVersion::MSG_APP_VERSION }
  39. include_examples 'app maintenance subscription'
  40. end
  41. context 'when restart auto event is triggered' do
  42. let(:app_version_set) { AppVersion::MSG_RESTART_AUTO }
  43. let(:expected_type) { 'restart_auto' }
  44. include_examples 'app maintenance subscription'
  45. end
  46. context 'when restart manual event is triggered' do
  47. let(:app_version_set) { AppVersion::MSG_RESTART_MANUAL }
  48. let(:expected_type) { 'restart_manual' }
  49. include_examples 'app maintenance subscription'
  50. end
  51. context 'when config change event is triggered' do
  52. let(:app_version_set) { AppVersion::MSG_CONFIG_CHANGED }
  53. let(:expected_type) { 'config_changed' }
  54. include_examples 'app maintenance subscription'
  55. end
  56. end
  57. end