From 258130d82415297911299f790c75bb497fb1cbbb Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 8 Mar 2015 22:34:14 +0100 Subject: [PATCH] Improved tests. --- test/browser/prefereces_test.rb | 30 ++++++++--- test/browser_test_helper.rb | 89 ++++++++++++++++++++++++++------- 2 files changed, 93 insertions(+), 26 deletions(-) diff --git a/test/browser/prefereces_test.rb b/test/browser/prefereces_test.rb index 72c73245d..6566c67a2 100644 --- a/test/browser/prefereces_test.rb +++ b/test/browser/prefereces_test.rb @@ -79,9 +79,14 @@ class PreferencesTest < TestCase ) # check language in ticket create + open_task( + :data => { + :title => 'Anruf', + } + ) verify_task( :data => { - :title => 'anruf', + :title => 'Anruf', } ) open_task( @@ -106,8 +111,10 @@ class PreferencesTest < TestCase ) # check language in ticket zoom - ticket_open_by_search( - :number => ticket[:number], + open_task( + :data => { + :title => 'preferences lang check #2', + } ) watch_for( :css => '.content.active', @@ -186,9 +193,14 @@ class PreferencesTest < TestCase ) # check language in ticket create + open_task( + :data => { + :title => 'Call', + } + ) verify_task( :data => { - :title => 'call', + :title => 'Call', } ) open_task( @@ -213,8 +225,10 @@ class PreferencesTest < TestCase ) # check language in ticket zoom - ticket_open_by_search( - :number => ticket[:number], + open_task( + :data => { + :title => 'preferences lang check #2', + } ) watch_for( :css => '.content.active', @@ -269,11 +283,11 @@ class PreferencesTest < TestCase :css => 'body', :value => 'Sprache', ) - sleep 6 + sleep 10 # check if language is still used after reload reload() - sleep 2 + sleep 10 watch_for( :css => 'body', diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 9379fc66c..b0f53af1d 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -1053,10 +1053,11 @@ wait untill text in selector disabppears ticket_update( :browser => browser1, :data => { - :title => '', - :body => 'some body', - :group => 'some group', - :state => 'closed', + :title => '', + :customer => 'some_customer@example.com', + :body => 'some body', + :group => 'some group', + :state => 'closed', }, :do_not_submit => true, ) @@ -1095,6 +1096,56 @@ wait untill text in selector disabppears # :css => '.content.active .page-header .ticket-title-update', # :value => :tab, # }, + end + if data[:customer] + + # select tab + click( :browser => instance, :css => '.active .tabsSidebar-tab[data-tab="customer"]') + + click( :browser => instance, :css => '.active div[data-tab="customer"] .js-actions .select-arrow' ) + click( :browser => instance, :css => '.active div[data-tab="customer"] .js-actions a[data-type="customer-change"]' ) + watch_for( + :browser => instance, + :css => '.modal', + :value => 'change', + ) + + element = instance.find_elements( { :css => '.modal input[name="customer_id_completion"]' } )[0] + element.click + element.clear + + # workaround, sometimes focus is not triggered + element.send_keys( data[:customer] ) + sleep 4 + + # check if pulldown is open, it's not working stable via selenium + res = instance.execute_script( "$('.modal .user_autocompletion .js-recipientDropdown').hasClass('open')" ) + #puts "res #{res.inspect}" + if !res + #puts "IS NOT OPEN!, open it" + instance.execute_script( "$('.modal .user_autocompletion .js-recipientDropdown').addClass('open')" ) + end + element.send_keys( :arrow_down ) + sleep 0.3 + instance.find_elements( { :css => '.modal .user_autocompletion .recipientList-entry.js-user.is-active' } )[0].click + sleep 0.3 + + click( :browser => instance, :css => '.modal .js-submit' ) + + watch_for_disappear( + :browser => instance, + :css => '.modal', + ) + + watch_for( + :browser => instance, + :css => '.active .tabsSidebar', + :value => data[:customer], + ) + + # select tab + click( :browser => instance, :css => '.active .tabsSidebar-tab[data-tab="ticket"]') + end if data[:body] #instance.execute_script( '$(".content.active div[data-name=body]").focus()' ) @@ -1127,22 +1178,24 @@ wait untill text in selector disabppears sleep 0.2 end - found = nil - (1..5).each {|loop| - if !found - begin - text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text - if text =~ /(Discard your unsaved changes.|Verwerfen der)/ - found = true + if data[:state] || data[:group] || data[:body] + found = nil + (1..5).each {|loop| + if !found + begin + text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text + if text =~ /(Discard your unsaved changes.|Verwerfen der)/ + found = true + end + rescue + # just try again end - rescue - # just try again + sleep 1 end - sleep 1 + } + if !found + raise "no discard message found" end - } - if !found - raise "no discard message found" end if params[:do_not_submit] @@ -1393,7 +1446,7 @@ wait untill text in selector disabppears user_create( :browser => browser2, :data => { - :login => 'some login' + random, + #:login => 'some login' + random, :firstname => 'Manage Firstname' + random, :lastname => 'Manage Lastname' + random, :email => user_email,