popover_spec.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Copyright (C) 2012-2024 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. trigger_popover('.ticketZoom-header .js-avatar .user-popover')
  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. trigger_popover('.ticketZoom-header .js-avatar .user-popover')
  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. trigger_popover('.user-popover')
  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. allow_any_instance_of(Taskbar).to receive(:update_preferences_infos)
  47. taskbar = Taskbar.where(key: 'Ticket-1', user_id: current_user.id).first
  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. trigger_popover('.js-attributeBar .user-popover')
  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. def trigger_popover(selector)
  62. find(selector) do |elem|
  63. elem.evaluate_script('Object.keys($(this).data()).includes("bs.popover")')
  64. end.hover
  65. end
  66. end