From e57707336ccd43ed9c720b2a1d216e5a3ab03f17 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 22 Jun 2018 14:32:51 +0200 Subject: [PATCH] Test stabilization: Disconnect connected chats only There is a race condition between clients exiting the chat session and disconnecting via a click. In cases where the client disconnects first the disconnect button is already hidden (not clickable) and Selenium will fail. --- test/browser/chat_test.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/browser/chat_test.rb b/test/browser/chat_test.rb index 7238a3271..7350986ce 100644 --- a/test/browser/chat_test.rb +++ b/test/browser/chat_test.rb @@ -186,8 +186,8 @@ class ChatTest < TestCase browser: agent, css: 'a[href="#customer_chat"]', ) - agent.find_elements( { css: '.active .chat-window .js-disconnect' } ).each(&:click) - agent.find_elements( { css: '.active .chat-window .js-close' } ).each(&:click) + agent.find_elements(css: '.active .chat-window .js-disconnect:not(.is-hidden)').each(&:click) + agent.find_elements(css: '.active .chat-window .js-close').each(&:click) customer = browser_instance location( @@ -299,8 +299,8 @@ class ChatTest < TestCase browser: agent, css: 'a[href="#customer_chat"]', ) - agent.find_elements( { css: '.active .chat-window .js-disconnect' } ).each(&:click) - agent.find_elements( { css: '.active .chat-window .js-close' } ).each(&:click) + agent.find_elements(css: '.active .chat-window .js-disconnect:not(.is-hidden)').each(&:click) + agent.find_elements(css: '.active .chat-window .js-close').each(&:click) customer = browser_instance location( @@ -383,7 +383,7 @@ class ChatTest < TestCase ) click( browser: agent, - css: '.active .chat-window .js-disconnect', + css: '.active .chat-window .js-disconnect:not(.is-hidden)', ) click( browser: agent, @@ -407,8 +407,8 @@ class ChatTest < TestCase browser: customer, css: '.zammad-chat-is-open', ) - agent.find_elements( { css: '.active .chat-window .js-disconnect' } ).each(&:click) - agent.find_elements( { css: '.active .chat-window .js-close' } ).each(&:click) + agent.find_elements(css: '.active .chat-window .js-disconnect:not(.is-hidden)').each(&:click) + agent.find_elements(css: '.active .chat-window .js-close').each(&:click) sleep 2 click( browser: customer, @@ -454,8 +454,8 @@ class ChatTest < TestCase browser: agent, css: 'a[href="#customer_chat"]', ) - agent.find_elements( { css: '.active .chat-window .js-disconnect' } ).each(&:click) - agent.find_elements( { css: '.active .chat-window .js-close' } ).each(&:click) + agent.find_elements(css: '.active .chat-window .js-disconnect:not(.is-hidden)').each(&:click) + agent.find_elements(css: '.active .chat-window .js-close').each(&:click) # set chat preferences click( @@ -606,8 +606,8 @@ class ChatTest < TestCase browser: agent, css: 'a[href="#customer_chat"]', ) - agent.find_elements( { css: '.active .chat-window .js-disconnect' } ).each(&:click) - agent.find_elements( { css: '.active .chat-window .js-close' } ).each(&:click) + agent.find_elements(css: '.active .chat-window .js-disconnect:not(.is-hidden)').each(&:click) + agent.find_elements(css: '.active .chat-window .js-close').each(&:click) exists( browser: agent,