From 984bb9c4f54406f9f5da08ea0559e22fb1fc9a3c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 23 Mar 2016 08:24:25 +0100 Subject: [PATCH] Code layout improvements. --- test/browser/aaa_getting_started_test.rb | 10 ++++----- test/browser/abb_one_group_test.rb | 24 ++++++--------------- test/browser/admin_channel_email_test.rb | 7 +++--- test/browser/taskbar_task_test.rb | 16 +++++++------- test/browser_test_helper.rb | 27 +++++++++++++++++++----- 5 files changed, 46 insertions(+), 38 deletions(-) diff --git a/test/browser/aaa_getting_started_test.rb b/test/browser/aaa_getting_started_test.rb index 23258ecc3..78c928950 100644 --- a/test/browser/aaa_getting_started_test.rb +++ b/test/browser/aaa_getting_started_test.rb @@ -13,12 +13,12 @@ class AaaGettingStartedTest < TestCase mailbox_password = ENV['MAILBOX_INIT'].split(':')[1] @browser = browser_instance - location( url: browser_url ) + location(url: browser_url) watch_for( css: '.setup.wizard', value: 'setup new system', ) - click( css: '.js-start .btn--primary' ) + click(css: '.js-start .btn--primary') watch_for( css: '.setup.wizard', value: 'admin', @@ -47,7 +47,7 @@ class AaaGettingStartedTest < TestCase css: '.js-admin input[name="password_confirm"]', value: 'test1234äöüß', ) - click( css: '.js-admin .btn--success' ) + click(css: '.js-admin .btn--success') # getting started - base watch_for( @@ -197,7 +197,7 @@ class AaaGettingStartedTest < TestCase accounts.each {|account| # getting started - auto mail - location( url: browser_url + '/#getting_started/channel' ) + location(url: browser_url + '/#getting_started/channel') click( css: '.js-channel .email .provider_name', ) @@ -269,7 +269,7 @@ class AaaGettingStartedTest < TestCase accounts.each {|account| # getting started - manual mail - location( url: browser_url + '/#getting_started/channel' ) + location(url: browser_url + '/#getting_started/channel') click( css: '.js-channel .email .provider_name', diff --git a/test/browser/abb_one_group_test.rb b/test/browser/abb_one_group_test.rb index 89527ec78..f6ac1c14a 100644 --- a/test/browser/abb_one_group_test.rb +++ b/test/browser/abb_one_group_test.rb @@ -37,20 +37,14 @@ class AgentTicketActionLevel0Test < TestCase tasks_close_all() # invite agent (with one group) - click( - css: '#navigation a[href="#dashboard"]', - ) - click( - css: '.active.content .tab[data-area="first-steps-widgets"]', - ) + click(css: '#navigation a[href="#dashboard"]') + click(css: '.active.content .tab[data-area="first-steps-widgets"]') watch_for( css: '.active.content', value: 'Configuration', ) - click( - css: '.active.content .js-inviteAgent', - ) - sleep 4 + click(css: '.active.content .js-inviteAgent') + modal_ready() set( css: '.modal [name="firstname"]', value: 'Bob', @@ -94,12 +88,9 @@ class AgentTicketActionLevel0Test < TestCase # customer ticket create click(css: 'a[href="#new"]') - click(css: 'a[href="#customer_ticket_new"]') - sleep 2 + click(css: 'a[href="#customer_ticket_new"]', wait: 2) - exists_not( - css: '.newTicket select[name="group_id"]', - ) + exists_not(css: '.newTicket select[name="group_id"]') set( css: '.newTicket input[name="title"]', @@ -109,8 +100,7 @@ class AgentTicketActionLevel0Test < TestCase css: '.newTicket [data-name="body"]', value: 'one group body', ) - click(css: '.newTicket button.js-submit') - sleep 5 + click(css: '.newTicket button.js-submit', wait: 5) # check if ticket is shown location_check(url: '#ticket/zoom/') diff --git a/test/browser/admin_channel_email_test.rb b/test/browser/admin_channel_email_test.rb index d77b8ced9..bfc342348 100644 --- a/test/browser/admin_channel_email_test.rb +++ b/test/browser/admin_channel_email_test.rb @@ -25,7 +25,7 @@ class AdminChannelEmailTest < TestCase click(css: '#content .js-channelNew') - sleep 2 + modal_ready() set( css: '.modal input[name="realname"]', @@ -65,7 +65,7 @@ class AdminChannelEmailTest < TestCase # re-create click(css: '#content .js-channelNew') - sleep 2 + modal_ready() set( css: '.modal input[name="realname"]', @@ -99,7 +99,8 @@ class AdminChannelEmailTest < TestCase # set invalid folder click(css: '#content .js-editInbound') - sleep 2 + + modal_ready() set( css: '.modal input[name="options::folder"]', diff --git a/test/browser/taskbar_task_test.rb b/test/browser/taskbar_task_test.rb index 25e27d7c8..89bffe299 100644 --- a/test/browser/taskbar_task_test.rb +++ b/test/browser/taskbar_task_test.rb @@ -12,8 +12,8 @@ class TaskbarTaskTest < TestCase tasks_close_all() # persistant task - click( css: 'a[href="#new"]' ) - click( css: 'a[href="#ticket/create"]' ) + click(css: 'a[href="#new"]') + click(css: 'a[href="#ticket/create"]', wait: 0.8) set( css: '.active .newTicket input[name="title"]', value: 'some test AAA', @@ -31,7 +31,7 @@ class TaskbarTaskTest < TestCase sleep 3 # check if task still exists - click( css: '.task' ) + click(css: '.task', wait: 0.8) match( css: '.active .newTicket input[name="title"]', @@ -40,7 +40,7 @@ class TaskbarTaskTest < TestCase tasks_close_all() - exists_not( css: '.active .newTicket input[name="title"]' ) + exists_not(css: '.active .newTicket input[name="title"]') end def test_persistant_task_with_relogin @@ -52,8 +52,8 @@ class TaskbarTaskTest < TestCase ) tasks_close_all() - click( css: 'a[href="#new"]' ) - click( css: 'a[href="#ticket/create"]' ) + click(css: 'a[href="#new"]') + click(css: 'a[href="#ticket/create"]') set( css: '.active .newTicket input[name="title"]', value: 'INBOUND TEST#1', @@ -63,8 +63,8 @@ class TaskbarTaskTest < TestCase value: 'INBOUND BODY TEST#1', ) - click( css: 'a[href="#new"]' ) - click( css: 'a[href="#ticket/create"]' ) + click(css: 'a[href="#new"]') + click(css: 'a[href="#ticket/create"]', wait: 0.8) set( css: '.active .newTicket input[name="title"]', value: 'OUTBOUND TEST#1', diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 2135b76d2..f31fa2ddf 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -264,7 +264,7 @@ class TestCase < Test::Unit::TestCase return if !clues instance.execute_script("$('.js-modal--clue .js-close').click()") assert(true, 'clues closed') - sleep 4 + sleep 2 end =begin @@ -416,6 +416,23 @@ class TestCase < Test::Unit::TestCase sleep 0.3 end +=begin + + modal_ready( + browser: browser1, + ) + +=end + + def modal_ready(params) + switch_window_focus(params) + log('modal_ready', params) + + instance = params[:browser] || @browser + + sleep 2 + end + =begin execute( @@ -544,7 +561,7 @@ class TestCase < Test::Unit::TestCase element = instance.find_elements(css: "#{params[:css]}.js-shadow + .js-input")[0] element.click element.clear - sleep 0.5 + sleep 0.4 element.send_keys(params[:value]) sleep 0.2 element.send_keys(:enter) @@ -562,7 +579,7 @@ class TestCase < Test::Unit::TestCase dropdown.select_by(:text, params[:value]) #puts "select - #{params.inspect}" rescue - sleep 0.5 + sleep 0.4 # just try again log('select', { rescure: true }) @@ -574,7 +591,7 @@ class TestCase < Test::Unit::TestCase dropdown.select_by(:text, params[:value]) #puts "select2 - #{params.inspect}" end - sleep 0.5 + sleep 0.4 end =begin @@ -1014,7 +1031,7 @@ class TestCase < Test::Unit::TestCase # accept task close warning if params[:discard_changes] - sleep 1 + modal_ready() instance.find_elements(css: '.modal button.js-submit')[0].click end