Maintenance: Stabilize hidden chat button selenium test case.

This commit is contained in:
Dominik Klein 2021-08-14 00:05:18 +02:00
parent 7e6e751d69
commit 7502c230d3

View file

@ -4,27 +4,34 @@ require 'rails_helper'
RSpec.describe 'Chat Handling', type: :system do RSpec.describe 'Chat Handling', type: :system do
let(:agent_chat_switch_selector) { '#navigation .js-chatMenuItem .js-switch' } let(:agent_chat_switch_selector) { '#navigation .js-chatMenuItem .js-switch' }
let(:chat_url) { "/assets/chat/znuny_open_by_button.html?port=#{ENV['WS_PORT']}" }
def authenticate def authenticate
Setting.set('chat', true) Setting.set('chat', true)
true true
end end
it 'Check that button is hidden after idle timeout (JQuery and without JQuery variant)', authenticated_as: :authenticate do shared_examples 'chat button is hidden after idle timeout' do
it 'Check that button is hidden after idle timeout', authenticated_as: :authenticate do
click agent_chat_switch_selector click agent_chat_switch_selector
open_window_and_switch open_window_and_switch
visit "/assets/chat/znuny_open_by_button.html?port=#{ENV['WS_PORT']}" visit chat_url
expect(page).to have_css('.zammad-chat', visible: :all) expect(page).to have_css('.zammad-chat', visible: :all)
expect(page).to have_css('.zammad-chat-is-hidden', visible: :all) expect(page).to have_css('.zammad-chat-is-hidden', visible: :all)
expect(page).to have_no_css('.open-zammad-chat:not([style*="display: none"]', visible: :all) expect(page).to have_no_css('.open-zammad-chat:not([style*="display: none"]', visible: :all, wait: 20)
end
end
visit "/assets/chat/znuny-no-jquery-open_by_button.html?port=#{ENV['WS_PORT']}" context 'when jquery variant is used' do
include_examples 'chat button is hidden after idle timeout'
end
expect(page).to have_css('.zammad-chat', visible: :all) context 'when none jquery variant is used' do
expect(page).to have_css('.zammad-chat-is-hidden', visible: :all) let(:chat_url) { "/assets/chat/znuny-no-jquery-open_by_button.html?port=#{ENV['WS_PORT']}" }
expect(page).to have_no_css('.open-zammad-chat:not([style*="display: none"]', visible: :all)
include_examples 'chat button is hidden after idle timeout'
end end
end end