chat_spec.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Chat Handling', type: :system do
  4. let(:agent_chat_switch_selector) { '#navigation .js-chatMenuItem .js-switch' }
  5. let(:chat_url) { "/assets/chat/znuny_open_by_button.html?port=#{ENV['WS_PORT']}" }
  6. def authenticate
  7. Setting.set('chat', true)
  8. true
  9. end
  10. shared_examples 'chat button is hidden after idle timeout' do
  11. it 'Check that button is hidden after idle timeout', authenticated_as: :authenticate do
  12. click agent_chat_switch_selector
  13. open_window_and_switch
  14. visit chat_url
  15. expect(page).to have_css('.zammad-chat', visible: :all)
  16. expect(page).to have_css('.zammad-chat-is-hidden', visible: :all)
  17. expect(page).to have_no_css('.open-zammad-chat:not([style*="display: none"]', visible: :all, wait: 20)
  18. end
  19. end
  20. context 'when jquery variant is used' do
  21. include_examples 'chat button is hidden after idle timeout'
  22. end
  23. context 'when none jquery variant is used' do
  24. let(:chat_url) { "/assets/chat/znuny-no-jquery-open_by_button.html?port=#{ENV['WS_PORT']}" }
  25. include_examples 'chat button is hidden after idle timeout'
  26. end
  27. end