From 7936573c2d051adec83d3d980b6e224c8c0acf30 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 22 Mar 2013 09:29:44 +0100 Subject: [PATCH] Added sla management browser tests. --- test/browser/manage_test.rb | 149 +++++++++++++++++++++++++++++++++--- test/browser_test_helper.rb | 7 ++ 2 files changed, 147 insertions(+), 9 deletions(-) diff --git a/test/browser/manage_test.rb b/test/browser/manage_test.rb index b17bc0290..9a3fe9508 100644 --- a/test/browser/manage_test.rb +++ b/test/browser/manage_test.rb @@ -3,8 +3,10 @@ require 'browser_test_helper' class ManageTest < TestCase def test_user - user = 'manage-test-' + rand(999999).to_s - user_email = user + '@example.com' + random = 'manage-test-' + rand(999999).to_s + user_email = random + '@example.com' + + # user tests = [ { :name => 'user', @@ -32,17 +34,17 @@ class ManageTest < TestCase { :execute => 'set', :css => 'input[name=login]', - :value => 'some login' + user, + :value => 'some login' + random, }, { :execute => 'set', :css => 'input[name="firstname"]', - :value => 'Manage Firstname' + user, + :value => 'Manage Firstname' + random, }, { :execute => 'set', :css => 'input[name="lastname"]', - :value => 'Manage Lastname' + user, + :value => 'Manage Lastname' + random, }, { :execute => 'set', @@ -74,7 +76,7 @@ class ManageTest < TestCase { :execute => 'match', :css => 'body', - :value => user, + :value => random, :match_result => true, }, { @@ -88,7 +90,7 @@ class ManageTest < TestCase { :execute => 'set', :css => 'input[name="lastname"]', - :value => '2Manage Lastname' + user, + :value => '2Manage Lastname' + random, }, { :execute => 'click', @@ -101,16 +103,145 @@ class ManageTest < TestCase { :execute => 'match', :css => 'body', - :value => '2Manage Lastname' + user, + :value => '2Manage Lastname' + random, :match_result => true, }, { :execute => 'wait', :value => 1, }, - ], }, + { + :name => 'sla', + :action => [ + { + :execute => 'click', + :css => 'a[href="#admin"]', + }, + { + :execute => 'click', + :css => 'a[href="#slas"]', + }, + { + :execute => 'wait', + :value => 2, + }, + { + :execute => 'click', + :css => 'a[data-type="new"]', + }, + { + :execute => 'wait', + :value => 2, + }, + { + :execute => 'set', + :css => 'input[name=name]', + :value => 'some sla' + random, + }, + { + :execute => 'set', + :css => 'input[name="first_response_time"]', + :value => 61, + }, + { + :execute => 'click', + :css => 'button.submit', + }, + { + :execute => 'wait', + :value => 5, + }, + { + :execute => 'match', + :css => 'body', + :value => random, + :match_result => true, + }, + { + :execute => 'click', + :css => 'a[data-type="edit"]:last-child', + }, + { + :execute => 'wait', + :value => 2, + }, + { + :execute => 'set', + :css => 'input[name=name]', + :value => 'some sla update ' + random, + }, + { + :execute => 'set', + :css => 'input[name="first_response_time"]', + :value => 121, + }, + { + :execute => 'click', + :css => 'button.submit', + }, + { + :execute => 'wait', + :value => 5, + }, + { + :execute => 'match', + :css => 'body', + :value => 'some sla update ' + random, + :match_result => true, + }, + { + :execute => 'wait', + :value => 1, + }, + { + :execute => 'click', + :css => 'a[data-type="destroy"]:last-child', + }, + { + :execute => 'wait', + :value => 2, + }, + { + :execute => 'accept', + :element => :alert, + }, + { + :execute => 'wait', + :value => 2, + }, + { + :execute => 'match', + :css => 'body', + :value => 'some sla update ' + random, + :match_result => false, + }, + { + :execute => 'click', + :css => 'a[href="#/"]', + }, + { + :execute => 'click', + :css => 'a[href="#admin"]', + }, + { + :execute => 'click', + :css => 'a[href="#slas"]', + }, + { + :execute => 'wait', + :value => 2, + }, + { + :execute => 'match', + :css => 'body', + :value => 'some sla update ' + random, + :match_result => false, + }, + ], + + }, ] browser_signle_test_with_login(tests, { :username => 'master@example.com' }) end diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 9d38b4999..3b0efb582 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -176,16 +176,23 @@ class TestCase < Test::Unit::TestCase else assert( false, "(#{test[:name]}) url #{instance.current_url} is not matching #{action[:result]}" ) end + elsif action[:element] == :alert + element = instance.switch_to.alert else assert( false, "(#{test[:name]}) unknow selector for '#{action[:element]}'" ) end if action[:execute] == 'set' + element.clear element.send_keys( action[:value] ) elsif action[:execute] == 'select' dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown.select_by(:text, action[:value]) elsif action[:execute] == 'click' element.click + elsif action[:execute] == 'accept' + element.accept + elsif action[:execute] == 'dismiss' + element.dismiss elsif action[:execute] == 'send_key' element.send_keys action[:value] elsif action[:execute] == 'match'