online_notification_spec.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Online notification', type: :system do
  4. let(:session_user) { User.find_by(login: 'admin@example.com') }
  5. describe 'circle after pending reached' do
  6. around do |example|
  7. Ticket.without_callback :save, :before, :ticket_reset_pending_time_seconds do
  8. example.run
  9. end
  10. end
  11. context 'when pending time is reached soon' do
  12. before do
  13. visit "ticket/zoom/#{ticket.id}"
  14. find("a[data-key='Ticket-#{ticket.id}']")
  15. end
  16. let(:ticket) { create(:ticket, owner: session_user, group: Group.first, state_name: 'pending reminder', pending_time: 4.seconds.from_now) }
  17. it 'loads as pending ticket' do
  18. expect(page).to have_css('.icon.pending')
  19. end
  20. it 'switches to open ticket' do
  21. expect(page).to have_css('.icon.open')
  22. end
  23. context 'when time is reached in non-active tab' do
  24. before { visit 'dashboard' }
  25. it 'loads as pending ticket' do
  26. expect(page).to have_css('.icon.pending')
  27. end
  28. it 'switches to open ticket' do
  29. expect(page).to have_css('.icon.open')
  30. end
  31. end
  32. end
  33. context 'when pending time is set to reached soon to an open ticket' do
  34. before do
  35. ensure_websocket do
  36. visit "ticket/zoom/#{ticket.id}"
  37. find("a[data-key='Ticket-#{ticket.id}']")
  38. end
  39. ticket.update! state: Ticket::State.lookup(name: 'pending reminder'), pending_time: 5.seconds.from_now
  40. end
  41. let(:ticket) { create(:ticket, owner: session_user, group: Group.first) }
  42. it 'loads as pending ticket' do
  43. expect(page).to have_css('.icon.pending')
  44. end
  45. it 'switches to open ticket' do
  46. expect(page).to have_css('.icon.open')
  47. end
  48. end
  49. end
  50. end