popover_spec.rb 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Popover', type: :system do
  4. # This test covers generic PopoverProvidable behavior
  5. it 'opening & auto-closing' do
  6. visit "#ticket/zoom/#{Ticket.first.id}"
  7. within :active_content do
  8. find('.ticketZoom-header .js-avatar').hover
  9. end
  10. # popover opened up
  11. expect(page).to have_css('.popover')
  12. visit '#dashboard'
  13. # move mouse to another location
  14. # for reliable popover re-spawning
  15. find('.menu').hover
  16. # popover is not visible when moving to another page without moving mouse
  17. # https://github.com/zammad/zammad/issues/4058
  18. expect(page).to have_no_css('.popover')
  19. visit "#ticket/zoom/#{Ticket.first.id}"
  20. # popover is not visible when moving back to the original page without moving mouse
  21. expect(page).to have_no_css('.popover')
  22. within :active_content do
  23. find('.ticketZoom-header .js-avatar').hover
  24. end
  25. # popover opens up again
  26. expect(page).to have_css('.popover')
  27. end
  28. it 'popover in overviews closes after overview update', ensure_threads_exited: true do
  29. ensure_websocket do
  30. visit '#ticket/view/all_unassigned'
  31. end
  32. within :active_content do
  33. find('.user-popover').hover
  34. end
  35. expect(page).to have_css('.popover')
  36. Ticket.find(1).update!(owner: current_user)
  37. ensure_block_keeps_running do
  38. Sessions.thread_client(Sessions.sessions.first, 0, Time.now.utc, nil)
  39. end
  40. expect(page).to have_no_css('.popover')
  41. end
  42. it 'popover of another agent closes after taskbar update' do
  43. ensure_websocket do
  44. visit "#ticket/zoom/#{Ticket.first.id}"
  45. end
  46. taskbar = Taskbar.where(key: 'Ticket-1', user_id: current_user.id).first
  47. allow(taskbar).to receive(:update_preferences_infos)
  48. within :active_content do
  49. taskbar.update! preferences: { 'tasks' => [{
  50. 'user_id' => create(:admin).id,
  51. 'apps' => taskbar.preferences['tasks'].first['apps'],
  52. }] }
  53. TransactionDispatcher.commit
  54. find('.js-attributeBar .user-popover').hover
  55. end
  56. expect(page).to have_css('.popover')
  57. taskbar.update! preferences: { 'tasks' => [] }
  58. TransactionDispatcher.commit
  59. expect(page).to have_no_css('.popover')
  60. end
  61. end