Added sla management browser tests.

This commit is contained in:
Martin Edenhofer 2013-03-22 09:29:44 +01:00
parent a70b88c733
commit 7936573c2d
2 changed files with 147 additions and 9 deletions

View file

@ -3,8 +3,10 @@ require 'browser_test_helper'
class ManageTest < TestCase class ManageTest < TestCase
def test_user def test_user
user = 'manage-test-' + rand(999999).to_s random = 'manage-test-' + rand(999999).to_s
user_email = user + '@example.com' user_email = random + '@example.com'
# user
tests = [ tests = [
{ {
:name => 'user', :name => 'user',
@ -32,17 +34,17 @@ class ManageTest < TestCase
{ {
:execute => 'set', :execute => 'set',
:css => 'input[name=login]', :css => 'input[name=login]',
:value => 'some login' + user, :value => 'some login' + random,
}, },
{ {
:execute => 'set', :execute => 'set',
:css => 'input[name="firstname"]', :css => 'input[name="firstname"]',
:value => 'Manage Firstname' + user, :value => 'Manage Firstname' + random,
}, },
{ {
:execute => 'set', :execute => 'set',
:css => 'input[name="lastname"]', :css => 'input[name="lastname"]',
:value => 'Manage Lastname' + user, :value => 'Manage Lastname' + random,
}, },
{ {
:execute => 'set', :execute => 'set',
@ -74,7 +76,7 @@ class ManageTest < TestCase
{ {
:execute => 'match', :execute => 'match',
:css => 'body', :css => 'body',
:value => user, :value => random,
:match_result => true, :match_result => true,
}, },
{ {
@ -88,7 +90,7 @@ class ManageTest < TestCase
{ {
:execute => 'set', :execute => 'set',
:css => 'input[name="lastname"]', :css => 'input[name="lastname"]',
:value => '2Manage Lastname' + user, :value => '2Manage Lastname' + random,
}, },
{ {
:execute => 'click', :execute => 'click',
@ -101,16 +103,145 @@ class ManageTest < TestCase
{ {
:execute => 'match', :execute => 'match',
:css => 'body', :css => 'body',
:value => '2Manage Lastname' + user, :value => '2Manage Lastname' + random,
:match_result => true, :match_result => true,
}, },
{ {
:execute => 'wait', :execute => 'wait',
:value => 1, :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' }) browser_signle_test_with_login(tests, { :username => 'master@example.com' })
end end

View file

@ -176,16 +176,23 @@ class TestCase < Test::Unit::TestCase
else else
assert( false, "(#{test[:name]}) url #{instance.current_url} is not matching #{action[:result]}" ) assert( false, "(#{test[:name]}) url #{instance.current_url} is not matching #{action[:result]}" )
end end
elsif action[:element] == :alert
element = instance.switch_to.alert
else else
assert( false, "(#{test[:name]}) unknow selector for '#{action[:element]}'" ) assert( false, "(#{test[:name]}) unknow selector for '#{action[:element]}'" )
end end
if action[:execute] == 'set' if action[:execute] == 'set'
element.clear
element.send_keys( action[:value] ) element.send_keys( action[:value] )
elsif action[:execute] == 'select' elsif action[:execute] == 'select'
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, action[:value]) dropdown.select_by(:text, action[:value])
elsif action[:execute] == 'click' elsif action[:execute] == 'click'
element.click element.click
elsif action[:execute] == 'accept'
element.accept
elsif action[:execute] == 'dismiss'
element.dismiss
elsif action[:execute] == 'send_key' elsif action[:execute] == 'send_key'
element.send_keys action[:value] element.send_keys action[:value]
elsif action[:execute] == 'match' elsif action[:execute] == 'match'