From 7502c230d3ddb59b360351976072108b4f9c24e5 Mon Sep 17 00:00:00 2001 From: Dominik Klein Date: Sat, 14 Aug 2021 00:05:18 +0200 Subject: [PATCH] Maintenance: Stabilize hidden chat button selenium test case. --- spec/system/chat_spec.rb | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/spec/system/chat_spec.rb b/spec/system/chat_spec.rb index 71d7b3e11..8b29be291 100644 --- a/spec/system/chat_spec.rb +++ b/spec/system/chat_spec.rb @@ -4,27 +4,34 @@ require 'rails_helper' RSpec.describe 'Chat Handling', type: :system do 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 Setting.set('chat', true) true end - it 'Check that button is hidden after idle timeout (JQuery and without JQuery variant)', authenticated_as: :authenticate do - click agent_chat_switch_selector + 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 - 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-is-hidden', visible: :all) - expect(page).to have_no_css('.open-zammad-chat:not([style*="display: none"]', 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_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) - 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) + context 'when none jquery variant is used' do + let(:chat_url) { "/assets/chat/znuny-no-jquery-open_by_button.html?port=#{ENV['WS_PORT']}" } + + include_examples 'chat button is hidden after idle timeout' end end